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

Re: let and for vs. lambda variations



Actually, even the multiple binding forms can be rewritten as lambdas,
using the wrapping trick, but it would be awkward and require some
obfuscated code:

  let (x=a b;y=c d) cmd  -->

  @ xy {@ y {@ x {cmd} <=$xy(1)} $xy(2)} <={wrap a b} <={wrap c d}

where `xy' is a symbol that does not appear in the text of cmd.  (!)

I hadn't realized before that local can be rewritten as a lambda, but
after a little though I came up with the following, for a single
binding local (so the above obfuscation is avoided):

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

where 

  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!

If you insist that for, local, and let stay together or leave
together, I think I'll vote that they stay.  The obfuscation needed
for handling the multiple binding let without making it a let* is just
too much.

But who uses multiple binding for, anyway?  And for what?

- Harald