<p dir="ltr"><br>
On Jan 21, 2015 6:21 AM, "Matthew Rocklin" <<a href="mailto:mrocklin@gmail.com">mrocklin@gmail.com</a>> wrote:<br>
><br>
> It would be nice to have literal keywords/symbols.  By this I mean, terms that look like words but are not previously defined variables.  <br>
><br>
> Prior art<br>
><br>
> Some other languages prefix by colon, :foo,  or use a backtick,  `foo.<br>
><br>
> julia> :foo<br>
> :foo<br>
> julia> typeof(:foo)<br>
> Symbol<br>
><br>
> user=> :foo<br>
> :foo<br>
> user=> (type :foo)<br>
> clojure.lang.Keyword<br>
><br>
> user=> `foo<br>
> user/foo<br>
> user=> (type `foo)<br>
> clojure.lang.Symbol<br>
><br>
> Why is this useful?<br>
><br>
> One use case in NumPy/Pandas use is to specify columns or fields of data without resorting to strings.  E.g. <br>
><br>
> df = pandas.load(...)<br>
> df.sort(:name)<br>
><br>
> What do people do now?<br>
><br>
> Currently people use auto-generated attributes<br>
><br>
> df.sort(<a href="http://df.name">df.name</a>) <br>
><br>
> or strings<br>
><br>
> df.sort('name')<br>
><br>
> auto-generated attributes work great until you want to use chained expressions<br>
><br>
> df.change_dataframe().sort(some_new_column_not_in_df)<br>
><br>
> strings work but feel unpleasant<br>
><br>
> Prior discussion?<br>
><br>
> This is a common language construct so my guess is that it has come up before.  Sadly Google searching the terms keywords and symbols results it a lot of unrelated material.  Can anyone point me to previous discussion?<br>
><br>
> There are clearly issues with using :foo in that it overlaps with slice syntax, presumably some other character could be pressed into service if this was found worthwhile.<br>
><br>
> I can come up with more motivating use cases if desired.</p>
<p dir="ltr">At best this saves one character, may reduce readability, and would require a huge amount of software to support another code path.  Is there any advantage to this besides the one character saved?</p>