Re: [sv-ec] How does static lifetime interact with virtual methods?

From: Gordon Vreugdenhil <gordonv_at_.....>
Date: Thu Jun 14 2007 - 12:47:09 PDT
Arturo Salz wrote:
> Gord,
> 
> I don't understand your confusion.

I'm not really confused, just want to clarify the behavior.  I don't
think that this is really worth keeping, but don't feel strongly
about it.

> In your example there are two tasks (C::t and D::t). Each task has an
> "x" argument with static lifetime. Hence:
>  1) There are two "x" arguments: C::t.x and D::t.x.

That is fine.  It is just odd that one call site can target different
statics on each call.  One could just as well argue that the
virtual method is the one that has the static formals and it is
only the body (behavior) that differs.  That would also be a sensible
interpretation.

>  2) C::t.x is the same for all invocations of C::t(likewise for D::t).
>  3) Simultaneous calls to C::t will indeed interfere with the value of
> "x".

Of course - there was no questions about that.

>  4) Calls to C::t and D::t do not interfere with the value of "x".

And that is what I wanted to make sure that we all agreed on.


> As for "this" I do believe that it ought to always be automatic. This
> should be clarified in the LRM, although we can infer that it must be
> the case from the verbiage of the current LRM:
> 	The this keyword denotes a predefined object handle that refers
> to the 	object that was used to invoke the subroutine that this is used
> within.
> If "this" is not automatic - hence, different invocations can interfere
> with the value of "this" - the above statement would be false.



That is why I specifically wanted to clarify that "this" is always
automatic.  It is not in fact obvious that for a blocking task
that quoted statement is true throughout the invocation as opposed
to at the time of invocation.

As long as we are all in agreement, that is fine.  I do think that
we should clarify that "this" is *always* automatic.


> Whether having arguments with static lifetime in a virtual function is a
> sensible thing or not, I don't believe it is sensible - or perhaps even
> useful - but I don't think it's worth writing special rules in the LRM
> tackle this. BTW, a virtual method with no arguments and static lifetime
> is indeed sensible.

Sure - that is just an implicit "static" on each internal data member.
No problem there; it is just that "static" with virtual is a bit more
strange and we at least have already seen user confusion on some of that.

Gord.

-- 
--------------------------------------------------------------------
Gordon Vreugdenhil                                503-685-0808
Model Technology (Mentor Graphics)                gordonv@model.com


-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
Received on Thu Jun 14 12:47:22 2007

This archive was generated by hypermail 2.1.8 : Thu Jun 14 2007 - 12:47:39 PDT