Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search

[REBOL] Re: 'parse-url - where defined?

From: larry:ecotope at: 30-Jan-2001 12:47

Hi Anton Good question. How does read-via work when parse-url is not a globally defined variable? I thinkyou will find the answer very interesting. The answer is that many functions in both Core and View are defined in the context of objects, and some subset of them is then exported to the global context for general use. This is the current method of encapsulating functions and data. When modules come along this may change. Here is a simple console example of the way this works:
>> ob: make object! [hidden-func: func [x][x * x] set 'sq func [y]
[hidden-func y]]
>> source sq
sq: func [y][hidden-func y]
>> sq 5
== 25
>> help hidden-func
No information on hidden-func (word has no value)
>> >>probe ob
make object! [ hidden-func: func [x][x * x] ]
Because sq is defined in the object ob, it can use hidden-func or any other object variable defined. The object spec block is executed at object creation time. When words are defined by word: blabla, they are defined in the context of the object. When they are defined with set, they are defined in the next higher context level. So mult in this case is global, but it's definition uses the hidden-func in ob. Notice the executed lines of code which do not define an object var are not present after the object is created. Make sense? -Larry PS This approach can be nested at several levels.