-
Notifications
You must be signed in to change notification settings - Fork 373
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
Add #[DELIM[ … ]DELIM] syntax for string literals #1379
Conversation
f6ccbf9
to
d2032ab
Compare
d2032ab
to
f2b45ef
Compare
@gilch @kirbyfan64 Is there any reason you guys aren't reviewing this? I thought we settled on the Lua style. |
I thought we did, or I did, at least. There are competing priorities, that's all. I can make this a priority since you think it's important. This can come later, but we'll want to at least update hy-mode for the new syntax, and vim-hy too, but no-one seems to be maintaining that. Since hy-mode isn't settled even for what we've got so far, I've been de-prioritizing syntax changes that would break it compared to other things. But even before then, both emacs and vim should mostly highlight properly if Hy files if we pick |
My own philosophy is that I should try to review PRs (that are ready for review, to my knowledge) before anything else (like writing issues, working on my own PRs, etc.), because PR reviewing seems to be the primary bottleneck for Hy development. |
=> (. '#[foo[bar]foo] hashstring_delim)
from hy import HyString
HyString('bar').hashstring_delim
Traceback (most recent call last):
File "c:\users\me\documents\github\hylang-hy\hy\importer.py", line 201, in hy_eval
return eval(ast_compile(expr, "<eval>", "eval"), namespace)
File "<eval>", line 1, in <module>
AttributeError: 'HyString' object has no attribute 'hashstring_delim' I can't seem to access the delimiter from the model. Is the compiler stripping it out somewhere? |
Looks like the macros can get to it though. => (defmacro foo [s] (. s hashstring_delim))
import hy
hy.macros.macro('foo')((lambda s: s.hashstring_delim))
<function <lambda> at 0x000001BDD82476A8>
=> (foo #[x[]x])
'x'
'x' |
I think what you're seeing in the first example is a limitation in how quoting works. The generated code is |
I think |
f2b45ef
to
7e416d3
Compare
Done. |
Tested too, that looks good. Seeing those Now that the delimiter is a keyword argument, I think I should put it in the HyString repr in #1360, at least when it doesn't have the default value of We also need news and docs, which should also specify that some number of |
Agreed on both counts.
It doesn't make a difference to me.
Will do.
I disagree. I don't want to count |
I don't want to count more than three, but how often does that come up?
OK, I guess.
I didn't have a particular alternative in mind, but I guess @kirbyfan64, anything else you'd like to add? Do you have a preference for the HyString reprs? |
Done. |
@gilch This good? I wasn't sure whether you wanted me to change |
Go ahead and change it to |
d2a4e89
to
ba7724b
Compare
@gilch Done. |
hy/compiler.py
Outdated
l = [HySymbol(name), form] | ||
if form.brackets is not None: | ||
l.extend([HyKeyword(":brackets"), form.brackets]) | ||
return imports, HyExpression(l).replace(form), False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is minor, but I'd prefer to avoid single-character names that can be confused with other characters in Python, like lI1
or 0O
. These are distinguishable in a good programmer font, but you might have to squint. This is the kind of thing flake8 should be able to catch.
The implementation seems good now. I don't like the name "hashstring" it makes it sound like it has something to do with hash functions, but it doesn't. It's just from the |
"Bracket string" seems as good as anything. I will likely get around to the mild inconvenience of editing this tomorrow. |
ba7724b
to
0c229eb
Compare
Both changes made. |
Glad to see this finally getting in! |
Bracket string literals are now fully supported in |
To do: