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

[REBOL] Re: Private words in objects?

From: gabriele::colellachiara::com at: 6-Jul-2006 11:05

Hi Gregg, On Wednesday, July 5, 2006, 6:16:09 PM, you wrote: GI> You *can* do it today, but it takes extra effort. I thought I would do GI> it a lot, once I figured out how (with the help of people here), but GI> I've never used it in a production system. The way Gregg is mentioning is just using a "hidden" context for your "protected" words. Example: use [private-field] [ private-field: 2 my-obj: context [ public-field: 1 set-field: func [val] [ private-field: val ] get-field: does [ private-field ] ] ] The disadvantage is that you can't easily clone the object (that wouldn't clone the other context, so that would be shared by all clones), so you need a constructor function. However there is no way for you to change PRIVATE-FIELD by mistake. (Note that there are many ways to achieve this result, so it really depends on what's best in your specific case.) Regards, Gabriele. -- Gabriele Santilli <> --- Colella Chiara software division ---