Could I for example do something like
popped = pop!(collection, ::Last)
?

Also important question is usefulness of this approach.

Why not just create different method names popfirst, poplast, pop?

In the case of setindex, getindex, setfield etc it is obviously superior 
and irreplaceable.
In any other case it is questionable. My idea is, that function name should 
tell you only what function does ( *verb *) and the rest should be left on 
parameters. But that's just my opinion, so I would like to hear yours.


Yea I agree with you that multiple dispatch can achieve the same thing and 
> much better (such a lovely feature).
>
> But there is a problem - consider:
>
> type Dequeue ... end
> type Last end
> type First end
> getindex(d::Dequeue, ::Last) = last(d)
> getindex(d::Dequeue, ::First) = first(d)
> pop!(d::Dequeue, ::Last) = pop!(d) # removes and returns last element
> pop!(d::Dequeue, ::First) = shift!(d) # removes and returns first element
> pop!(d::Dequeue, index::Int) = splice!(d) # removes and returns element 
> at index x
>
>
>    - My types Last / First can clash with types I have defined elsewhere.
>    - I want to do [ dequeue[Last] ] instead of [ dequeue[Last() ]
>
> How can I go around these ?
>
>

Reply via email to