rob_w has quit [Remote host closed the connection]
seninha has joined #picolisp
isaneran has quit [Ping timeout: 252 seconds]
isaneran has joined #picolisp
isaneran has quit [Remote host closed the connection]
msavoritias has quit [Remote host closed the connection]
pablo_escoberg has joined #picolisp
<pablo_escoberg>
Hey all, quick question about `var` and `var:` : Once I declare a `var` in a given class, is there any way to override it for subclasses? I tried declaring the var in the class definition, and I tried doing it with the second form of `var` but it seems the value defined in the superclass persists. Should I use sth like (put *Class Val)
<pablo_escoberg>
instead, or is there some way to do it with `var`?
<beneroth>
I would think you can just define an additional var in your subclass
<beneroth>
var: and meta go through parent classes until they find a definition
<pablo_escoberg>
That's exactly what I expected, but not what I'm seeing.
<pablo_escoberg>
http://pb1n.de/?6adc65 is an example. You would expect "xxxx" but you get "asdf". Question is, is there a way to override this?
<beneroth>
your mistake is calling (var:) directly on the +B class instead of an +B object
<beneroth>
(with (new '(+B)) (prinl (var: foo)))
<beneroth>
gives xxxx
<beneroth>
look at the implementation of 'var:, it does apply 'meta on This. This gets evaluated to the list of classes, so in case of +B it will be '(+A) but in case of an +B object it will be '(+B +A)
pablo_escoberg has quit [Ping timeout: 245 seconds]
<beneroth>
in your example, try : (with '+A (var: foo))
<beneroth>
-> NIL
<beneroth>
as expected, because calling it (with '+A ...) it only looks at the parents of +A, not +A itself
pablo_escoberg has joined #picolisp
<pablo_escoberg>
Ah, ok. Got it. TY.
pablo_escoberg has quit [Ping timeout: 245 seconds]