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

[REBOL] Object private member (was: objects: overhead, private data, nami ng con

From: coussement::c::js::mil::be at: 20-Sep-2001 14:12

Hi REBOLians: About object private members, could anybody explain this to me: <code> o: context [ _a: 5 set '_b 10 get-a: does [print-a] set 'print-a does [print _a] set 'get-b does [print _b] ] </code> Let's try:
>> o/get-a
>> o/get-b
** Script Error: Invalid path value: get-b ** Near: o/get-b
>> source o
o: make object! [ _a: 5 get-a: func [][print-a] ]
>> o/_a
== 5
>> o/_b
** Script Error: Invalid path value: _b ** Near: o/_b
So... it looks like within an object, the use of 'set invoque a privatization of the word, which is not any more visible from the outside. Great: I can use this property for making private members, but this way of doing is still strange to me. Any clue why a 'set-word! has two different ways of handling things, within this context ? ==christophe