Re: difference between (let) and (bind)

2011-07-29 Thread Edwin Eyan Moragas
Hi Tomas and Alex,

thanks much for the patience. i'm getting there. hopefully. and slowly. :)

best

/e

On Thu, Jul 28, 2011 at 3:13 PM, Tomas Hlavaty  wrote:
> Hi Edwin,
>
>> reading the docs again after this, (let) evaluates while (bind) does
>> not. i hope i got that right.
>
> I think it's the other way round, see bellow 'up' and 'up.'.
>
>> i see. but i still have to experience them firsthand. looking at the
>> java.wl, you have (up.) and (if.).
>
> Yes:
>
>   (up [cnt] sym ['val]) -> any
>
> while
>
>   (up. ['cnt] 'sym ['val]) -> any
>
> I think that 'up' can be implemented on top of 'up.'.  I tried that in
> java.wl but in the end I kept it implemented in java for some reason.
>
>> i'm actually in the process of skinning minipicolisp to retain the wl
>> functions
>
> That's an excelent exercise;-)
>
> Some time ago somebody suggested very neat implementation of 'let' using
> function application (it's archived on this mailing list).  In the
> spirit of wl, i.e. minimal native code and as much as possible in lisp,
> it would be good to use that instead of native 'let', 'let?' and 'bind'.
>
> Cheers,
>
> Tomas
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>
--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: difference between (let) and (bind)

2011-07-28 Thread Tomas Hlavaty
Hi Edwin,

> reading the docs again after this, (let) evaluates while (bind) does
> not. i hope i got that right.

I think it's the other way round, see bellow 'up' and 'up.'.

> i see. but i still have to experience them firsthand. looking at the
> java.wl, you have (up.) and (if.).

Yes:

   (up [cnt] sym ['val]) -> any

while

   (up. ['cnt] 'sym ['val]) -> any

I think that 'up' can be implemented on top of 'up.'.  I tried that in
java.wl but in the end I kept it implemented in java for some reason.

> i'm actually in the process of skinning minipicolisp to retain the wl
> functions

That's an excelent exercise;-)

Some time ago somebody suggested very neat implementation of 'let' using
function application (it's archived on this mailing list).  In the
spirit of wl, i.e. minimal native code and as much as possible in lisp,
it would be good to use that instead of native 'let', 'let?' and 'bind'.

Cheers,

Tomas
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: difference between (let) and (bind)

2011-07-28 Thread Alexander Burger
Hi Edwin,

> On Thu, Jul 28, 2011 at 4:48 AM, Tomas Hlavaty  wrote:
> > Hi Edwin,
> >
> >> thinking about it a bit, i can just do away with one and live with the
> >> other?  say, can i just live with (bind)?
> >
> > yes, but it is more convenient to write let in your programs instead of
> > the bind with constructing the binding list manually.  However, in
> > certain situations, one needs an evaluating version, e.g. when you
> > construct code programmatically.  I hit this situation in the wl
> 
> reading the docs again after this, (let) evaluates while (bind) does
> not. i hope i got that right.

Yes.

BTW, in the reference evaluated arguments are marked with a quote

   (let sym 'any . prg) -> any
   (let (sym 'any ..) . prg) -> any

   (bind 'sym|lst . prg) -> any

so we see that 'let' doesn't evaluate 'sym', while 'bind' does.


As Tomas said, it is a matter of convenience:

   (let A (lines "lib.l")
  (* A A) )


If you wanted to use 'bind' for that, you could do

   (bind 'A
  (setq A (lines "lib.l"))
  (* A A) )

or

   (bind (list (cons 'A (lines "lib.l")))
  (* A A) )


'bind' is more flexible, as the symbols can be determined at runtime,
while 'let' allows for a more readble code.

Cheers,
- Alex
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: difference between (let) and (bind)

2011-07-27 Thread Edwin Eyan Moragas
On Thu, Jul 28, 2011 at 4:48 AM, Tomas Hlavaty  wrote:
> Hi Edwin,
>
>> thinking about it a bit, i can just do away with one and live with the
>> other?  say, can i just live with (bind)?
>
> yes, but it is more convenient to write let in your programs instead of
> the bind with constructing the binding list manually.  However, in
> certain situations, one needs an evaluating version, e.g. when you
> construct code programmatically.  I hit this situation in the wl

reading the docs again after this, (let) evaluates while (bind) does
not. i hope i got that right.

(yes sir, still learning. i'm actually in the process of skinning
minipicolisp to retain the wl functions. what i'm trying to do is
understand the minipicolisp interpreter)

> interpreter (the one written in Java) where I wanted to implement as
> much as possible in pure picolisp (as opposed to Java).  There I needed
> evaluating versions of some functions.  I don't remember off the top of
> my head which cases were those functions but I usually named them with a
> leading dot character to make it obvious they were internal.  When you
> have the evaluating version it becomes easy to implement the macro
> version on top of them.

i see. but i still have to experience them firsthand. looking at the
java.wl, you have (up.) and (if.).

i'll let this stew some. please don't hesitate to shed further
enlightenment on this tho.

thank you.

/e
>
> Cheers,
>
> Tomas
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>
--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: difference between (let) and (bind)

2011-07-27 Thread Tomas Hlavaty
Hi Edwin,

> thinking about it a bit, i can just do away with one and live with the
> other?  say, can i just live with (bind)?

yes, but it is more convenient to write let in your programs instead of
the bind with constructing the binding list manually.  However, in
certain situations, one needs an evaluating version, e.g. when you
construct code programmatically.  I hit this situation in the wl
interpreter (the one written in Java) where I wanted to implement as
much as possible in pure picolisp (as opposed to Java).  There I needed
evaluating versions of some functions.  I don't remember off the top of
my head which cases were those functions but I usually named them with a
leading dot character to make it obvious they were internal.  When you
have the evaluating version it becomes easy to implement the macro
version on top of them.

Cheers,

Tomas
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: difference between (let) and (bind)

2011-07-27 Thread Edwin Eyan Moragas
Hi Tomas,

On Thu, Jul 28, 2011 at 1:27 AM, Tomas Hlavaty  wrote:
> Hi Edwin,
>
> roughly speaking, bind is a function while let is a macro.  They differ
> in argument evaluation.  bind is programmable while let is more of a
> syntax thingy.

thank you for this.

thinking about it a bit, i can just do away with one and live with the other?

say, can i just live with (bind)?

>
> Cheers,
>
> Tomas
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>
--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: difference between (let) and (bind)

2011-07-27 Thread Tomas Hlavaty
Hi Edwin,

roughly speaking, bind is a function while let is a macro.  They differ
in argument evaluation.  bind is programmable while let is more of a
syntax thingy.

Cheers,

Tomas
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe