-
-
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
:" " syntax for non-standard quoted symbols? #9945
Comments
The reason we made the choice to use symbols instead of strings in DataFrames was to discourage non-standard column names. It would be much better to reverse that decision than to redefine backticks in Base Julia. |
I also try to avoid non-standard column names whenever possible, but sometimes it's just much more straightforward to use the original data format. Do you propose to use something like |
There is a lot to be said for using |
@alyst I think |
@nalimilan I am also the strong proponent of "column names must be valid identifiers" policy, but in certain cases (data is imported and the input format is fixed; column names encode metadata; porting existing R scripts to Julia etc) it would just be convenient to use non-standard ones instead of fixing the data and the scripts to comply with the policy. |
My personal sense is that Julia does support an easy way already: My sense about this issue is that we should have part of the discussion in DataFrames. |
I'm very much in agreement with what @johnmyleswhite said. It's a minor cognitive load commensurate to the reminder that one cannot use that symbol as if it's a field or a variable. I like So, |
If we changed the commands for something like |
I would propose making Using If we were going to use backticks for anything else, I would consider expression quoting since that is how we quote expressions is markdown and emails anyway. |
@StefanKarpinski +1 for |
Hang on. what does |
@tonyhffong Recent 0.4-devel gives |
I think we'd have to keep parsing |
Conceptually, we have now :( a ) == :a # A quote of a variable equals to that variable's symbol.
:"a b" == :( "a b" ) == "a b" # in both 0.3 and 0.4-dev. A quote of a string literal is just that string literal. which kind of makes sense to me. Maybe it's a hobgoblin of little minds, but I do think it's nice that way. |
It's consistent, but the former is useful while the latter is useless. |
Late to the party here, but I really wouldn't feel comfortable with punning the quoting |
+1 also for |
While implementing #32408 I noticed the notation If we made |
At the moment to generate non-standard symbols in Julia (e.g. with whitespace), one has to write
symbol("a b")
. R uses backtick quotes for similar purposes, and that is much more concise. The typical use case is to refer to a dataframe column with non-standard characters in its name (e.g. imported from CSV/XLS file).It would be nice to use backticks to quote symbols in Julia as well, but backticks are currently reserved for command interpolation. What if, instead of backticks, commands would be specified as
sh"<cmd>"
orcmd"<cmd>"
, and backticks would be granted to symbols (given it's a more generic and frequent use case)?The use of backticks for commands was inspired by Unix shell, but, in fact, it's a little bit misleading as backquoting a command in Julia doesn't execute it, as in shell.
sh"<cmd>"
alternative could be naturally extended to the other external scripts, e.gperl"..."
,lua"..."
etc.The text was updated successfully, but these errors were encountered: