On Thu, May 26, 2016 at 11:31 AM, Ford Ox <[email protected]> wrote: > Lets start from scratch. > > What if this syntax would be possible in Julia: > > collection = [i for i in 1:10] > @show collection[:first] > @show collection[:middle] > @show collection[:last] > @show collection[:first] = -1 > @show collection[:middle] = -1 > @show collection[:my_own_name] = -1
I don't see why it is better than using a keyword like what we have now. Especially because `middle` is confusing and symbol is valid syntax already so it can't be used for compile time computation. >> >> collection[1] = 1 >> collection[5] = 5 >> collection[10] = 10 >> collection[1] = -1 = -1 >> collection[5] = -1 = -1 >> collection[7] = -1 = -1 > > > As you see, it is decided at compile time, at what index of array I access > And you can create special symbols for this smart accessing in julia itself! I don't see why it's useful since we support doing arithmetics on `end` (and I don't see how you can do that (arithmetics) with your approach). > > Fact: It is already possible, but it does not look so nice: > @setindex ( collection[:first] = 5 ) > Fact: You cannot do something like: > FIRST = :first > @setindex ( collection[FIRST] = 5 ) Which is what make the way you propose unsatisfying. > > > >
