Arc Forumnew | comments | leaders | submitlogin
New scoping idea
2 points by akkartik 2048 days ago | 1 comment
I would post this as a comment on http://arclanguage.org/item?id=21187, particularly rocketnia's comment on indentation (http://arclanguage.org/item?id=21203), but replies are unfortunately no longer allowed.

"When invoked with a list of bindings as first argument, `let` will behave more or less like you expect it.

"When called without, it will introduce the same bindings into the current lexical environment rather than opening a new, which allows reducing nesting and the number of live environments."

https://www.reddit.com/r/lisp/comments/bfrds5/the_value_of_macros/elhp736/?context=1



3 points by shader 2048 days ago | link

I saw that reddit thread recently, and was initially against the idea, but I could see why it might have some value. It may be more efficient, and can be more concise too.

Most of the time though I think that the additional nesting layer of a a let form helps make the code clearer, and probably simpler to parse too—it's obvious where the boundaries of the scope are. Also, I'm not sure there's a good reason to suddenly introduce new variables partway through an environment.

I could see restricting '= to only assign to declared variable names, if that would help with the typo vs global problem. Maybe introduce a separate 'declare or 'global form that can be used to explicitly introduce global variables, instead of accidentally making them. On the other hand, arc is the language of user power—adding complexity to prevent people from shooting themselves in the foot seems like a step in the wrong direction.

Pros and cons...

-----