Re: [fpc-pascal] with statement using mulltiple objects

2014-09-17 Thread Frederic Da Vitoria
2014-09-17 3:11 GMT+02:00 Flávio Etrusco flavio.etru...@gmail.com: On Tue, Sep 16, 2014 at 8:09 PM, Philippe phili...@quarta.com.br wrote: on compiler implementation: I read in this list that the group lost months due a with problem. People use with, and I guess lot of people use it!

Re: [fpc-pascal] with statement using mulltiple objects

2014-09-17 Thread Flávio Etrusco
On Wed, Sep 17, 2014 at 4:38 AM, Frederic Da Vitoria davito...@gmail.com wrote: 2014-09-17 3:11 GMT+02:00 Flávio Etrusco flavio.etru...@gmail.com: On Tue, Sep 16, 2014 at 8:09 PM, Philippe phili...@quarta.com.br wrote: on compiler implementation: I read in this list that the group lost

Re: [fpc-pascal] with statement using mulltiple objects

2014-09-16 Thread Frederic Da Vitoria
2014-09-14 16:23 GMT+02:00 Mark Morgan Lloyd markmll.fpc-pas...@telemetry.co.uk: I'd be far happier if there were provision for declaring a temporary shortcut symbol: with shortcut: TSomething= TreeRoot.SubDirs[Low(TreeRoot.SubDirs)]^ do begin shortcut.DirLogged := true;

Re: [fpc-pascal] with statement using mulltiple objects

2014-09-16 Thread Philippe
could the compiler avoid with pitfalls? now the compiler attach a property to the closest with where it finds it. the compiler could check if the property appears in another with of the with stack and produce a message (hint, warning or error, which may be configurated). is not it a way

Re: [fpc-pascal] with statement using mulltiple objects

2014-09-16 Thread Frederic Da Vitoria
2014-09-16 12:26 GMT+02:00 Philippe phili...@quarta.com.br: Em 16.09.2014 05:44, Frederic Da Vitoria escreveu: 2014-09-14 16:23 GMT+02:00 Mark Morgan Lloyd markmll.fpc-pas...@telemetry.co.uk: I'd be far happier if there were provision for declaring a temporary shortcut symbol: with

Re: [fpc-pascal] with statement using mulltiple objects

2014-09-16 Thread Mattias Gaertner
On Tue, 16 Sep 2014 07:26:24 -0300 Philippe phili...@quarta.com.br wrote: could the compiler avoid with pitfalls? now the compiler attach a property to the closest with where it finds it. the compiler could check if the property appears in another with of the with stack and

Re: [fpc-pascal] with statement using mulltiple objects

2014-09-16 Thread Frederic Da Vitoria
2014-09-16 12:36 GMT+02:00 Frederic Da Vitoria davito...@gmail.com: 2014-09-16 12:26 GMT+02:00 Philippe phili...@quarta.com.br: Em 16.09.2014 05:44, Frederic Da Vitoria escreveu: 2014-09-14 16:23 GMT+02:00 Mark Morgan Lloyd markmll.fpc-pas...@telemetry.co.uk: I'd be far happier if

Re: [fpc-pascal] with statement using mulltiple objects

2014-09-16 Thread Giuliano Colla
Il 16/09/2014 12:26, Philippe ha scritto: could the compiler avoid with pitfalls? The with construct can be very handy, but should be used with caution, like a lot of other constructs, declarations, etc. E.g. for symbols present with the same name in different units, depending on the

Re: [fpc-pascal] with statement using mulltiple objects

2014-09-16 Thread Sven Barth
Am 16.09.2014 12:37 schrieb Mattias Gaertner nc-gaert...@netcologne.de: On Tue, 16 Sep 2014 07:26:24 -0300 Philippe phili...@quarta.com.br wrote: could the compiler avoid with pitfalls? now the compiler attach a property to the closest with where it finds it. the compiler could

Re: [fpc-pascal] with statement using mulltiple objects

2014-09-16 Thread Frederic Da Vitoria
2014-09-16 14:42 GMT+02:00 Sven Barth pascaldra...@googlemail.com: Am 16.09.2014 12:37 schrieb Mattias Gaertner nc-gaert...@netcologne.de : On Tue, 16 Sep 2014 07:26:24 -0300 Philippe phili...@quarta.com.br wrote: could the compiler avoid with pitfalls? now the compiler

