Re: [Lazarus] 'with' is evil, isn't it?

2011-08-08 Thread Robin Hoo
As I see if we could use with like below, adding a dot before property/function/procedure with Canvas do begin .Rectangle(0, 0, .Width, .Height); end; 2011/8/5 Alexander Klenin kle...@gmail.com On Fri, Aug 5, 2011 at 22:04, Luca Olivetti l...@wetron.es wrote: Unfortunately, with a

Re: [Lazarus] 'with' is evil, isn't it?

2011-08-05 Thread Lukasz Sokol
On 04/08/2011 14:52, Alexander Klenin wrote: [...] My thoughts exactly! :) How about some explicit syntax sugar to help Code Tools understand this construct? e.g. that an alias can only be declared within the with statement: (and of course the whole alias business can be optional) with

Re: [Lazarus] 'with' is evil, isn't it?

2011-08-05 Thread Alexander Klenin
On Fri, Aug 5, 2011 at 19:32, Lukasz Sokol el.es...@gmail.com wrote: On 04/08/2011 14:52, Alexander Klenin wrote:  e.g. that an alias can only be declared within the with statement: (and of course the whole alias business can be optional) with MyLongAndComplicatedObject [as a[:optional type

Re: [Lazarus] 'with' is evil, isn't it?

2011-08-05 Thread Luca Olivetti
Al 03/08/11 17:08, En/na Lukasz Sokol ha escrit: Except that in the with construct the named alias will not be an instance of variable, but rather a way of _naming_ it shorter, an _alias_; I agree that making it a variable will create all sorts of problems regarding memory management,

Re: [Lazarus] 'with' is evil, isn't it?

2011-08-05 Thread Sven Barth
Am 05.08.2011 11:23, schrieb Luca Olivetti: Al 03/08/11 17:08, En/na Lukasz Sokol ha escrit: Except that in the with construct the named alias will not be an instance of variable, but rather a way of _naming_ it shorter, an _alias_; I agree that making it a variable will create all sorts of

Re: [Lazarus] 'with' is evil, isn't it?

2011-08-05 Thread Max Vlasov
On Fri, Aug 5, 2011 at 1:29 PM, Sven Barth pascaldra...@googlemail.comwrote: Am 05.08.2011 11:23, schrieb Luca Olivetti: (though it was 20 years ago and I don't remember the exact syntax, I think it was with a=some.structure,b=some.other.**structure do instead of with

Re: [Lazarus] 'with' is evil, isn't it?

2011-08-05 Thread Luca Olivetti
Al 05/08/11 12:11, En/na Max Vlasov ha escrit: Luca shared an interesting fact, so I tried to find more information. He probably meant UCSD Pascal, as I see this is a very interesting system, mentioned also in the lazarus wiki ( http://wiki.freepascal.org/UCSD_Pascal ). I downloaded the

Re: [Lazarus] 'with' is evil, isn't it?

2011-08-05 Thread Sven Barth
Am 05.08.2011 12:30, schrieb Luca Olivetti: Al 05/08/11 12:11, En/na Max Vlasov ha escrit: Luca shared an interesting fact, so I tried to find more information. He probably meant UCSD Pascal, as I see this is a very interesting system, mentioned also in the lazarus wiki (

Re: [Lazarus] 'with' is evil, isn't it?

2011-08-05 Thread Luca Olivetti
Al 05/08/11 12:30, En/na Luca Olivetti ha escrit: Al 05/08/11 12:11, En/na Max Vlasov ha escrit: Luca shared an interesting fact, so I tried to find more information. He probably meant UCSD Pascal, as I see this is a very interesting system, mentioned also in the lazarus wiki (

Re: [Lazarus] 'with' is evil, isn't it?

2011-08-05 Thread Sven Barth
Am 05.08.2011 12:11, schrieb Max Vlasov: But during the research another interesting specie was found. It's called Sun Workshop Pascal Compiler http://www.informatik.uni-hamburg.de/RZ/software/SUNWspro/pascal/user_guide/index.html It's amazing how many Pascal compilers are out there... It

Re: [Lazarus] 'with' is evil, isn't it?

2011-08-05 Thread Luca Olivetti
Al 05/08/11 12:40, En/na Sven Barth ha escrit: Though = seems a little bit like a misuse of that operator... := might be a more pascalish solution. I really don't mind one way or the other, but since a bare = is used for defining constants, it doesn't seem out of place for defining an alias

Re: [Lazarus] 'with' is evil, isn't it?

2011-08-05 Thread Alexander Klenin
On Fri, Aug 5, 2011 at 21:51, Luca Olivetti l...@wetron.es wrote: Al 05/08/11 12:40, En/na Sven Barth ha escrit: Though = seems a little bit like a misuse of that operator... := might be a more pascalish solution. I really don't mind one way or the other, but since a bare = is used for

Re: [Lazarus] 'with' is evil, isn't it?

2011-08-05 Thread Luca Olivetti
Al 05/08/11 12:53, En/na Alexander Klenin ha escrit: On Fri, Aug 5, 2011 at 21:51, Luca Olivetti l...@wetron.es wrote: Al 05/08/11 12:40, En/na Sven Barth ha escrit: Though = seems a little bit like a misuse of that operator... := might be a more pascalish solution. I really don't mind one

Re: [Lazarus] 'with' is evil, isn't it?

2011-08-05 Thread Mark Morgan Lloyd
Alexander Klenin wrote: On Fri, Aug 5, 2011 at 21:51, Luca Olivetti l...@wetron.es wrote: Al 05/08/11 12:40, En/na Sven Barth ha escrit: Though = seems a little bit like a misuse of that operator... := might be a more pascalish solution. I really don't mind one way or the other, but since a

Re: [Lazarus] 'with' is evil, isn't it?

2011-08-05 Thread Hans-Peter Diettrich
Sven Barth schrieb: you can see the following example with new_patient: new, old_patient: old do begin new.LastName := 'Smith'; [...] Not only the : look a bit strange (it remembers me a bit of the on-clause in except blocks though), but also - and more importantly - the order:

Re: [Lazarus] 'with' is evil, isn't it?

2011-08-04 Thread Sven Barth
Am 03.08.2011 09:31, schrieb Michael Schnell: On 08/02/2011 06:39 PM, Jürgen Hestermann wrote: In general I find the with statement very useful and have used and do use it a lot. If you are clever enough to avoid confusion ;) . (Such as a nested with that defines the same identifier for both

Re: [Lazarus] 'with' is evil, isn't it?

2011-08-04 Thread Sven Barth
Am 02.08.2011 16:38, schrieb Max Vlasov: Hi, Personally I stopped using 'with' keyword long time ago, but there are code fragments from the past and today I fixed a little bug showing again that it's a evil. TCanvas in lazarus has width and height properties while in Delphi it hasn't (at least

Re: [Lazarus] 'with' is evil, isn't it?

2011-08-04 Thread Michael Schnell
On 08/03/2011 10:17 PM, Reimar Grabowski wrote: I don't really get why this question is posted here and not on the fpc list. +1 -Michael -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org

Re: [Lazarus] 'with' is evil, isn't it?

2011-08-04 Thread Michael Schnell
On 08/04/2011 08:12 AM, Sven Barth wrote: absolute is another example of such a construc ..and AFAIK using absolute is depreciated (at least with Delphi). -Michael -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org

Re: [Lazarus] 'with' is evil, isn't it?

2011-08-04 Thread Max Vlasov
On Thu, Aug 4, 2011 at 11:39 AM, Michael Schnell mschn...@lumino.de wrote: On 08/03/2011 10:17 PM, Reimar Grabowski wrote: I don't really get why this question is posted here and not on the fpc list. +1 -Michael Actually, this particular case was also lcl-related. Anyone who written

Re: [Lazarus] 'with' is evil, isn't it?

2011-08-04 Thread Alexander Klenin
2011/8/4 Max Vlasov max.vla...@gmail.com: Anyone who written something in Delphi control-related with a construction with Canvas do Width Height ... (meaning the bounds of the control) will be affected while porting something to Lazarus , because lcl Canvas has width and height while

Re: [Lazarus] 'with' is evil, isn't it?

2011-08-04 Thread Martin
On 04/08/2011 12:10, Alexander Klenin wrote: 2011/8/4 Max Vlasovmax.vla...@gmail.com: Anyone who written something in Delphi control-related with a construction with Canvas do Width Height ... (meaning the bounds of the control) will be affected while porting something to Lazarus ,

Re: [Lazarus] 'with' is evil, isn't it?

2011-08-04 Thread Alexander Klenin
On Thu, Aug 4, 2011 at 22:32, Martin laza...@mfriebe.de wrote: IF something like alias were to be introduced (and I am *not* for this), then pascal style, with a declaration above the code. It could then be used in a with statement, or anywhere else. procedure foo; var  c: TObject; alias;

Re: [Lazarus] 'with' is evil, isn't it?

2011-08-04 Thread Hans-Peter Diettrich
Michael Schnell schrieb: On 08/04/2011 08:12 AM, Sven Barth wrote: absolute is another example of such a construc ..and AFAIK using absolute is depreciated (at least with Delphi). absolute is undocumented in XE, but not flagged as deprecated by the compiler. And it works as expected, of

Re: [Lazarus] 'with' is evil, isn't it?

2011-08-04 Thread Sven Barth
Am 04.08.2011 16:06, schrieb Hans-Peter Diettrich: Michael Schnell schrieb: On 08/04/2011 08:12 AM, Sven Barth wrote: absolute is another example of such a construc ..and AFAIK using absolute is depreciated (at least with Delphi). absolute is undocumented in XE, but not flagged as

Re: [Lazarus] 'with' is evil, isn't it?

2011-08-03 Thread Michael Schnell
On 08/03/2011 06:50 AM, Max Vlasov wrote: Reading all the discussion and suggestions, some thoughts came I never tried with with Lazarus, but with Delphi (I never tried the newest versions) it was not possible to view the value of a with-handled variable by pointing the mouse on it. The

Re: [Lazarus] 'with' is evil, isn't it?

2011-08-03 Thread Michael Schnell
On 08/02/2011 06:39 PM, Jürgen Hestermann wrote: In general I find the with statement very useful and have used and do use it a lot. If you are clever enough to avoid confusion ;) . (Such as a nested with that defines the same identifier for both withed record and maybe same is also

Re: [Lazarus] 'with' is evil, isn't it?

2011-08-03 Thread Alexander Klenin
I also use 'with' extensively, despite the risks, since with the right usage the readablity gains are considerable. 2011/8/3 Max Vlasov max.vla...@gmail.com: 1. Introducing a check in the compiler setting (or a conditional define) that could force the developer to use self inside 'with'

Re: [Lazarus] 'with' is evil, isn't it?

2011-08-03 Thread Michael Van Canneyt
On Wed, 3 Aug 2011, Alexander Klenin wrote: I also use 'with' extensively, despite the risks, since with the right usage the readablity gains are considerable. 2011/8/3 Max Vlasov max.vla...@gmail.com: 1. Introducing a check in the compiler setting (or a conditional define) that could force

Re: [Lazarus] 'with' is evil, isn't it?

2011-08-03 Thread Michael Schnell
On 08/03/2011 06:50 AM, Max Vlasov wrote: 1. Introducing a check in the compiler setting (or a conditional define) that could force the developer to use self inside 'with' constructions As you can consider any class functions code to be implicitly included in a with self clause this could

Re: [Lazarus] 'with' is evil, isn't it?

2011-08-03 Thread Lukasz Sokol
On 03/08/2011 13:00, Alexander Klenin wrote: On Wed, Aug 3, 2011 at 22:34, Michael Van Canneyt mich...@freepascal.org wrote: Of course, a disambiguation facility would be even better, but I am afraid FPC developers will resist this improvement :( Frankly, I don't understand the discussion.

Re: [Lazarus] 'with' is evil, isn't it?

2011-08-03 Thread Graeme Geldenhuys
On 08/03/2011 02:00 PM, Alexander Klenin wrote: Anyway, my preferred solution would be to allow aliases in 'with' statement, which would improve readability even further while sacrificing only a few characters: with a := MyCompomentList[0] do begin Rectangle(0, 0, a.Width, a.Height);

Re: [Lazarus] 'with' is evil, isn't it?

2011-08-03 Thread Michael Van Canneyt
On Wed, 3 Aug 2011, Graeme Geldenhuys wrote: On 08/03/2011 02:00 PM, Alexander Klenin wrote: Anyway, my preferred solution would be to allow aliases in 'with' statement, which would improve readability even further while sacrificing only a few characters: with a := MyCompomentList[0] do

Re: [Lazarus] 'with' is evil, isn't it?

2011-08-03 Thread Graeme Geldenhuys
On 08/03/2011 03:20 PM, Michael Van Canneyt wrote: A simple solution to something which I don't think is a problem either. [I fully agree with Michael van Canneyt here] I agree the above is indeed an acceptable solution. But I do think it is a corner case, because it goes against pascal

Re: [Lazarus] 'with' is evil, isn't it?

2011-08-03 Thread Mark Morgan Lloyd
Michael Van Canneyt wrote: On Wed, 3 Aug 2011, Graeme Geldenhuys wrote: On 08/03/2011 02:00 PM, Alexander Klenin wrote: Anyway, my preferred solution would be to allow aliases in 'with' statement, which would improve readability even further while sacrificing only a few characters: with a

Re: [Lazarus] 'with' is evil, isn't it?

2011-08-03 Thread Michael Fuchs
Am 03.08.2011 15:53, schrieb Mark Morgan Lloyd: with const a = MyCompomentList[0] do begin Rectangle(0, 0, a.Width, a.Height); end; What is wrong with the existing solution, declaring a variable a and use it? var a: TComponent; ... a := MyCompomentList[0]; Rectangle(0, 0, a.Width,

Re: [Lazarus] 'with' is evil, isn't it?

2011-08-03 Thread Michael Schnell
On 08/03/2011 02:00 PM, Alexander Klenin wrote: with a := MyCompomentList[0] do begin Rectangle(0, 0, a.Width, a.Height); end; Here defining a as a pointer would do away with the with and the begin .. end. By allowing for C-like defining of cariables we could write something like var a

Re: [Lazarus] 'with' is evil, isn't it?

2011-08-03 Thread Michael Van Canneyt
On Wed, 3 Aug 2011, Mark Morgan Lloyd wrote: Michael Van Canneyt wrote: On Wed, 3 Aug 2011, Graeme Geldenhuys wrote: On 08/03/2011 02:00 PM, Alexander Klenin wrote: Anyway, my preferred solution would be to allow aliases in 'with' statement, which would improve readability even further

Re: [Lazarus] 'with' is evil, isn't it?

2011-08-03 Thread Fr0sT
I personally use with widely and never experienced any troubles with it but I know that many people just hate this statement (see discussion on Emb-ro forums and one of the most popular requests on Emb-ro quality central). I guess problem could be solved by modifying statement like this: with

Re: [Lazarus] 'with' is evil, isn't it?

2011-08-03 Thread Max Vlasov
On Wed, Aug 3, 2011 at 3:34 PM, Michael Van Canneyt mich...@freepascal.orgwrote: On Wed, 3 Aug 2011, Alexander Klenin wrote: I also use 'with' extensively, despite the risks, since with the right usage the readablity gains are considerable. 2011/8/3 Max Vlasov max.vla...@gmail.com: 1.

Re: [Lazarus] 'with' is evil, isn't it?

2011-08-03 Thread Lukasz Sokol
On 03/08/2011 15:34, Michael Schnell wrote: On 08/03/2011 02:00 PM, Alexander Klenin wrote: with a := MyCompomentList[0] do begin Rectangle(0, 0, a.Width, a.Height); end; Here defining a as a pointer would do away with the with and the begin .. end. By allowing for C-like defining of

Re: [Lazarus] 'with' is evil, isn't it?

2011-08-03 Thread Lukasz Sokol
On 03/08/2011 14:20, Michael Van Canneyt wrote: The On E : Exception do is a Borland hack, which I'm not entirely happy with either. They should have forced people to declare the E in the function variable block. But since we already have this one, I could live with the above. (albeit

Re: [Lazarus] 'with' is evil, isn't it?

2011-08-03 Thread Michael Van Canneyt
On Wed, 3 Aug 2011, Max Vlasov wrote: On Wed, Aug 3, 2011 at 3:34 PM, Michael Van Canneyt mich...@freepascal.org wrote: On Wed, 3 Aug 2011, Alexander Klenin wrote: I also use 'with' extensively, despite the risks, since with the right usage the readablity

Re: [Lazarus] 'with' is evil, isn't it?

2011-08-03 Thread Hans-Peter Diettrich
Michael Van Canneyt schrieb: Frankly, I don't understand the discussion. I use 'with' all the time because it increases readability and reduces typing. I don't want to be punished with heaps of warnings simply because I use a language feature. Yes, I am aware that there are risks involved.

Re: [Lazarus] 'with' is evil, isn't it?

2011-08-03 Thread Reimar Grabowski
No, 'with' is not evil and I don't really get why this question is posted here and not on the fpc list. R. -- A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? A: Top-posting. Q: What is the most annoying thing in e-mail? --

Re: [Lazarus] 'with' is evil, isn't it?

2011-08-03 Thread Alexsander Rosa
We use with to populate or display properties of objects from our in-house OPF. However we have some ground rules: most properties are mapped from tables (DAO pattern) and their names are in portuguese and with an underscore, like valor_total. A common code looks like this: *with mCliente do

Re: [Lazarus] 'with' is evil, isn't it?

2011-08-03 Thread leledumbo
I think a warning if the name inside of 'with' overrides a name from outer scope would be an acceptable compromise. I agree with this solution, it doesn't change the syntax, yet it gives better chance to spot wrong scope of identifier which could happen during porting or upgrade. -- View this

[Lazarus] 'with' is evil, isn't it?

2011-08-02 Thread Max Vlasov
Hi, Personally I stopped using 'with' keyword long time ago, but there are code fragments from the past and today I fixed a little bug showing again that it's a evil. TCanvas in lazarus has width and height properties while in Delphi it hasn't (at least some time ago). So the code below leads to

Re: [Lazarus] 'with' is evil, isn't it?

2011-08-02 Thread Michael Schnell
+1 -Michael -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Re: [Lazarus] 'with' is evil, isn't it?

2011-08-02 Thread Rich Saunders
+1 Rich S. -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Re: [Lazarus] 'with' is evil, isn't it?

2011-08-02 Thread silvioprog
+1. -- Silvio Clécio === Blog - silvioprog.com.br Twitter - twitter.com/silvioprog LazSolutions - code.google.com/p/lazsolutions LazWebSolutions - code.google.com/p/lazwebsolutions Lazarus-BR - groups.google.com.br/group/lazarus-br?hl=pt-BR

Re: [Lazarus] 'with' is evil, isn't it?

2011-08-02 Thread Marcos Douglas
2011/8/2 Max Vlasov max.vla...@gmail.com: Hi, Personally I stopped using 'with' keyword long time ago, but there are code fragments from the past and today I fixed a little bug showing again that it's a evil. TCanvas in lazarus has width and height properties while in Delphi it hasn't (at

Re: [Lazarus] 'with' is evil, isn't it?

2011-08-02 Thread ik
On Tue, Aug 2, 2011 at 18:03, Marcos Douglas m...@delfire.net wrote: 2011/8/2 Max Vlasov max.vla...@gmail.com: Hi, Personally I stopped using 'with' keyword long time ago, but there are code fragments from the past and today I fixed a little bug showing again that it's a evil. TCanvas

Re: [Lazarus] 'with' is evil, isn't it?

2011-08-02 Thread cobines
Yes, it is treacherous. I try not to use it. Maybe if it only allowed to refer to properties, functions of the with object, but it also allows outer scope and you never know how the classes will change in the future. Suddenly your code refers to entirely different data, because someone decided to

Re: [Lazarus] 'with' is evil, isn't it?

2011-08-02 Thread Marcos Douglas
2011/8/2 ik ido...@gmail.com: That's also bad. Because I can use for example with the following way: with area, canvas do   begin     Rectangle(0,0, with, height);   end; If you'll have this or self or $_ (in perl :)) it still contain the same problem. I prefer explicit code then implicit

Re: [Lazarus] 'with' is evil, isn't it?

2011-08-02 Thread Hans-Peter Diettrich
Marcos Douglas schrieb: IMHO, 'with' should have an implicit pointer like 'self' (could be 'this' or whatever). Thisg will fail with nested With's, or a With with multiple expressions. A nicer syntax would require only an . for your this.. Eg: procedure TControlDescendant.Paint; begin

Re: [Lazarus] 'with' is evil, isn't it?

2011-08-02 Thread Jürgen Hestermann
Max Vlasov schrieb: Personally I stopped using 'with' keyword long time ago, but there are code fragments from the past and today I fixed a little bug showing again that it's a evil. TCanvas in lazarus has width and height properties while in Delphi it hasn't (at least some time ago). So the

Re: [Lazarus] 'with' is evil, isn't it?

2011-08-02 Thread Mark Morgan Lloyd
Hans-Peter Diettrich wrote: Marcos Douglas schrieb: IMHO, 'with' should have an implicit pointer like 'self' (could be 'this' or whatever). Thisg will fail with nested With's, or a With with multiple expressions. A nicer syntax would require only an . for your this.. Eg: procedure

Re: [Lazarus] 'with' is evil, isn't it?

2011-08-02 Thread Martin
On 02/08/2011 17:39, Jürgen Hestermann wrote: In general I find the with statement very useful and have used and do use it a lot. Though it must be used in well defined short code blocks only. If you have very convoluted data structures with deeply nested arrays and records and pointers to

Re: [Lazarus] 'with' is evil, isn't it?

2011-08-02 Thread Jürgen Hestermann
--- with Uebergabe^, Qarray[QuaderNr]^.Teilung[R] do AusdehnungInMeter := (Feldgrenzen[length(Einteilungen)+1] - Feldgrenzen[1]) *

Re: [Lazarus] 'with' is evil, isn't it?

2011-08-02 Thread Marcos Douglas
On Tue, Aug 2, 2011 at 2:21 PM, Hans-Peter Diettrich drdiettri...@aol.com wrote: Marcos Douglas schrieb: IMHO, 'with' should have an implicit pointer like 'self' (could be 'this' or whatever). Thisg will fail with nested With's, or a With with multiple expressions. A nicer syntax would

Re: [Lazarus] 'with' is evil, isn't it?

2011-08-02 Thread Hans-Peter Diettrich
Jürgen Hestermann schrieb: with Uebergabe^, Qarray[QuaderNr]^.Teilung[R] do AusdehnungInMeter := (Feldgrenzen[length(Einteilungen)+1] - Feldgrenzen[1]) * EinheitAuswahl[Einheit.Koord[R]].Faktor; This is very close

Re: [Lazarus] 'with' is evil, isn't it?

2011-08-02 Thread Hans-Peter Diettrich
Marcos Douglas schrieb: On Tue, Aug 2, 2011 at 2:21 PM, Hans-Peter Diettrich drdiettri...@aol.com wrote: Marcos Douglas schrieb: IMHO, 'with' should have an implicit pointer like 'self' (could be 'this' or whatever). Thisg will fail with nested With's, or a With with multiple expressions. A

Re: [Lazarus] 'with' is evil, isn't it?

2011-08-02 Thread Luiz Americo Pereira Camara
On 2/8/2011 11:38, Max Vlasov wrote: Hi, Personally I stopped using 'with' keyword long time ago, but there are code fragments from the past and today I fixed a little bug showing again that it's a evil. TCanvas in lazarus has width and height properties while in Delphi it hasn't (at least

Re: [Lazarus] 'with' is evil, isn't it?

2011-08-02 Thread Max Vlasov
On Tue, Aug 2, 2011 at 7:03 PM, Marcos Douglas m...@delfire.net wrote: 2011/8/2 Max Vlasov max.vla...@gmail.com: Hi, Personally I stopped using 'with' keyword long time ago, but there are code fragments from the past and today I fixed a little bug showing again that it's a evil.