[REBOL] Re: Please help me out
From: henrikmk::gmail at: 24-Aug-2010 0:49
On Mon, Aug 23, 2010 at 11:23 PM, Emeka <emekamicro-gmail.com> wrote:
> Why REDUCEd? =A0I am a bit confused now.
I think it's easier to say that block values are not "live" i.e. they
don't turn into something else as they are at no point evaluated and
they do not necessarily reference anything, but the values may be
bound somewhere (much deeper topic).
You can then do various things to evaluate the content of the block or
parts of it. REDUCE is just one of many ways:
a: 4
b: 1
reduce [a b now]
== [4 1 23-aug-2010/12:12:12]
You can also DO the block. That is essentially just running REBOL code.
do [a b now]
== 23-aug-2010/12:12:12
One of the big strengths of REBOL is that you can look at that block
in different ways: You can consider it a dialect, a sublanguage of
your own design. You can look at it as raw data as input for a
function or you can look at it as actual code, which is done above.
When you treat the block as data, the values are usually not treated
as live elements, but you are entirely free to do that.
Here is the example above as a dialect:
parse [a b now] [
any [set w ['a | 'b] (print ["you asked for a word" w])]
'now (print "looks like you asked for the time")
]
you asked for a word a
you asked for a word b
looks like you asked for the time
A side-effect of processing blocks like this, is that it makes it easy
to make data transfers secure or the reading and inspection of foreign
data. You can easily choose to evaluate a value in a block or perform
a special action, if you don't think it's safe.
I'm not sure it answers any of your questions, but maybe you'll
understand a bit about the code vs. data aspect of REBOL.
--
Regards,
Henrik Mikael Kristensen