Re: [fpc-pascal] with statement using mulltiple objects

2014-09-16 Thread Philippe
I imagine that who really want to get rid from the hint ... don´t use Pascal anyway! or do have strong test tools!!! one point is that (many?) people use with ... and compiler can make it safer. may be as described Frederic Da Vitoria ... producing error when may be confused. (but let

Re: [fpc-pascal] with statement using mulltiple objects

2014-09-16 Thread Ewald
On 09/16/2014 03:41 PM, Philippe wrote: I imagine that who really want to get rid from the hint ... don´t use Pascal anyway! or do have strong test tools!!! one point is that (many?) people use with ... and compiler can make it safer. may be as described Frederic Da Vitoria ... producing

Re: [fpc-pascal] with statement using mulltiple objects

2014-09-16 Thread Flávio Etrusco
On Mon, Sep 15, 2014 at 2:55 AM, Sven Barth pascaldra...@googlemail.com wrote: On 14.09.2014 18:05, Philippe wrote: Take this example: === code begin === (...) procedure TestWith; var p: PTest; begin New(p); with p^ do begin Prop1 := 42; Prop2 := 21; end;

Re: [fpc-pascal] with statement using mulltiple objects

2014-09-16 Thread Philippe
on compiler implementation: I read in this list that the group lost months due a with problem. People use with, and I guess lot of people use it! I checked the reference http://www.freepascal.org/docs-html/ref/refsu58.html#x155-16500013.2.8 and there is not any warning ... just: The

Re: [fpc-pascal] with statement using mulltiple objects

2014-09-16 Thread Flávio Etrusco
On Tue, Sep 16, 2014 at 8:09 PM, Philippe phili...@quarta.com.br wrote: on compiler implementation: I read in this list that the group lost months due a with problem. People use with, and I guess lot of people use it! I checked the reference

Re: [fpc-pascal] with statement using mulltiple objects

2014-09-15 Thread Martin Schreiber
On Monday 15 September 2014 07:55:20 Sven Barth wrote: As you can see the expression p^ is only evaluated once in the TestWith case while it's evaluated twice in the TestWithout one. So it's only minimally faster in this example (one less memory access), but if you use enough members of TTest

Re: [fpc-pascal] with statement using mulltiple objects

2014-09-15 Thread Tomas Hajny
On Mon, September 15, 2014 07:55, Sven Barth wrote: On 14.09.2014 18:05, Philippe wrote: someone wrote about a better performance using with. is that true? even with a simple pointer as in: . . This is the relevant code generated for TestWith: === asm begin === # [28] with p^ do begin

Re: [fpc-pascal] with statement using mulltiple objects

2014-09-15 Thread Graeme Geldenhuys
On 2014-09-14 11:49, Sven Barth wrote: Though to be honest Lazarus handles with-statements in context of debugging much more gracefully than Delphi... We all know Lazarus is way better that Delphi - so that's always good to know. :) As already mentioned, human refactoring of WITH statements

Re: [fpc-pascal] with statement using mulltiple objects

2014-09-15 Thread Graeme Geldenhuys
On 2014-09-14 15:41, Vojtěch Čihák wrote: because Editor is also public property of TStringGrid. Here would be solution to rename parameter to AEditor. Yes, that is a classic issue I have often come across. Regards, - Graeme - -- fpGUI Toolkit - a cross-platform GUI toolkit using Free

Re: [fpc-pascal] with statement using mulltiple objects

2014-09-15 Thread Graeme Geldenhuys
On 2014-09-14 13:30, Marco van de Voort wrote: WITH doesn't, and you risk that if your class or one of its ancestor has such property, and your error goes unnoticed. +1 Not to mention that you can't use tooltip debugging when it comes to the WITH statement - at least this was the case last

Re: [fpc-pascal] with statement using mulltiple objects

2014-09-15 Thread Mark Morgan Lloyd
Graeme Geldenhuys wrote: As already mentioned, human refactoring of WITH statements can, and has, caused lots of debugging issues afterwards. If Dijkstra had written a letter to the CACM cautioning against the With statement, I wonder whether Wirth would have headlined it With Statement

Re: [fpc-pascal] with statement using mulltiple objects

2014-09-15 Thread Mark Morgan Lloyd
Bernd Oppolzer wrote: PL/1 was designed in the mid 60s, and Wirth of course knew about PL/1, because he was at IBM at the time, and of course he was aware of the problems and pitfalls of PL/1. I didn't know that Wirth had been directly associated with IBM. I did know that while at Stanford

Re: [fpc-pascal] with statement using mulltiple objects

2014-09-15 Thread Sven Barth
Am 15.09.2014 09:08 schrieb Graeme Geldenhuys mailingli...@geldenhuys.co.uk: On 2014-09-14 13:30, Marco van de Voort wrote: WITH doesn't, and you risk that if your class or one of its ancestor has such property, and your error goes unnoticed. +1 Not to mention that you can't use tooltip

Re: [fpc-pascal] with statement using mulltiple objects

2014-09-15 Thread johanns
On Sun, Sep 14, 2014 at 02:30:01PM +0200, Marco van de Voort wrote: In our previous episode, J?rgen Hestermann said: - d:=TreeRoot.SubDirs[Low(TreeRoot.SubDirs)]; // local var d d^.DirLogged := true; d^.DirHatFocus

Re: [fpc-pascal] with statement using mulltiple objects

2014-09-15 Thread vfclists .
On 13 September 2014 20:29, vfclists . vfcli...@gmail.com wrote: On 13 September 2014 20:02, Sven Barth pascaldra...@googlemail.com wrote: On 13.09.2014 20:13, vfclists . wrote: According to the docs the with statement when used with mulltiple objects only works with the last parameter.

Re: [fpc-pascal] with statement using mulltiple objects

2014-09-14 Thread Graeme Geldenhuys
On 2014-09-13 21:04, Mattias Gaertner wrote: What is the rationale for such a statement, ie using multliple elements? Less typing. ...and increases grey hair growth (due to lots more trouble debugging). :-) Regards, - Graeme - -- fpGUI Toolkit - a cross-platform GUI toolkit using Free

