Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / pas2js / 2020-02

Optimization

8 messages · 4 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Unknown author

Hi guys,

is it possible to switch off Optimization with a compiler directive

fa:

{$O-}
procedure TForm1.Button1Click(Sender: TObject);
begin
	WriteLn( 'Click' )
end;
{$O+}

i just want that the optimization process do not remove this function, but i don't want to switch off the whole optimization

thanks in advance
peter

Mattias Gaertner
to Unknown author
Show quoted text 16 lines
Hi guys, is it possible to switch off Optimization with a compiler directive fa: {$O-} procedure TForm1.Button1Click(Sender: TObject); begin WriteLn( 'Click' ) end; {$O+} i just want that the optimization process do not remove this function, but i don't want to switch off the whole optimization
Add somewhere safe:
  if false then Button1Click(nil);

Mattias

Unknown author
to Mattias Gaertner
Add somewhere safe: if false then Button1Click(nil);

thats the way i do it now

-----
procedure TForm1.Button1Click(Sender: TObject);
begin
   if Sender = Nil then
     Exit;
   WriteLn( 'Button1 Clicked' );
end;
-----

but its not very nice to have the same code in every event would be better to have a method to tell the optimization process "do not remove this procedure" with {$O-} and {$O+} or what ever directive

thanks
peter

Show quoted text 5 lines
Mattias _______________________________________________ Pas2js maillist - https://lists.freepascal.org/cgi-bin/mailman/listinfo/pas2js
Ulrich, Christian
to Mattias Gaertner: On Wed, 26 Feb 2020 07:43:45 +0100 Add somewhere safe: if false then Button1Click(nil);…

I would like the swich too, what if the optimizer gets more intelligent some day ? If false... seems not very problematic to detect by an optimizer some day

Earlier message 31 lines
-----Ursprüngliche Nachricht----- Von: Pas2js [mailto:] Im Auftrag von Mattias Gaertner via Pas2js Gesendet: Mittwoch, 26. Februar 2020 09:24 An: Cc: Mattias Gaertner Betreff: Re: [Pas2js] Optimization On Wed, 26 Feb 2020 07:43:45 +0100 wrote: > Hi guys, > > is it possible to switch off Optimization with a compiler directive > > fa: > > {$O-} > procedure TForm1.Button1Click(Sender: TObject); > begin > WriteLn( 'Click' ) > end; > {$O+} > > > i just want that the optimization process do not remove this function, > but i don't want to switch off the whole optimization Add somewhere safe: if false then Button1Click(nil); Mattias
Michael Van Canneyt
to Ulrich, Christian

This cannot be solved by a switch at the place of declaration. It needs a procedure modifier. ; noremove; or so.

For the time being: Put the procedure in a published section of a class. The compiler will not remove it then.

Michael.

Christian wrote 40 lines
I would like the swich too, what if the optimizer gets more intelligent some day ? If false... seems not very problematic to detect by an optimizer some day -----Ursprüngliche Nachricht----- Von: Pas2js [mailto:] Im Auftrag von Mattias Gaertner via Pas2js Gesendet: Mittwoch, 26. Februar 2020 09:24 An: Cc: Mattias Gaertner Betreff: Re: [Pas2js] Optimization On Wed, 26 Feb 2020 07:43:45 +0100 wrote: > Hi guys, > > is it possible to switch off Optimization with a compiler directive > > fa: > > {$O-} > procedure TForm1.Button1Click(Sender: TObject); > begin > WriteLn( 'Click' ) > end; > {$O+} > > > i just want that the optimization process do not remove this function, > but i don't want to switch off the whole optimization Add somewhere safe: if false then Button1Click(nil); Mattias _______________________________________________ Pas2js maillist - https://lists.freepascal.org/cgi-bin/mailman/listinfo/pas2js _______________________________________________ Pas2js maillist - https://lists.freepascal.org/cgi-bin/mailman/listinfo/pas2js
Mattias Gaertner
to Ulrich, Christian: I would like the swich too, what if the optimizer gets more intelligent some day ? If…
Christian" wrote
I would like the swich too, what if the optimizer gets more intelligent some day ? If false... seems not very problematic to detect by an optimizer some day

Switching/controlling that optimization via directives is in my todo list.

Mattias

