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

A big let and with change #898

Merged
merged 2 commits into from Oct 1, 2015
Merged

A big let and with change #898

merged 2 commits into from Oct 1, 2015

Conversation

algernon
Copy link
Member

This drops the outer brackets from let and with, but does NOT change let behaviour anymore. That'll be another change, if at all.

See #713 and #852.

(Thanks for the reviews so far, the scope of this change was drastically reduced.)

@algernon algernon added this to the Grand Language Cleanup milestone Aug 13, 2015
@farhaven
Copy link
Contributor

LGTM, I like it.

@gilch
Copy link
Member

gilch commented Aug 17, 2015

👎 I approve of removing the extra [] from let, but not of making it a mere alias for setv, which is counter to #240. The body has no special meaning, which is still confusing. let is marginally more useful as it is now, despite its problems.

As for with, can we use nil/None as a dummy variable, as discussed in #852? I haven't tested it, but from looking at the code, it doesn't appear to work.

@algernon
Copy link
Member Author

(with [nil (open "touch-me-gently" "w")] (print "!")) works. It worked before too, just as _ too, (with) didn't change in that regard.

I'll redo this PR, and instead of completely changing let, I'll just drop the brackets, and deal with let elsewhere.

@algernon
Copy link
Member Author

Updated, now it doesn't change let all that much, just drops the brackets.

@gilch
Copy link
Member

gilch commented Aug 17, 2015

What happens if with's [] has an odd number of arguments? Can you add an error check?

@algernon
Copy link
Member Author

The old version and the new both do the same thing: hope it does something sane-ish. I'll add a test case, though.

@algernon
Copy link
Member Author

@zackmdavis
Copy link
Contributor

(A thought prompted by #907—) as long as we're breaking the world in order to favor Clojure-style brace-minimizing implicit pairings, we should probably do cond as well.

@algernon
Copy link
Member Author

I don't think it's worth removing brackets from cond: we just recently made it so that the vectors have an implicit do, so you can have multiple statements.

Thus:

(cond
 [(= foo bar) (do-this) (do-that)]
 [(= hue hue) (do-something-else) (do-that-too)])

If we drop the brackets, we lose the ability to do an implicit do. I believe the implicit do is much more useful than dropping the brackets would be.

@gilch
Copy link
Member

gilch commented Aug 19, 2015

We could support both with a variadic if, see #830.

@algernon
Copy link
Member Author

Ping @hylang/core.

This changes let to use a flat list of symbol-value pairs instead of a
vector of vectors. One side effect is that (let [[a 1] z]) is not
expressible now, and one will explicitly need to set a nil value for z,
such as: (let [a 1 z nil]).

Closes #713.

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
This changes with syntax from (with [[x (expr)] (expr)] ...) to (with
[x (expr) (expr)] ...). Should have no ill side effects apart from the
syntax change.

Closes #852.

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
algernon added a commit that referenced this pull request Oct 1, 2015
@algernon algernon merged commit 7904632 into hylang:master Oct 1, 2015
@algernon algernon deleted the glc/DOWN-WITH-THEM-BRACKETS branch October 1, 2015 08:12
@gilch gilch mentioned this pull request Jun 23, 2016
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

Successfully merging this pull request may close these issues.

None yet

4 participants