0

I am interested to know more about the use of the phrase "pop" in relationship to the mark in Emacs. The command pop-global-mark, as I understand it, jumps to the buffer and position of the latest entry in the global ring and also rotates the ring. But why the use of the word "pop" and what exactly is popped?

1 Answer 1

3

global-mark-ring is a list with marker objects. In programming and computer science "popping" something from a list simply means removing the first element of the list (and usually returning the first element).

I.e if you have a list (1 2 3) and call something like (pop '(1 2 3)) the new list would be (2 3).

While I do not know when the term was first used in computer science, the first element of a list is commonly called the "head" (and everything after the "tail"). So what you are doing is "popping the head" of the list.

Edit:

According to Wikipedia (thanks @NickD) it comes from the stack of plates popping up in a cafeteria.

Stacks are often described using the analogy of a spring-loaded stack of plates in a cafeteria. Clean plates are placed on top of the stack, pushing down any already there. When a plate is removed from the stack, the one below it pops up to become the new top plate.

3
  • 4
    The original use was for he data structure called "stack" (a list is just one way to implement a stack). See the WIkipeida article.
    – NickD
    Apr 25, 2021 at 18:15
  • Oh cool, I'll add that to the answer :)
    – Tephra
    Apr 25, 2021 at 18:26
  • 1
    You might also mention the opposite stack operation: push. (For a queue you have opposites enqueue and dequeue.)
    – Drew
    Apr 25, 2021 at 18:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.