Arc Forumnew | comments | leaders | submitlogin
Explicit local =
2 points by Amferreira 5939 days ago | 7 comments
I was reading some old Arc stuff, about implicit variable declaration using =, and how that turned out bad, and was wondering if it would be possible to do something like this: (do (l= x 5) (cons x 'a))) Basically a = that adds the variable to the local scope, the diference from the original arc = being that it is explicit, not implicit.


3 points by drcode 5939 days ago | link

The issue is that the variable is at the scope of the "do", which means it can't be a standard macro, but a change to the language implementation. It can definitely be done though- The question is more as to whether this offers enough conceptual advantage over "let"...

This is essentially the same (or very similar at least) to a system I implemented a while back, which you can read about here: http://arclanguage.org/item?id=7485

I added an additional twist that gives it additional advantages that I argue offset the cost of a new language construct.

-----

1 point by bOR_ 5938 days ago | link

what is exactly the advantage it has over 'let'? Just brevity? (I'm not sure if having explicit local variables adds clarity)

-----

2 points by drcode 5938 days ago | link

it's the combo of brevity, one less set of parens and one less indentation level.

-----

1 point by stefano 5938 days ago | link

It would let you avoid adding an indentation level.

-----

1 point by Amferreira 5938 days ago | link

Well, I'm kinda ashamed, but I just found out that define in scheme does just that. If you define a variable inside a block, the variable belongs to that block. Does def in arc work like that also? (I don't have arc in this computer, so I can't test it)

-----

2 points by stefano 5937 days ago | link

I think internal 'define in scheme must occur at the beginning of a function definition, not intermixed wth other expressions.

-----

2 points by almkglor 5938 days ago | link

No, it doesn't

-----