Re: [fpc-pascal] with statement using mulltiple objects

2014-09-14 Thread Graeme Geldenhuys
On 2014-09-13 21:31, Marius wrote: programmers know that and try to avoid the with statement. +1 Regards, - Graeme - ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] with statement using mulltiple objects

2014-09-14 Thread Jürgen Hestermann
Am 2014-09-13 22:31, schrieb Marius: Mattias Gaertner wrote: All seasoned programmers know that and try to avoid the with statement. Realy? I love it. Consider these two varianst of code from one of my programs: - with

Re: [fpc-pascal] with statement using mulltiple objects

2014-09-14 Thread Mattias Gaertner
On Sun, 14 Sep 2014 11:58:22 +0200 Jürgen Hestermann juergen.hesterm...@gmx.de wrote: Am 2014-09-13 22:31, schrieb Marius: Mattias Gaertner wrote: All seasoned programmers know that and try to avoid the with statement. The quote is from Marius, not from me. Realy? I love it. Consider

Re: [fpc-pascal] with statement using mulltiple objects

2014-09-14 Thread Jürgen Hestermann
Am 2014-09-14 12:08, schrieb Mattias Gaertner: All seasoned programmers know that and try to avoid the with statement. The quote is from Marius, not from me. Correct. I deleted the wrong reference. ;-( Realy? I love it. Consider these two varianst of code from one of my programs:

Re: [fpc-pascal] with statement using mulltiple objects

2014-09-14 Thread Sven Barth
Am 14.09.2014 09:36 schrieb Graeme Geldenhuys mailingli...@geldenhuys.co.uk: On 2014-09-13 21:04, Mattias Gaertner wrote: What is the rationale for such a statement, ie using multliple elements? Less typing. ...and increases grey hair growth (due to lots more trouble debugging). :-)

Re: [fpc-pascal] with statement using mulltiple objects

2014-09-14 Thread Marius
Jürgen Hestermann wrote: Realy? I love it. Consider these two varianst of code from one of my programs: This is a simpler example than the one with with the 4 levels deep (which can be quite a puzzle if there are multiple records containing the same fieldname(s)). And yes you may love them but

Re: [fpc-pascal] with statement using mulltiple objects

