Yes, the datatype words in the dictionary deserve some additional
explanation. I noticed that they were still out of date on the
last release of the dictionary.
WRT parens, the 2.0 behavior is correct (similar to the original Alpha
version). A paren is identical to a block, except that the interpreter
will evaluate it.
blk: [1 + 2]
print blk
print do blk
par: make paren! blk
print par
So, in a way, parens are "little functions" that take no args. In
language terms, parenthetic expressions are first class values, they
can be assigned to vars, passed as args, returned as results.
(Of course, they're not really functions at all.... but that's one
way to think of the behavior.)
Finally, to illustrate the truth of using parens in function specs:
>> fun: func [:par (paren!)][head insert tail :par [+ 4]]
>> a: fun (1 + 3)
== (1 + 3 + 4)
>> a
== 8
Ah, the things you need to do to be sure a language is reflective
(that is, it deals well with itself). A gem.
-Carl
PS: Docs team: add this.
At 11/28/99 01:25 PM -0800, you wrote:
>Hi Gabriele,
>
>glad to see you back in good "form" (pun itended ;-).
>
>you wrote:
>>That behaviour is not due to form:
>
>
>Correct. What is it due to?
>
>Apparently, the way REBOL treats words in parentheses has changed since
>version 1:
>Here's what version 1 used to do:
>
>>> word: "meaning"
>meaning
>>> var2: make paren! [word]
>(word)
>>> var2
>(word)
>>> :var2
>(word)
>
>(This was copied from the Version 1 console: 1.0.3.3 (Win32 x86))
>
>Compare to your experiments:
>
>>> word: "meaning"
>== "meaning"
>>> var2: make paren! [word]
>== (word)
>>> var2
>== "meaning"
>>> :var2
>== (word)
>
>In version 1 get and evaluation of var2 amounted to the same thing. In the
>current version this is no longer true.
>
>How do you account for the difference between:
>>> :var2
>== (word)
>
>and
>
>>> var2
>== "meaning"
>
>?
>
>Using :var2 returns something different from evaluating var2. However, the
>new User's Guide (beta) continues to say:
>
>User's Guid (beta)
>:word Retrieve the word's value, but don't evaluate it.
> This is useful for referring to functions and other
> types of data without evaluating them.
>
>So, everything would be peachy, if (word) was covered by the vague "... and
>other types of data ...". Is a word in parentheses a type of data that is
>evaluated? Not according to the dictionary:
>
>"PAREN!
>
>Represents the PAREN datatype, both externally to the user and internally
>within the system. When supplied as an argument to the MAKE function, it
>specifies the type of value to be created. When provided within the
>specification of the argument of a function, it requests the interpreter to
>check that the argument value is of the specified type when the function is
>evaluated. "
>
>For our discussion it is important to note that the dictionary does not
>document a usage of paren! which leads to the evaluation of a word. My
>guess is that was introduced after 1.0. Version 2.1 already includes the
>new way (word) works.
>
>I'd say the dictionary needs to be updated. BTW, if anyone from the REBOL
>crew is reading along, the following statement in the dictionary entry for
>PAREN! also needs to be carefully reworded ;-):
>
>"When provided within the specification of the argument of a function, it
>requests the interpreter to check that the argument value is of the
>specified type when the function is evaluated. "
>
>That was never true.
>
>Elan
>