Re:REBOL Oneliners
by voldacar on Sunday March 08, 2020 @04:24PM
(#22520358)
The syntax looks kind of odd - it feels a bit like trying to read lisp without the parentheses. Seems like a very expressive language though based on the number of characters needed to get stuff done
[ Parent
| on HN ]
IIRC I read somewhere that Rebol is homoiconic but not sure.
It is. For example, in the third example:
foreach file load %./ [if not dir? file [write/binary join ftp://user:[email protected]/ 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
2Thanks.
Curious ones can find a brief explanation of this core idea in a Github wiki (shameless plug!).
https://github.com/red/red/wiki/%5BDOC%5D-How-Red-works:-a-b...