couple of really noob questions (ranges, toString)
spir
denis.spir at gmail.com
Tue Nov 2 04:16:58 PDT 2010
On Mon, 1 Nov 2010 20:40:30 -0700
Jonathan M Davis <jmdavisProg at gmx.com> wrote:
> The term "pop" does _not_ mean that an element is returned but that it is
> removed from the range. This is true for pretty much anything that uses a pop
> function in any language - stacks, lists, etc. It _is_ true that many
> implementations choose to have pop return the element which is popped, but
> that's an implementation detail. The term pop merely indicates that an element
> is removed from an end of a range or container.
All right, that's where I went wrong. Thank you for the clear explanation. (Now, I will continue with the article by Andrei Alexandrescu, 10 pages left :-)
[But I do not know of any pop not returning the removed value in any lang or library; instead, pop is the favorite example of people arguing against the distinction between actual functions (result, but no effect) and actions (effect, but no result): naughty pop does both.
Maybe call it here remove()? Even if "pop"'s sense was defined by an all-mighty authority, we could hardly avoid people having different expectations born from previous experience, esp when it's so widespread: the two pop examples at http://en.wikipedia.org/wiki/Stack_%28data_structure%29 return the element.]
I would also find current() much clearer than front(), since from the client's perspective it looks like shrinking the collection (or view) instead of traversing it; see the confusion expressed by the OP's original question; but well...
Denis
-- -- -- -- -- -- --
vit esse estrany ☣
spir.wikidot.com
More information about the Digitalmars-d-learn
mailing list