2014-09-14 Thread Marius
Jürgen Hestermann wrote: Do you also prepent all function and variable names with the unit name they come from? Do you realy always write LazUTF8.UTF8Delete instead of UTF8Delete ? Nested WITH statements and the unit concept share the same problem but still the benefits outweigh the drawbacks

Re: [fpc-pascal] with statement using mulltiple objects

2014-09-14 Thread Marco van de Voort
In our previous episode, J?rgen Hestermann said: - d:=TreeRoot.SubDirs[Low(TreeRoot.SubDirs)]; // local var d d^.DirLogged := true; d^.DirHatFocus := false; d^.SubDirsExpanded := true; [...]

Re: [fpc-pascal] with statement using mulltiple objects

2014-09-14 Thread Philippe
-1. !!! I like with ... even it may give trouble times to times!!! ... but I work alone on my programs ... as always ... nothing perfect! always should consider the conditions!! Em 14.09.2014 09:30, Michael Thompson escreveu: We have spend weeks (if not months) off hunting

Re: [fpc-pascal] with statement using mulltiple objects

2014-09-14 Thread Ched
Hello All, My two cents. The with statement is crystal clear for me. If newbies prefer to use different manners to code the things, that are free to do it. Using some kind of intermediate variable ? That's make to code difficult to understand, need do open begin/end blocks in some situations.

Re: [fpc-pascal] with statement using mulltiple objects

2014-09-14 Thread Mark Morgan Lloyd
Ched wrote: Hello All, My two cents. The with statement is crystal clear for me. If newbies prefer to use different manners to code the things, that are free to do it. Using some kind of intermediate variable ? That's make to code difficult to understand, need do open begin/end blocks in

Re: [fpc-pascal] with statement using mulltiple objects

2014-09-14 Thread Marco van de Voort
In our previous episode, Ched said: So, they with statement has at least one aficionados: me. Was the with statement present if the first versions designed by Wirth himself ? Yes, but the problems are mostly because of the scoping complexity that OO extensions like classes add. Specially

Re: [fpc-pascal] with statement using mulltiple objects

2014-09-14 Thread Bernd Oppolzer
Am 14.09.2014 15:39, schrieb Ched: Hello All, My two cents. The with statement is crystal clear for me. If newbies prefer to use different manners to code the things, that are free to do it. Using some kind of intermediate variable ? That's make to code difficult to understand, need do open

Re: [fpc-pascal] with statement using mulltiple objects

2014-09-14 Thread Vojtěch Čihák
Hi,   once I came to troubles with with:   procedure TForm1.StringGrid1SelectEditor(Sender: TObject; aCol, aRow: Integer; var Editor: TWinControl); begin   with StringGrid1 do     begin       ...       Editor:= ...;       ...     end; end;  because Editor is also public property of TStringGrid.

Re: [fpc-pascal] with statement using mulltiple objects

2014-09-14 Thread Bernd Oppolzer
The reason why I made these comparisons to PL/1: PL/1 was designed in the mid 60s, and Wirth of course knew about PL/1, because he was at IBM at the time, and of course he was aware of the problems and pitfalls of PL/1. By including the WITH statement into PASCAL, he probably wanted to give

Re: [fpc-pascal] with statement using mulltiple objects

2014-09-14 Thread Martin Schreiber
On Sunday 14 September 2014 16:34:06 Marco van de Voort wrote: In the past I had the same opinion about with (WITHs evilness is exaggerated) as many others, but once I bumped my head a few times while using OO frameworks that were either not of my design or very large, I basically stopped

Re: [fpc-pascal] with statement using mulltiple objects

2014-09-14 Thread Marco van de Voort
In our previous episode, Martin Schreiber said: basically stopped using it. Why does Free Pascal not invent a safe with similar as the with of MSElang? The primary question is of course if there is a need for a new construct at all. I don't know MSELang, but many new languages try to add

Re: [fpc-pascal] with statement using mulltiple objects

2014-09-14 Thread Philippe
main problem seems to be using property whose name is common within 2 objects of the same with (or code within several with) could it be controlled by a compiler option? in that case compiler may return a hint or warning or even an error depending of the choosen configuration ... does

Re: [fpc-pascal] with statement using mulltiple objects

