What are the "historical reasons" for push and pop?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

What are the "historical reasons" for push and pop?

ouverson
Listening to Shimon lecture "VM Abstraction: the Stack".

At the beginning of the lecture, Shimon says, "One of them is called push for historical reasons and this operation allows us to put the plate on the top of the stack and..."

What are the "historical reasons" for push and pop? If someone knows.

Thank you.
Reply | Threaded
Open this post in threaded view
|

Re: What are the "historical reasons" for push and pop?

WBahn
Administrator
The phrase, "for historical reasons," is often used when something just is the way it is and we assume there was some reason for it but it is unclear or unknown what that reason is. It's a form of handwaving to let the audience know that it's okay if the terms themselves don't make obvious sense to them, just use them the way everyone uses them and you'll be fine.

The earliest use of the terms push and pop for a stack operation that I am aware of go back to the early 60's and a Burroughs computer. I've heard it claimed that the terms were inspired by some common toys at the time (and possibly by things like PEZ candy dispensers) where you would push items into one end of the toy and, upon taking some action, the last item pushed in would come popping out.

The commonly used visual example are plate or tray dispensers at a cafeteria since it is assumed that nearly everyone has encountered them on numerous occasions. In this case, the term 'pop' doesn't seem the most appropriate. Terms like 'pull', or 'take' would seem to be more natural.

I tend to treat push/pop as generic terms for adding and removing a value from a data structure, be it a stack, a queue, a heap, or whatever. Others take the position that push/pop should only be used when talking about a stack and that the terms enqueue and dequeue should be used when talking about a queue (FIFO) and yet other terms should be used for other data structures. The intent appears to be that the terms used should indicate what data structure is being used instead of having to make that explicit. Personally, I think this is going overboard and is likely to be driven more by the function/method names used in a particular programming environment, such as Java, that offers these data structures as part of the basic features. I would far prefer to be explicit about the data structure in use and then use a single term for the normal way to add a value to that structure and a single term for the normal way to remove a value from that structure.




Reply | Threaded
Open this post in threaded view
|

Re: What are the "historical reasons" for push and pop?

ouverson
Thank you for taking the time to provide details about data structures and terms.

It is much appreciated.