foreach := every doesn't do what you think it does. "every" is a reserved word and can't be assigned litrally. What you get is the resulat of evluating the expression "every collect := tab". which will be asisnged to foreach. What you want to do is"
$define foreach every
at the top, that will give you the behavior you are aiming for.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
An expression like write(type(foreach) with your orginal would show a null as foreach would be assigned the result of an empty every expression. (Or that form of every fails, and you end up with a new variable reference when you look at it?? need to run some experiments).
Plus, be careful redefining collect, it's already a builtin for the garbage collector. You can still get at the original with proc("collect", 0) though.
Edit: shouldn't leave reply windows open for too long; Hard working people like Jafar come by and make the info look redundant. ;-)
Cheers,
Brian
Last edit: Brian Tiffin 2017-08-30
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
Anonymous
Gen AI apps are built with MongoDB Atlas
Atlas offers built-in vector search and global availability across 125+ regions. Start building AI apps faster, all in one place.
View and moderate all "Help Getting Started" comments posted by this user
Mark all as spam, and block user from posting to "Discussion"
Hello,
I'm playing around with assigning proc values to variables but not sure what I'm doing wrong.
In the code below I get the following error:
test.icn:11: # "x" unclosed literal or missing operator
Seems my assignment to "foreach" doesn't work, whereas the one for "collect" does. I can't spot the difference.
foreach := every doesn't do what you think it does. "every" is a reserved word and can't be assigned litrally. What you get is the resulat of evluating the expression "every collect := tab". which will be asisnged to foreach. What you want to do is"
$define foreach every
at the top, that will give you the behavior you are aiming for.
Anon,
every is not a procedure, it's a reserved word, so it'll need a different way of creating the alias
Preprocessor might do
but that is maybe not what you are aiming for?
An expression like
write(type(foreach)with your orginal would show a null as foreach would be assigned the result of an empty every expression. (Or that form of every fails, and you end up with a new variable reference when you look at it?? need to run some experiments).Plus, be careful redefining collect, it's already a builtin for the garbage collector. You can still get at the original with proc("collect", 0) though.
Edit: shouldn't leave reply windows open for too long; Hard working people like Jafar come by and make the info look redundant. ;-)
Cheers,
Brian
Last edit: Brian Tiffin 2017-08-30