Arc Forumnew | comments | leaders | submitlogin
2 points by almkglor 6060 days ago | link | parent

== Easy variables

Hmm. We could redefine 'do in such a manner that we could introduce variables directly in the sequence, like so:

  (do
     (niaw)
     (var x 42)
     (woof x)
     (var z 99)
     (grrr x z))

  ==>

  (do
    (niaw)
    (with (x 42)
      (woof x)
      (with (z 99)
        (grr x z))))
== short names

This looks like a good lesson to learn.

== op wins

Arc's [ ... _ ... ] syntax approximates a limited form of SRFI-26 'cute or Goo's op; having a separate syntax also makes it stand out.



2 points by absz 6060 days ago | link

Careful! From http://www.paulgraham.com/arclessons.html:

Implicit local variables conflict with macros.

In previous Lisps if you wanted to create a local variable you had to do it explicitly with a let. In Arc we were planning to let users declare local variables implicitly, just by assigning values to them. This turns out not to work, and the problem comes from an unforseen quarter: macros.

If you're going to declare local variables implicitly, you have to decide what the scope of the new variable will be. We decided we would make new variables local to blocks: a local variable created implicitly by assignment would have a scope that extended to the nearest enclosing do (Arc's progn).

...

What convinced us to toss it was not a technical problem but a social one. In a language with implicit local variables and macros, you're always tripping over unexpected lexical contours. You don't want to create new lexical contours without announcing it. But a lot of macros that don't look like blocks in the call expand into blocks. So we provided a second block operator, called justdo, which was like do but didn't create a new lexical contour (i.e. it is Common Lisp progn), and this is what you were supposed to use in macroexpansions.

The trouble was, I kept forgetting and using do instead. And I was thereby writing utilities with the worst sort of bug: the kind that might not show up for years, and only then in someone else's code.

...

This problem is not limited to Lisp. Macros and implicit local variables just don't seem to work well together. Meaning that any language that already has implicit local variables will run into trouble if they try to add macros.

----------

Maybe your "explicit var" would work, but it might just put the problem back from the other direction, so to speak. Perhaps if you give macros some form of "lexical hygiene" (yeah, yeah, hygiene bad, etc.)... How does Goo do it?

-----

1 point by eds 6060 days ago | link

http://arclanguage.org/item?id=1736

-----