-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
julep: a plan for backticks #12139
Comments
-1 from me. Although I like the proposal, I don't think what we gain here is worth the massive breakage. |
If we're going to change the command syntax, why not have Ref #9945 for the proposed symbol changes. |
I agree with @simonster, |
The cmd shell on Windows doesn't handle single quotes the same way a posix shell does, as one case. |
-1 to |
+1 to this proposal, and the end goal. One thing that would be lost though: it would no longer be possible to nest quasiquotes lexically. But I think the needs of that would be infrequent enough that you could easily work around it. |
This seems like two independent issues.
Previously we had 2 will be a long process with deprecation periods to allow people to migrate to the new solution, so there is no hurry deciding what we will use the syntax for. |
Would triple back-ticks replace |
+1, this seems like a nice improvement. If nothing else I'm not going to be able to unsee the frownyface operator now. @toivoh I don't think we'd necessarily lose that ability. We can already nest strings as e.g. |
@ScottPJones Command interpolation works differently. For instance, assume we had a program |
+1 for the @StefanKarpinski proposals 1 and 3 (backticks become expressions, colons are symbols), and also the @mauro3 suggestion to use triple back-ticks to replace quote/end blocks. Also agree that |
@pao Thanks. That's a rather subtle difference I would think. |
@ScottPJones, please read http://julialang.org/blog/2012/03/shelling-out-sucks/ and http://julialang.org/blog/2013/04/put-this-in-your-pipe/ for more background on why Julia's backticks exist, work the way they do, and are important for calling external programs reliably. I went through it there in a great bit of detail with lots of examples. No point in rehashing that unnecessarily. |
@one-more-minute wrote:
Good point. Since you can parenthesize expressions you could always write |
OK, I did read the second one, that @hayd mentioned, I'll read the other one. Thanks. |
It is not a very strong argument that just because the cmd syntax is not used often in Base, it can just be freely deprecated without too much impact. Of course it is not used in Base, you should make minimal assumptions about your environment if you want to be cross platform. Command syntax is used often in data processing pipelines. It is often faster to call unix functionality through shelling out than to use Julia code to munge your data as the unix utilities are currently much faster. The real deprecation here is not with the cmd syntax but with expression quoting (which is used everywhere). I agree that the backtick is marginally nicer syntax, but is it _that_ much nicer to go through all this code churn? @tbreloff you say that the current syntax is subtle, could you give a concrete example? At the current release rate, this proposal would have us adapting to deprecations and rewriting code for ~2 years. To go through and fix packages is a lot of effort for often little gain. I'm just raising the red flag that we should actually be gaining something tangible from this proposal (other than it is more aesthetically pleasing) before committing to it. |
@ivarne wrote:
Ah, I see you beat me to this proposal. |
@jakebolewski, this is a good point, but I do think that aesthetics matter and this is something that will be in the language forever. I don't really want to live with the frowneyface operator forever, especially when there's this other much nicer syntax so tantalizingly close. |
regarding subtlety... here's a few quick examples which are non-obvious with a quick glance (for non-expert users anyways):
I feel like it would be much clearer to see:
Aesthetics matter a ton. I want to be able to scan code in 1-2 seconds to understand what it's doing.. I don't want to spend my time looking for matching parens and reasoning about what something means in context. This is doubly valuable if I can add logic to my syntax highlighter that clearly identifies expressions in the code. I can't easily do that if symbols and expressions share syntax. |
|
@tbreloff, @one-more-minute wouldn't using explicit |
Possibly, although wrapping things in a redundant |
@jakebolewski yes you can obviously get around these problems, but Julia is still 0.4 (dev)... if there are good solutions to making the language easy to understand/read, we should do it. |
@tbreloff what is the confusion and messiness with Users who are manipulating quoted expressions have entered "sufficiently advanced user territory". We don't even commit to having a stable |
I think there'd be a certain elegance to have (Edited, thanks @toivoh) |
Thinking about the commonalities between quasi-quotation and command line syntax, they're both some sort of executable string with syntax. Perhaps the custom |
+1 to eventually using @mbauman brings up a good point. Maybe the convention going forward is |
No, I still think that's an imprecise analogy - it works the way code inside an interpolation (or existing quoting) works, not the way interpolation inside strings works. Interpolation is its own parsed context within the string. You're proposing making backticks a parsed context, except when prefixed by a formatting macro? Seems maybe useful, but not a dramatic improvement. The funny lowering of custom string literals is already kind of hidden and confusing, now we're going to add another version of it? |
Or to take this another step, if we're going to do this, why not apply the exact same treatment to single quotes while we're at it. I'm sure there's a better use for them than chars, we can just use |
That is quite nice. |
Isn't the point that you could define parsing rules on prefixed backticks? e.g. cmd/cxx/sql. The conventions between parsing and executing are a bit unclear: sql/cxx execute on construction (IIUC), cmd/:( don't and need to be run/eval'd. |
Yes, there's a bit of a distinction to be made between constructs that construct code versus evaluate code. It might be worth making it more uniform, but it's unclear why one would want to construct but not evaluated SQL or C++ code objects. |
If we really are going to change the syntax, I think we should start deprecation process in this release so that at least we can write non-deprecated code going forward in the 0.5 release cycle. |
This the chance to get infix operators. That's the only nice way to achieve custom infix operators that I'm aware of, and if we decide to use this syntax for quasi-quotation we will never get that. |
I don't see why backticks are a desirable choice for infix operator syntax. |
Because they are a minimal piece of syntax that we can put surrounding a custom operator: Unless we can define a symbol to be an infix operator without surrounding it with syntax, say:
|
Can we not worry about infix operators when we're getting close to a release and need to get things moving sooner rather than later? |
Got it |
I've never liked backticks for infix operators, so I'm not too worried about that. |
Yeah, I used to think having generalized infix operators was super important, but over time, it's become less and less important IMO. I think the natural Julia style with multiple dispatch generalizes to more than just two arguments, so infix suddenly isn't as important. Using backticks for quoting code is much more natural. |
|
Back on topic, I think the order of Stefan's checklist is right. We first need to allow and implement `foo```. How we do that is still in discussion (line numbers? conventions for construction vs execution?) and a bit of work. I'm not sure it's worth delaying 0.4 more for this. |
Leaving huge breaking syntax changes up in the air doesn't really help anyone. If this is going to change it should happen sooner rather than later. |
I personally feel that we should put this on the backburner for now, and discuss earlier in the 0.5 cycle. |
I agree with @ViralBShah ; at this point I don't want a single additional thing to worry about for 0.4. The "do it sooner rather than later" argument has merit, but can only go so far. Otherwise as soon as somebody raises a breaking syntax idea, we have to delay whatever release we're working on until it's settled. It's sort of a breaking-change-filibuster. I like backticks for code quoting, but I'm worried about the nesting behavior. It vaguely reminds me of the syntax of prefix |
While I'm still in favor of this, I agree that jumping into it too fast is a bad idea. This is post 0.4. |
I think I'm in the vast minority here, but I actually prefer the frowny face operator; having I also think that the triple backticks for block syntax is much less clear than I agree with Jake that it's a lot of ecosystem-wide breakage for, in my very humble opinion, marginal benefit. |
I was (perhaps unnecessarily) a bit worried about how nesting expressions will work nicely, which is the nice thing about having them surrounded by brackets. Here's just an idea:
with triple backticks being more like the latter, I suppose? Having |
I don't think we're going to do this. The problem with backticks in place of |
It has not infrequently seemed a shame to me that Markdown has trained us all to quote code by wrapping it in backticks.
a + b
is how we want to write the quoted expressiona + b
. That's considerably nicer than:(a + b)
– the frownieface operator is just kind of weird – and it has some syntactic issues since the parens are actually part of the expression being quoted, not the quotation syntax; this has tripped quite a few people up.Currently, backticks are used for quoting external commands using a convenient shell-like syntax. You don't want to use single or double quotes for this since it's quite common to want to use those quote characters in command expressions. But there's one bit of syntax we haven't exploited yet: backtick custom-literal strings. (This option only just occurred to me the other week.) So I would propose the following syntaxes:
a + b + $ex
. The dollar sign splices expressions into the quoted code as it does inside of:(...)
currently.cmd
-prefixed backticks to write commands:pipe(cmd
find -name *.$ext, cmd
head -n$n)
. The dollar sign splices values into commands as it does into backticks currently.:foo
forsymbol("foo")
,:"foo bar"
forsymbol("foo bar")
or:123
forsymbol("123")
.Using backticks for quasiquoting has the advantage that it's what lisp does. Getting to this point without breaking everything will require a substantial deprecation process:
foo
...`` – and allow people to use those for a while.cmd
find -name *.$ext`` as a syntax for external commands.a + b
to meaning quasiquotation – this breaks code using...
for commands.:(a + b)
as quasiquotation.:(a + b)
for quasiquotation, enable:"foo bar"
for non-identifier symbols.That's a long process, but I think it's a better use of backticks. It has the advantages of matching how we write quoted code in Markdown and most Lisps use backtick for quasiquotation – in Lisp style just at the front, of course, but still, I think it will be more familiar to Lispers.
The text was updated successfully, but these errors were encountered: