Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the undocumented block you get from THIRD on object/function in Rebol2?

I've read internally R2 stores contexts as two tables, one for words and the other for values, so you can ask for them:

o: context [a: 1 b: 2]
>> first o
== [self a b]
>> second o
== [make object! [
        a: 1
        b: 2
    ] 1 2]

in any way...

>> pick o 1
== [self a b]
>> pick o 2
== [make object! [
        a: 1
        b: 2
    ] 1 2]

but there's a third "table" (a block) which seems to be undocumented and this one is only accessible using third function

>> third o
== [a: 1 b: 2]

>> pick o 3
** Script Error: Out of range or past end
** Near: pick o 3

what is supposed to be this third block?

something similar seem to occur in functions but this time both third and pick perform well:

>> f: func [a] [print a]
>> first :f
== [a]
>> second :f
== [print a]
>> third :f
== [a]
>> pick :f 1
== [a]
>> pick :f 2
== [print a]
>> pick :f 3
== [a]

first block is params, second block is body but what does this third block represents in a function?

like image 681
Pep Avatar asked Feb 26 '14 21:02

Pep


1 Answers

Third returns object definition.

>> body: [a: 1 b: 2]
== [a: 1 b: 2]
>> obj: context body
>> equal? body third obj
== true
>> strict-equal? body third obj
== true

It's same as body-of in Rebol 2.7.7 and higher and Rebol 3.

like image 94
rebolek Avatar answered Oct 23 '22 09:10

rebolek