[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: let and for vs. lambda variations



>   fn %local var wrapped-list cmd {
>     let (old=$$var)
>       unwind-protect {
>         $var = <={$wrapped-list}
>         $cmd
>       }{$var = $old}}
> 


> (Whose let is of course rewritable as a lambda...)  Funny, I don't
> even see a problem with name space collisions!

Paul> what happens if the variable you're rebinding is named old, var,  
Paul> wrapped-list, or cmd?  that's the name space collision i was talking  
Paul> about.

Umm, yes, of course.  Silly of me, but I still insist it can be done,
as long as you're not trying to figure it out on your way out the
door, as I was.  How about this?

  local (x=a b) cmd  -->  %local @ {cmd} x a b

where 

  fn %local 

  fn %local fun var list {
    let (old=$$var)
      unwind-protect {
        $var = list
        $fun
      }{$var = $old}}

Wrapping cmd in a lambda of its own should take care of the name space
issue.

- Harald