[Lazarus] Event with changed signature can be loaded without error

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

[Lazarus] Event with changed signature can be loaded without error

Free Pascal - Lazarus mailing list
I don't know: is this changed or am I fooled by my memory? I was rather
sure that when the signature of a published event is changed, forms
saved with the old signature cannot be read without error. But now I
notice that this is not true any more.

The version of TAChart which I just committed to trunk had to change the
signature of the TChartDataPointDrawEvent event from

    procedure (ASender: TDataPointDrawTool) of object;

to

  procedure (ASender: TDataPointDrawTool;  ADrawer: IChartDrawer) of object;

Testing this with the demo in folder
(lazarus)/components/tachart/demo/tools in which the event is handled I
was expecting an error - but no, the program compiles and runs fine as
if nothing had changed.

Am I missing something?

--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Event with changed signature can be loaded without error

Free Pascal - Lazarus mailing list
On Fri, 12 Apr 2019 19:35:03 +0200
Werner Pamler via lazarus <[hidden email]> wrote:

> I don't know: is this changed or am I fooled by my memory? I was
> rather sure that when the signature of a published event is changed,
> forms saved with the old signature cannot be read without error. But
> now I notice that this is not true any more.

Loading a form only checks the name, not the signature.

 

> The version of TAChart which I just committed to trunk had to change
> the signature of the TChartDataPointDrawEvent event from
>
>     procedure (ASender: TDataPointDrawTool) of object;
>
> to
>
>   procedure (ASender: TDataPointDrawTool;  ADrawer: IChartDrawer) of
> object;
>
> Testing this with the demo in folder
> (lazarus)/components/tachart/demo/tools in which the event is handled
> I was expecting an error - but no, the program compiles and runs fine
> as if nothing had changed.
>
> Am I missing something?

You were just lucky.

Mattias

--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Event with changed signature can be loaded without error

Free Pascal - Lazarus mailing list
In reply to this post by Free Pascal - Lazarus mailing list
On 12.04.2019 19:35, Werner Pamler via lazarus wrote:
> I don't know: is this changed or am I fooled by my memory? I was
> rather sure that when the signature of a published event is changed,
> forms saved with the old signature cannot be read without error. But
> now I notice that this is not true any more.

AFAIR it has always been so. Didn't you mix up with virtual methods?


> The version of TAChart which I just committed to trunk had to change
> the signature of the TChartDataPointDrawEvent event from
>
>    procedure (ASender: TDataPointDrawTool) of object;
>
> to
>
>  procedure (ASender: TDataPointDrawTool;  ADrawer: IChartDrawer) of
> object;


You must never change the signature of published events. You pick up a
new name, deprecate the old one and after a stable release you delete
the deprecated one. In this way you still break compatibility, but in a
way that the user is notified about it.

I hope you will have more understanding for breaking changes in the
future after this experience :)

Ondrej

--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Event with changed signature can be loaded without error

Free Pascal - Lazarus mailing list
Am 12.04.2019 um 20:23 schrieb Ondrej Pokorny via lazarus:
> On 12.04.2019 19:35, Werner Pamler via lazarus wrote:
>> I don't know: is this changed or am I fooled by my memory? I was
>> rather sure that when the signature of a published event is changed,
>> forms saved with the old signature cannot be read without error. But
>> now I notice that this is not true any more.
>
> AFAIR it has always been so. Didn't you mix up with virtual methods?

I mixed up loading and and toggling between form and code view, and my
memory refers to Delphi. I just tested it again: After loading a D7
project with a VirtualTreeView into Delphi XE2 and pressing F12 to
toggle to Form view I get the error "Method ... to which
VirtualStringTree1.OnGetText refers has an incompatible parameter list"
because the D7 event signature contains a widestring parameter, but the
XE2 event contains a normal string parameter. - When i load the
toolsdemo mentioned in the first message into Lazarus and press F12
nothing happens although the parameter list is different. Strange.


> You must never change the signature of published events. You pick up a
> new name, deprecate the old one and after a stable release you delete
> the deprecated one. In this way you still break compatibility, but in
> a way that the user is notified about it.
>
> I hope you will have more understanding for breaking changes in the
> future after this experience :)

Don't worry, it will be changed shorty, but I wanted to have an example
which every interested reader could test easily without having to
install anything.
--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Event with changed signature can be loaded without error

Free Pascal - Lazarus mailing list
In reply to this post by Free Pascal - Lazarus mailing list
On Fri, Apr 12, 2019 at 7:38 PM Werner Pamler via lazarus
<[hidden email]> wrote:

> I don't know: is this changed or am I fooled by my memory? I was rather
> sure that when the signature of a published event is changed, forms
> saved with the old signature cannot be read without error. But now I
> notice that this is not true any more.

Memory serves you wrong.
See https://bugs.freepascal.org/view.php?id=23032

--
Bart
--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Event with changed signature can be loaded without error

Free Pascal - Lazarus mailing list
In reply to this post by Free Pascal - Lazarus mailing list
On 12.04.2019 22:29, Werner Pamler via lazarus wrote:
> Am 12.04.2019 um 20:23 schrieb Ondrej Pokorny via lazarus:
>> I hope you will have more understanding for breaking changes in the
>> future after this experience :)
>
> Don't worry, it will be changed shorty, but I wanted to have an
> example which every interested reader could test easily without having
> to install anything.

No problem with that. I know that sometimes it is necessary to change
the parameters of e.g. a virtual method even if it means that libraries
supporting several Lazarus versions have to use IFDEFs for the
overrides. I do understand it.

Ondrej

--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus