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

QuoteNodes and Symbol literals #20

Open
fcard opened this issue May 26, 2016 · 1 comment
Open

QuoteNodes and Symbol literals #20

fcard opened this issue May 26, 2016 · 1 comment

Comments

@fcard
Copy link
Owner

fcard commented May 26, 2016

Currently symbol literals in patterns don't really count as literals, but rather as a binding inside a QuoteNode, which could be a gotcha. e.g.

@macromethod m(:sym1) 0
@macromethod m(:sym2) 1

# Intended: Different methods for specific symbols.
@m(:sym1) == 0
@m(:sym2) == 1

# Actual: Both are the same method, so second overwrites first.
@m(:sym1) == 1
@m(:sym2) == 1

# Since
@macromethod mtruth(:x) [x]
@mtruth(:a) == [:a]

# You have to:
@macromethod m1(:L{:sym1}) 0
@macromethod m1(:L{:sym2}) 1

# or:
@macromethod m2(:E{:(:sym1)}) 0
@macromethod m2(:E{:(:sym2)}) 1

@m1(:sym1) == @m2(:sym1) == 0
@m1(:sym2) == @m2(:sym2) == 1

This behaviour may be useful for capturing whole nested expressions (@mtruth(:(x+y)) == [:(x+y)]) and changing it would make it inconsistent with capturing with nested expressions (@letds :(x+y) = :(:(1+2)) (x,y)), but I don't know if these cases are common enough to keep this. Hmm.... Oh well, at least if Julia's 12139 happens this won't be a problem anymore!

I am gonna keep this one around until I do an overall update for Julia 0.5, but if you're a lost soul that somehow came across this and has opinions about it, feel free to share them!

@fcard fcard added this to the 0.5.1 milestone Aug 9, 2016
@fcard
Copy link
Owner Author

fcard commented Sep 25, 2016

Wait, both this and #5 are breaking, aren't they? Then I need to do a major version for them.. Darn it, there goes my plan of syncing the package with the julia version! I thought myself so clever, but in the end hubris has caused my downfall* :(

*I.e. some extra work

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

No branches or pull requests

1 participant