On Sat, Dec 17, 2016 at 11:51:04PM +0100, Joh-Tob Schäg wrote:
> There is no (efficient) way to find the symbol (1 2 3) is bound to. So
> would you have to know the symbol all the time.
> (de add-to-global-list (Sym Value)
> (setq Sym (cons Value Sym)))
> (de delete-from-global-list (Sym)
> (setq Sym (cdr Sym)))
Note that this will not work as one might expect. It sets the value of the
symbol 'Sym', not of the symbol it is bound to. You need a level of indirection
using 'set' instead of 'setq', and 'val'.
(set Sym (cons Value Sym)))
(set Sym (cdr (val Sym))) )
> But i guess you do not want to pass the symbol around. But the function
> still does need to what global symbol to work on. You can either use
> Picolisp object system for that or you can implement it on your own.
> (de return-list-handler (@Symbol)
> (fill '((Op-code . Operands)
> ((= Op-code "add") (setq @Symbol (cons (car Operands) @Symbol)))
> ((= Op-code "sort") (setq @Symbol (sort @Symbol)))
> ((= Op-code "readcar") (car @Symbol))
> ((= Op-code "readcdr") (cdr @Symbol))
> ((= Op-code "del") (setq @Symbol (cdr @Symbol)))))))
Same here. You need 'val' in some places, e.g.
(sort @Symbol) -> (sort (val @Symbol))
Also, I would recommend 'case' instead of 'cond' here
(For all the above, I'm still not able to detect any practical sense or purpose,
but that's up to Dean perhaps ;)