Hi Cle,

> > (put '+aClass 'ClassVar "new value")
> >
> > and perhaps write a utility function.
> 
> thanks for the hint. Is there any special reason, why there is no such
> utility function in picoLisp for that task? I mean defining and querying
> helpers exists ... :-/

Because it was not needed until now ;-)


> Do you have any proposal, what such a helper/utility function should be
> called to fit into (var:) (var) functions that already exists?
> ...
> Yep, like in Ruby or Smalltalk for instance ;-) I really need a counter,
> that is member of the class, as instance creation will increment said
> counter.

The proper way to access properties in the class hierarchy is 'meta'.
'meta' is also used internally by 'var:'.

Though it only returns a value, it can be used for the purposes you have
in mind if you reserve a cell (also a "variable" in picoLisp terms) for
it.

(class +aClass)
..
(var counter 0)

..

(meta MyObj 'counter)  # -> (0)

(with MyObj
   (var: counter)  # -> (0)
   (car (var: counter))  # -> 0
   ...
   (inc (var: counter))  # -> 1
)

Cheers,
- Alex
-- 
UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=unsubscribe

Reply via email to