Thorsten Jolitz <tjol...@gmail.com> writes: > Alexander Burger <a...@software-lab.de> writes:
Ok, this works ;-) : (de foo2 (ClsNm MethNm) (class +Bar) (dm plus> (X) (+ 1 X))) -> foo2 : (foo2) -> plus> : (setq B (new '(+Bar))) -> $177641167640474 : (plus> B 3) -> 4 ')) so somehow my understanding of read macros is false here: (class ~(any (pack '+ ClsNm))) > Hi Alex, > >>> : (de +Test >>> (T (Hi) (=: hi Hi)) >>> (hi> (Nm) (or (text (: hi) Nm) "Dear Sir or Madam,")) ) >>> -> +Test >> >> .. while this is half of the lunch ... >> >>> : (hi> Foo "Alex") >>> !? (hi> Foo "Alex") >>> hi> -- Undefined # => WHY? >> >> .. it is better (as Joe Bogner suggested) to use 'dm'. >> >> The reason is that 'dm' does a little more: It also defines the symbol >> 'hi>' to >> behave as a sender of messages to objects, equivalent to >> >> : (setq hi> meth) >> -> 22951574276 >> >> With that, the following works >> >> : (hi> Foo "Thorsten") > > Ok, I see. > > But, in a source file it's obvious how to use (class) and (dm) > > (class 1 ...) > (dm ...) > (dm ...) > > (class 2 ...) > (dm ...) > (dm ...) > > The reader seems to remember which class was defined last, and > associates the following methods to that class. > > How to use (class) and (dm) in a program is not that obvious for me: > > :(de foo (ClsNm MethNm) (class ~(any (pack '+ ClsNm))) (dm ~(any (pack > MethNm ">") (X) (+ 1 X)))) > -> foo > : (foo "Bar" "plus") > !? (val (setq *Class (car Lst))) > 270136 -- Variable expected > ')))) > > Would you rather write the classical definitions to a file and then load > that? -- cheers, Thorsten -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe