I was thinking about how "push' and 'unshift' stick things onto an
array, while 'pop' and 'shift' pick them off.
So how about a stick/pick pair, together with modifiers :left, :right,
:top, :bottom ?
Hence (my notation is existing code ----> suggested code):
push (@ray,$thing) ------> stick :top (@ray,$thing)
------> stick :right (@ray,$thing)
unshift (@ray,$thing) ---> stick :bottom (@ray,$thing)
---> stick :left (@ray,$thing)
and:
$thing = pop (@ray) -----> $thing = pick :top (@ray)
-----> $thing = pick :right (@ray)
$thing = shift (@ray) ---> $thing = pick :bottom (@ray)
---> $thing = pick :left (@ray)
For arrays, the choice of left/right and top/bottom would be a matter
of taste.
Then maybe we could also have modifiers :in and :out , eg.,
stick :in (@ray,$thing,$at_element_number)
$thing = pick :out (@array,$after_element_number)
or even
@ray = pick :out (@ary,$after_element_number,$n_elements)
These would insert into an array or exerpt from an array
Suppose that there is overloading to a matrix?
stick :left (@@matrix,@ry) could then differ from stick :top
(@@matrix,@ry)
as left/right would stick/pick columns, and top/bottom rows.
How about overloading to a string (visualised as a sequence of
characters/bytes/graphemes)? Then
chop($string) --> pick :right :byte ($string)
but also
$ubstring = substr($tring,$start,$nelems)
--> $ubstring = pick :out ($string,$at_element_number,
$n_elems)
Hope the idea is clear even if the notation is a bit odd.