On 2010-01-29 12:56:43 -0500, Andrei Alexandrescu <seewebsiteforem...@erdani.org> said:

Steven Schveighoffer wrote:
On Fri, 29 Jan 2010 12:23:24 -0500, Andrei Alexandrescu <seewebsiteforem...@erdani.org> wrote:
Consider:

struct Stack(T) {
     T pop();
     ...
}

By your definition, pop() should be a property. It doesn't quite strike me as an intuitive decision.

is pop's main purpose to fetch a value or to modify the stack? I'd say the purpose is split equally, so it's not a function whose main purpose is to fetch a value.

So now we're down to proportions, nuance, and where "main" goes. You made my point. I win.

You win because Steven's definition is not good enough. I said before that we should have a authoritative definition. If we really can't define how a property should be defined after some reflection, then you really win.

My definition is that a property gives access to an aspect of an object and doesn't modify it (the getter is essentially logical-const). In this case, 'pop' doesn't give you access to something in the stack, it removes an element (that's an action) and give you the element. It's pretty clear that 'pop' is used as a verb here, that should be enough to decide it's a function.

--
Michel Fortin
michel.for...@michelf.com
http://michelf.com/

Reply via email to