Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between `context` and `object`?

In Rebol 3, there are the functions object and context.

What's the purpose of the difference?

Note : for reference, in red, both are the same, and object doesn't exist in rebol 2

Context: no pun intended

Initially, I was wondering why we had context instead of make object!

Now, after learning of the object word used to make objects, I'm curious to know why they are all different and the rationale for having different things to make the same thing.

Note that in rebol3:

object: make function! [[
    "Defines a unique object."
    blk [block!] "Object words and values (modified)"
][
    make object! append blk none
]]

It appends none to the block. Why? Is this just a minor difference? Does it deserve a separate question?

In all 3:

context: make function! [[
    "Defines a unique object."
    blk [block!] "Object words and values (modified)"
][
    make object! blk
]]

P.S. slight differences in construction between the versions

like image 909
Geeky I Avatar asked Feb 05 '23 10:02

Geeky I


1 Answers

context was historically introduced in Rebol2 as a shortcut to make object!, and to better signify the intent of using the object to provide a definitionally scoped namespace for organizing user code.

object was added in Rebol3 in order to provide a more natural name for the shortcut and be more useful when constructing the object dynamically using collect-words for example.

Red should be using the Rebol3 object definition, as it provides that handy extra feature.

like image 97
DocKimbel Avatar answered May 16 '23 07:05

DocKimbel