79658175

Date: 2025-06-08 21:26:18
Score: 1
Natty:
Report link

Because someone posted a link to this thread somewhere else years later, I feel obligated to correct something (and created my StackOverflow account just for the occasion).

As trolley813 correctly pointed out (though in a very complicated way), every LIFO structure is FILO.

But not every FILO structure is LIFO.

Consider:

Structure holds [first] element and a FIFO [buffer].
There is a helper function for total count.

push [a]:
If total count is 0, write [a] to [first].
Push [a] to [buffer] otherwise.

pop:
If total count is 1, return [first].
Pop from [buffer] otherwise.
(If total count is 0, throw exception or whatever.)

Is the structure FILO?
Yes, The first element is only returned after the buffer has been emptied.

Is the structure LIFO?
Let's see an example.
Pushes: A, B, C
Pops: B, C, A

No, it's not LIFO. It's only LIFO if the buffer is LIFO, too.

FILO is a concept designed by name only. And the name only specifies what happens to the first element and not to any other element as long as that first element is present. The name doesn't imply that it's defined recursively. If [buffer] had to be of the same structure, then yes, it would be LIFO - but that isn't the case. Whereas every LIFO structure is by name alone always a stack.

We should use the established LIFO concept when talking about stacks.
When someone says "FILO", they're probably misspeaking. Or considering esoteric use cases.

Reasons:
  • Blacklisted phrase (1): StackOverflow
  • Long answer (-1):
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • Low reputation (1):
Posted by: Rackergen