Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove redundant braces in with #852

Closed
gilch opened this issue Jul 25, 2015 · 4 comments
Closed

Remove redundant braces in with #852

gilch opened this issue Jul 25, 2015 · 4 comments

Comments

@gilch
Copy link
Member

gilch commented Jul 25, 2015

from this

(with [[arg (expr)] [(expr)]] block)

to this

(with [(expr) :as arg
       (expr)]
  block)
@algernon
Copy link
Member

I wouldn't use keywords there... instead:

(with [arg (expr)
       _ (expr)]
  block)

Just make them pairs - easy to split, easy to work with, less to type, and - in my opinion - feels more natural.

@algernon algernon added this to the Grand Language Cleanup milestone Jul 25, 2015
@gilch
Copy link
Member Author

gilch commented Jul 25, 2015

@algernon I like this suggestion. I had actually considered it before settling on the :as proposal, partially for consistency with import.

The _ isn't a good choice though. I know it's commonly used as a dummy variable in other languages. In Prolog and Lua, for example. It's not such a good choice in Python, however. In the Python shell, _ is like * in the Common Lisp repl or *1 in Clojure's repl. It's the value of the last input.

How about this instead:

(with [arg (expr)
       nil (expr)]
  block)

Rather than insert junk into the AST because Hy requires a variable we're not going to use, (be it _ or otherwise), the nil will make it clear that no assignment is being made. Since obviously you can't assign to nil. It's a literal. This may lengthen the implementation just a little bit, but it's not hard to check a list for nils.

@algernon
Copy link
Member

Nil's fine, yep.

@algernon
Copy link
Member

FWIW, this should be done after #713.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants