[REBOL] Re: [ A world of words ] naming convention, namespace, namespace poll
From: dockimbel:free at: 4-Jun-2003 11:06
Hi Marc,
En réponse à Marc Meurrens <[rebol--meurrens--org]>:
[...]
> ;;;;;;;;;;;;; WHAT I WANT... THE "TANK" EXAMPLE
>
> use [ _capacity ] [
> _capacity: 100
> tank1: context [
> _content: 0
> content+: func [add][
> _content: max 0 min _capacity _content + max 0 add
> ]
> content-: func [sub][
> _content: max 0 min _capacity _content - max 0 sub
> ]
> =content: does [_content]
> =capacity: does [_capacity]
> ]
> ]
[...]
If you use private contexts, keep in mind that you may loose some REBOL
important features like :
- reflection :
>> first tank1 ; get all words defined in object tank1
== [self _content content+ content- =content =capacity]
You cannot see '_capacity anymore. A function using reflection to process
your object will miss this word.
- serialization :
>> tank1: load mold tank1
>> tank1/=capacity
>> _capacity
** Script Error: _capacity has no value
** Near: _capacity
Same issue when saving then reloading your object with save & load or when
sending it over a tcp connection.
HTH,
-DocKimbel