Joh-Tob
>Why not use the idea i presented?
It's not that I won't....I'd only just come back to show what I'd found re
function arguments when I saw your solutions.
Again...thank you very much for them. All code related to what I'm trying
to do is extremely helpful given my inexperience with picolisp.
Best Regards
Dean

On 18 December 2016 at 07:05, Alexander Burger <a...@software-lab.de> wrote:

> 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)
> >       (cond
> > ((= 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
>
>    (case Op-code
>       ("add" ..)
>       ("sort" ..)
>       .. )
>
> (For all the above, I'm still not able to detect any practical sense or
> purpose,
> but that's up to Dean perhaps ;)
>
> - Alex
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>

Reply via email to