octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: What's the meaning of base_properties::has_dynamic_property() ?


From: Michael Goffioul
Subject: Re: What's the meaning of base_properties::has_dynamic_property() ?
Date: Tue, 22 Nov 2011 22:16:16 +0000

On Tue, Nov 22, 2011 at 9:01 PM, John W. Eaton <address@hidden> wrote:
> On 22-Nov-2011, Michael Goffioul wrote:
>
> | Hi (John),
> |
> | I'm wondering what's the meaning of
> | base_properties::has_dynamic_property() method? It only returns true
> | when the name is in base_properties::dynamic_properties member, but
> | that only happens after base_properties::set_dynamic has been called
> | at least once.
> |
> | This means that if you create a dynamic property then happen to call
> | has_dynamic_property(), it will return false. Change the property
> | value (which in fine calls set_dynamic), then it returns true. Is this
> | intentional?
>
> I don't see where has_dynamic_property is ever used.

I don't know. Tracing the log, it seem you added it, that's why I'm asking.
http://hg.savannah.gnu.org/hgweb/octave/rev/1e5c11890f85

> But I think it
> is intended to test whether one exists, regardless of value.

AFAIK, dynamic properties will always have a value. They are added
per-object, not per class of objects. And when they are created,
dynamic properties always have a default value.

> I
> haven't looked closely at this, but how can you create a dynamic
> property without adding it to the list of dynamic properties that is
> used in has_dynamic_property?

Simply by calling addproperty function. This ends up calling
base_properties::insert_property(), which inserts the dynamic property
in all_props member. It's only when you change the value of the
dynamic property, which ends up calling
base_properties::set_dynamic(), that the property is finally added to
dynamic_properties member. But if you don't change the property value
explicitly, it's never added to the dynamic properties used in
has_dynamic_property. Hence my confusion.

I may be wrong, but looking at the code, it seems to me that the
member base_properties::dynamic_properties is actually obsolete. All
(and only) dynamic properties are stored in all_props member.

Michael.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]