Queue push/pop

Brian Rice water at tunes.org
Wed Jan 4 08:52:07 PST 2006


On Jan 4, 2006, at 3:41 AM, Tony Garnock-Jones wrote:

> (triggered by the changes to the process code to use push/pop  
> instead of
> addLast/removeFirst)
>
> I don't like these names. Push and pop to me mean stack-like, LIFO
> behaviour. Using them to mean FIFO behaviour seems weird.

These are used in standard textbooks for FIFO protocol, and we use  
the polymorphism in TraversalStream to shift between depth-first and  
breadth-first traversals, so I think it's fair to say that we're  
getting a benefit from the polymorphism. Also, LIFO and FIFO are not  
the only possible animals where push:/pop are suitable protocols,  
like Heap's push:/pop which obey a sorting setup.

It's weird, but on the other hand it's tedious to have code that has  
to indicate where first/last interplay in an explicit way. After all,  
it doesn't matter which is first and which is last, only that there  
is FIFO semantics, in the same way that we don't really care that  
Stack is a Sequence whose "active" end is the "last"-word end of it.

We can always add queries to indicate whether something is a LIFO or  
FIFO.

> (Might be interesting to consider adopting the Perl/Python/Javascript
> idiom of push/pop, shift/unshift pairs? Hmm.)

FIFO/LIFO-ism could be a mixin or something over Sequence types. In  
any case, shift/unshift seem to all stem from Awk (after checking  
Knuth and a few other dinosaur textbooks) and do not make sense to me  
as Smalltalk style selectors. Maybe if shift/unshift also swapping  
FIFO/LIFO meaning as push:/pop do...? Even then, shift and unshift  
seem to require a priori knowledge of directionality.

So, basically I'm offering some resistance to the idea unless there's  
additional support aside from that merely derived from awk/perl using  
one array type for everything. I don't think that even a etymology  
relationship between Queue and Deque really justifies much, since in  
a Deque, you really do need to know which end is which, front/last  
and all that.

--
-Brian
http://tunes.org/~water/brice.vcf

-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 186 bytes
Desc: This is a digitally signed message part
Url : /archives/slate/attachments/20060104/1f551de5/PGP.pgp


More information about the Slate mailing list