[fpc-devel] Bug in trunk?
Michael Van Canneyt
michael at freepascal.org
Fri Mar 28 15:11:38 CET 2008
On Fri, 28 Mar 2008, Mattias Gärtner wrote:
> Zitat von Michael Van Canneyt <michael at freepascal.org>:
>
> >
> >
> > On Fri, 28 Mar 2008, Micha Nelissen wrote:
> >
> > > Michael Van Canneyt wrote:
> > > > It is used in streaming in the classes unit; the streaming mechanism
> > checks
> > > > the actual
> > > > value against this value: if it is the same, the value is not streamed.
> > >
> > > FYI: so before streaming, the "streamer" has to reset the values to their
> > > defaults to stream properly. Unfortenately, there is no function to do
> > this,
> > > and it's usually done in constructor. Therefore streaming twice does not
> > work
> > > properly.
> >
> > This is not correct.
> >
> > The default value is the value at create time and remains fixed during the
> > lifetime of the component. It has no influence on the number of times you
> > stream a component.
>
> Theoretically yes.
> Practically it works this way:
> TWriter writes a value if it differs from the 'default'. The 'default' is
> 1. if there is a stored function, and it returns false, then the current value
> is a default.
> 2. if there is an ancestor, then the current value of the ancestor
> 3. the 'default' constant of the property.
>
> So, it is not always possible to find out if _a_ value is default.
> You can only find out if the _current_ value is default.
Yes, but now you are juggling with terms, and mixing concepts:
- The "default" keyword means the value when the class was created.
Nothing more, nothing less.
As such the current implementation does what it needs to do.
- Stored is a mechanism, separate from default, to determine whether a property
should be stored at all, regardless of the value, be it default or not.
- The ancestor never acts as 'default'. Visual inheritance is a diff
mechanism, nothing else: only the differences between ancestor and
child should be streamed.
The streaming mechanism uses these 3 concepts to minimalize the size of the
stream that it creates. It couldn't care less about resetting the component
or whatever.
If a 'reset to defaults' mechanism is required, then a different set of concepts
must be developed and used.
Michael.
More information about the fpc-devel
mailing list