Arc Forumnew | comments | leaders | submitlogin
2 points by akkartik 4749 days ago | link | parent

Here it is in wart:

  mac let(vars f . body) :case (and cons?.vars (keyword? car.vars))
    `(with ,(collect:each k vars
              (yield sym.k)
              (yield:f sym.k))
       ,@body)
It took me several hours to get to this; in the process I uncovered lots of things I'd forgotten to implement :) And bugs :/

http://github.com/akkartik/wart/compare/37d4a2d736...d38d477...

When I try to eval:

  let (:a :b) (table 'a 1 'b 2) (cons a b)
..it cranks for a good second and a half, and conses over a million cells. (It also leaks 24 cells; that's top priority to fix.)


3 points by akkartik 4748 days ago | link

I've modified ssyntax precedence to follow rocketnia's suggestion[1] rather than arc. Now[2] it looks like this:

  mac let(vars f . body) :case (and cons?.vars keyword?:car.vars)
    `(with ,(collect:each k vars
              (yield sym.k)
              (yield f:sym.k))
       ,@body)
[1] http://arclanguage.org/item?id=13974

[2] git clone git://github.com/akkartik/wart.git && git checkout 2007e158c8

-----

1 point by Pauan 4747 days ago | link

"(with hash ...)"

This is very similar to a macro in Arubic-style namespaces:

  (eval-w/ foo ...)
The above evaluates the expression "..." in the "foo" namespace, which may potentially be a table. That's not quite right, though. Here's the correct version:

  (eval-w/ (new-namespace foo namespace)
    ...)
The above could then be easily wrapped in a macro like "w/table", or even overloading the "with" macro as you did.

---

"..it cranks for a good second and a half, and conses over a million cells."

I'm not entirely sure how such a simple expression could cause so much consing. What is wart doing with all those cells?

-----

2 points by akkartik 4747 days ago | link

"What is wart doing with all those cells?"

It's turtles all the way down, but I need to better understand the details.

-----