2014-09-14 Thread Luca Olivetti
El 14/09/14 17:20, Marco van de Voort ha escrit: In our previous episode, Martin Schreiber said: basically stopped using it. Why does Free Pascal not invent a safe with similar as the with of MSElang? The primary question is of course if there is a need for a new construct at all. I

Re: [fpc-pascal] with statement using mulltiple objects

2014-09-14 Thread Philippe
someone wrote about a better performance using with. is that true? even with a simple pointer as in: with ptr^ do begin prop1 := ... prop2 := ... end; which should be faster then ptr^.prop1 := ... ptr^.prop1 := ... others wrote it is just usefull to save writing time ... Em

Re: [fpc-pascal] with statement using mulltiple objects

2014-09-14 Thread Luca Olivetti
El 14/09/14 12:22, Jürgen Hestermann ha escrit: - d:=TreeRoot.SubDirs[Low(TreeRoot.SubDirs)]; // local var d d^.DirLogged := true; d^.DirHatFocus := false; d^.SubDirsExpanded := true; [...]

Re: [fpc-pascal] with statement using mulltiple objects

2014-09-14 Thread Jim Leonard
On 9/13/2014 2:02 PM, Sven Barth wrote: It has always worked in this manner. It's just for abbreviating typing, not for combining properties. (and then the with-variant with multiple elements is even more seldomly used than the single-element one...) In the Turbo Pascal days, WITH allowed for

Re: [fpc-pascal] with statement using mulltiple objects

2014-09-14 Thread Sven Barth
On 14.09.2014 18:05, Philippe wrote: someone wrote about a better performance using with. is that true? even with a simple pointer as in: with ptr^ do begin prop1 := ... prop2 := ... end; which should be faster then ptr^.prop1 := ... ptr^.prop1 := ... others wrote it is just usefull to

Re: [fpc-pascal] with statement using mulltiple objects

2014-09-14 Thread Sven Barth
On 15.09.2014 03:06, Jim Leonard wrote: On 9/13/2014 2:02 PM, Sven Barth wrote: It has always worked in this manner. It's just for abbreviating typing, not for combining properties. (and then the with-variant with multiple elements is even more seldomly used than the single-element one...) In

[fpc-pascal] with statement using mulltiple objects

2014-09-13 Thread vfclists .
According to the docs the with statement when used with mulltiple objects only works with the last parameter. The statement With A,B,C,D do Statement; is equivalent to With A do With B do With C do With D do Statement; -- I thought that if all the objects have the property the

Re: [fpc-pascal] with statement using mulltiple objects

2014-09-13 Thread Sven Barth
On 13.09.2014 20:13, vfclists . wrote: According to the docs the with statement when used with mulltiple objects only works with the last parameter. The statement With A,B,C,D do Statement; is equivalent to With A do With B do With C do With D do Statement; -- I thought that if

Re: [fpc-pascal] with statement using mulltiple objects

2014-09-13 Thread vfclists .
On 13 September 2014 20:02, Sven Barth pascaldra...@googlemail.com wrote: On 13.09.2014 20:13, vfclists . wrote: According to the docs the with statement when used with mulltiple objects only works with the last parameter. The statement With A,B,C,D do Statement; is equivalent to

Re: [fpc-pascal] with statement using mulltiple objects

2014-09-13 Thread Sven Barth
On 13.09.2014 21:29, vfclists . wrote: What then is the nesting for if the command will only apply to the last item with the property? Is each nested element supposed to be a property of the enclosing element? What is the rationale for such a statement, ie using multliple elements? Consider

Re: [fpc-pascal] with statement using mulltiple objects

2014-09-13 Thread Marius
Mattias Gaertner wrote: Less typing. Just some generic comments in general. Its also much harder to understand in the long run and it can even be dangerous as stuff migh be refactored over time. All seasoned programmers know that and try to avoid the with statement.

Re: [fpc-pascal] with statement using mulltiple objects

2014-09-13 Thread Luca Olivetti
El 13/09/14 20:13, vfclists . ha escrit: I thought all the 3 labels would have the caption set, but only Label3's caption is set. Is this a difference between Delphi's Object Pascal and FreePascal, or has Delphi's Object Pascal always worked in the same manner? The with syntax comes from