Show quoted text 38 lines
-----Ursprüngliche Nachricht----- Von: Pas2js [mailto:] Im Auftrag von Mattias Gaertner via Pas2js Gesendet: Mittwoch, 26. Februar 2020 09:24 An: Cc: Mattias Gaertner Betreff: Re: [Pas2js] Optimization On Wed, 26 Feb 2020 07:43:45 +0100 wrote: > Hi guys, > > is it possible to switch off Optimization with a compiler directive > > fa: > > {$O-} > procedure TForm1.Button1Click(Sender: TObject); > begin > WriteLn( 'Click' ) > end; > {$O+} > > > i just want that the optimization process do not remove this > function, but i don't want to switch off the whole optimization Add somewhere safe: if false then Button1Click(nil); Mattias _______________________________________________ Pas2js maillist - https://lists.freepascal.org/cgi-bin/mailman/listinfo/pas2js _______________________________________________ Pas2js maillist - https://lists.freepascal.org/cgi-bin/mailman/listinfo/pas2js
Ulrich, Christian
to Mattias Gaertner

Perfekt, danke.

Earlier message 58 lines
-----Ursprüngliche Nachricht----- Von: Pas2js [mailto:] Im Auftrag von Mattias Gaertner via Pas2js Gesendet: Mittwoch, 26. Februar 2020 10:20 An: Cc: Mattias Gaertner Betreff: Re: [Pas2js] Optimization On Wed, 26 Feb 2020 08:57:45 +0000 "Ulrich, Christian" wrote: > I would like the swich too, what if the optimizer gets more > intelligent some day ? If false... seems not very problematic to > detect by an optimizer some day Switching/controlling that optimization via directives is in my todo list. Mattias > > -----Ursprüngliche Nachricht----- > Von: Pas2js [mailto:] Im Auftrag > von Mattias Gaertner via Pas2js Gesendet: Mittwoch, 26. Februar 2020 > 09:24 An: > Cc: Mattias Gaertner > Betreff: Re: [Pas2js] Optimization > > On Wed, 26 Feb 2020 07:43:45 +0100 > wrote: > > > Hi guys, > > > > is it possible to switch off Optimization with a compiler directive > > > > fa: > > > > {$O-} > > procedure TForm1.Button1Click(Sender: TObject); > > begin > > WriteLn( 'Click' ) > > end; > > {$O+} > > > > > > i just want that the optimization process do not remove this > > function, but i don't want to switch off the whole optimization > > Add somewhere safe: > if false then Button1Click(nil); > > Mattias > _______________________________________________ > Pas2js maillist - > https://lists.freepascal.org/cgi-bin/mailman/listinfo/pas2js > _______________________________________________ > Pas2js maillist - > https://lists.freepascal.org/cgi-bin/mailman/listinfo/pas2js
Unknown author
to Michael Van Canneyt: This cannot be solved by a switch at the place of declaration. It needs a procedure…
For the time being: Put the procedure in a published section of a class. The compiler will not remove it then.

Great Michael
published works perfect

thanks
peter

Show quoted text 53 lines
Michael. On Wed, 26 Feb 2020, Ulrich, Christian wrote: > I would like the swich too, what if the optimizer gets more > intelligent some day ? > If false... seems not very problematic to detect by an optimizer some > day > > -----Ursprüngliche Nachricht----- > Von: Pas2js [mailto:] Im Auftrag > von Mattias Gaertner via Pas2js > Gesendet: Mittwoch, 26. Februar 2020 09:24 > An: > Cc: Mattias Gaertner > Betreff: Re: [Pas2js] Optimization > > On Wed, 26 Feb 2020 07:43:45 +0100 > wrote: > >> Hi guys, >> >> is it possible to switch off Optimization with a compiler directive >> >> fa: >> >> {$O-} >> procedure TForm1.Button1Click(Sender: TObject); >> begin >> WriteLn( 'Click' ) >> end; >> {$O+} >> >> >> i just want that the optimization process do not remove this >> function, >> but i don't want to switch off the whole optimization > > Add somewhere safe: > if false then Button1Click(nil); > > Mattias > _______________________________________________ > Pas2js maillist - > https://lists.freepascal.org/cgi-bin/mailman/listinfo/pas2js > _______________________________________________ > Pas2js maillist - > https://lists.freepascal.org/cgi-bin/mailman/listinfo/pas2js _______________________________________________ Pas2js maillist - https://lists.freepascal.org/cgi-bin/mailman/listinfo/pas2js