> Because it is done at compile time, where you can even decide to call > completely different function. See > dequeue = ..... > dequeue[:first] # is replaced with different function than dequeue[1] > dequeue[:last] # is replaced with different function than dequeue[end] ( > O(1) vs O(n) )
I don't see what you mean by compile time. You cannot dispatch on the symbol at compile time. If you use syntax level rewrite, there's no point of using symbol either. > > Because you can define your own syntax. The :middle was just stupid example > to show you, that you can decide on your own symbol based on collection you > are working with ( say there is collection which when accessing middle has > different complexity than accessing other elements). You can easily do this by defining your own token. Misusing the symbol syntax isn't the right way to go. > > Of course you can do arithmetics with this approach. No you can't. Not in a way that you can overload it for different types anyway. >> Which is what make the way you propose unsatisfying. >> > > Are you talking about [ FIRST = :first ]? > If so, I could argue about this since you can't also do [ LAST = end ] > The only difference is that [ LAST = end ] throws error at compile time. The difference is that `end` is a keyword. And symbol literal is not.
