rebmu icon indicating copy to clipboard operation
rebmu copied to clipboard

AI~ (Array/Initial) doesn't work with functions

Open rgchris opened this issue 11 years ago • 2 comments

Supplying ARRAY/INITIAL in Rebol with a function value initiates each element of the array with the product of a fresh invocation of the function. This doesn't happen in Rebmu. Rebol 3:

>> n: 1 array/initial 4 does [++ n]
== [1 2 3 4]

And in Rebmu:

>> rebmu/debug [I&[a+Jn]Aai~4 i] 
Executing: [i: & [a+ j n] a: ai~ 4 i]
== [1 1 1 1]

rgchris avatar Apr 05 '14 05:04 rgchris

Note that your example requires a get-word even in regular Rebol.

>> rebmu/debug [I&[a+Jn]Aai~4 :i]  
Executing: [i: & [a+ j n] a: ai~ 4 :i]
== [1 2 3 4]

...however, it wasn't working even when passing in the result of the function generator. (which was presumably what you tried first). So yep, there was a bug.

Fixed with the assistance of a helpful person on StackOverflow :-)

http://stackoverflow.com/questions/22892499/

hostilefork avatar Apr 06 '14 18:04 hostilefork

Ah, while it did fix the specific case of function values it changes the evaluation rules...so now you can't pass ordinary variables or expressions because of the quoting. It effectively makes AI~ have a different prototype which isn't what's needed... see comment on SO.

hostilefork avatar Apr 06 '14 18:04 hostilefork