Re: Needing a trick with 'de

2017-10-16 Thread andreas
> My question: which mechanism frees X of the value it was setq-ed? During function execution, the variables (symbols actually) used as parameters (in the function definition) are like in an implicit (let): When executing, the values are bound to the arguments as specified in the function call,

Re: Needing a trick with 'de

2017-10-16 Thread Alexander Burger
On Mon, Oct 16, 2017 at 03:44:54PM +0200, Christophe Gragnic wrote: > Because I thought that setq would store a value in the parameter var > "more permanently". > Something like: > > : (foo (need 3)) >(need 3) >-> 3 > : X > -> (need 3) # what I expected > > I thought using a let

Re: Needing a trick with 'de

2017-10-16 Thread Christophe Gragnic
On Mon, Oct 16, 2017 at 3:25 PM, Alexander Burger wrote: > This is just unnecessary overhead, as 'let' is basically 'bind' (or 'use' to > be > more correct) plus 'setq'. And 'X' is bound already by the function call. So > why > waste time and (stack)space? Because I

Re: Needing a trick with 'de

2017-10-16 Thread Alexander Burger
Hi Christophe, > I'm quite surprised of the use of setq instead of let. > Could you please elaborate? Do you mean, staying with the generated example code: (de foo X (setq X (car X)) (msg X) (length (eval X)) ) to generate instead: (de foo X (let X (car X)

Re: Needing a trick with 'de

2017-10-15 Thread Christophe Gragnic
On Sat, Oct 14, 2017 at 7:48 AM, Alexander Burger wrote: > You are close :) Hi Alex, Thanks, I'm making some progress at last! A personal lesson: when meta-programming, I should make more use of pp. > I would do this: > >(de decar Lst > (def (++ Lst) >

Re: Needing a trick with 'de

2017-10-14 Thread rick
On Sat, 14 Oct 2017 07:48 +0200, Alexander Burger wrote: > Test: > > [...] > >: (foo (need 3)) >(need 3) >-> 3 Rounding off the test: : (foo (need 3) 'this-and-subsequent-will-be-ignored 42 (/ 1 0)) (need 3) -> 3 Of course. :) -- UNSUBSCRIBE:

Re: Needing a trick with 'de

2017-10-13 Thread Alexander Burger
Hi Christophe, > (decar myfn arg > # here arg is the first arg given when calling myfn, unevaluated > ) > > > This is my attempt: > > (de decar args > (let (fn (car args) > arg (cadr args) > body (cddr args)) > (set fn (list (list "arg") (list 'let arg "arg" (list