4 ms·
It is. For example, in the third example: foreach file load %./ [if not dir? file [write/binary join ftp://user:pass@example.com/ file read/binary file]] T
by Izkata 7y ago
It is. For example, in the third example:
foreach file load %./ [if not dir? file [write/binary join ftp://user:pass@example.com/ file read/binary file]]
Those two sets of [ ] are the block! datatype, which is an array-like type. "foreach" is a function that takes an identifier and two block!s ("load" returns a block!), executing the second for each one in the first.
Quick example showing it:
>> something: [print val]
== [print val]
>> foreach val [1 2 3] something
1
2
3
>> append something [+ 3]
== [print val + 3]
>> foreach val [1 2 3] something
4
5
6
The second example in the oneliners kinda shows this as well, but I suppose it's not obvious without knowing more of the language. The outer block! is actually a separate dialect being passed to the layout function as data, that the layout function parses and handles. What's normally thought of as rebol is called the "do dialect", because that's how you run a block! as code:
>> X: [print 1 + 2]
== [print 1 + 2]
>> do X
3
>> X/3
== +
>> X/3: to-word {*}
== *
>> X
== [print 1 * 2]
>> do X
2
- noobdood 7y agoThanks.