It is a good news to hear Jeff's plan :) So far ≀: could be a solution. I found ≀ have a rather high precedence. But...considering that it is not easy to type ≀ in other editor, I may still use ["..."]. Whatever, many thanks for the idea!
On Wednesday, April 1, 2015 at 11:41:47 PM UTC+2, Jiahao Chen wrote: > > You can fake this syntax by using a supported Unicode operator > <https://github.com/JuliaLang/julia/blob/master/src/julia-parser.scm#L17-20>, > e.g. ≀ (which can be typed with \wr<TAB>): > > For example: > > x≀y = x[string(y)] > x=Dict("foo"=>1, "bar"=>2) > x≀:foo+2 #3 > > In this case ≀: would pretend to be the operator you wanted. > > Thanks, > > Jiahao Chen > Staff Research Scientist > MIT Computer Science and Artificial Intelligence Laboratory > > On Wed, Apr 1, 2015 at 5:32 PM, Jerry Xiong <[email protected] > <javascript:>> wrote: > >> I sometimes miss the concise way to fetch the element in a dictionary, >> such as dict$key in R and dict.key in Matlab. In Julia, I have to use >> dict["key"] or dict[:key]. Although they are logically identical, the >> concise way has both typing and visual conveniences. I can regard dict.key1 >> and dict.key2 as two independent variables ( equal to dict_key1 and >> dict_key2) sometimes while regard them as fields of a structure othertimes. >> I tryed to overload macro @~ to do it, so I can use dict~key instead. >> However, the precedence of ~ is not high enough, such as dict~key+1 is >> equal to dict~(key+1) rather than (dict~key)+1. I wonder is there any plan >> to support such concise way of key fetching, or keep a high-precedence >> operator (e.g. dict§key, dict..key, dict!!key ) for custom macro defination >> in the future Julia? >> > >
