Re: [fpc-devel] Local variable names and colision with attributes/properties names

2012-09-27 Thread Sven Barth
On 27.09.2012 19:33, Marco van de Voort wrote: In our previous episode, Marcos Douglas said: - Records... "R" (?) - Constants... UPPER_CASE? cSomething? At least we would have a good and unique style. IMHO, that's taking it too far. Usually there is only made a difference between scopes (e.g

Re: [fpc-devel] Local variable names and colision with attributes/properties names

2012-09-27 Thread Marcos Douglas
On Thu, Sep 27, 2012 at 2:43 PM, Michael Van Canneyt wrote: > > > On Thu, 27 Sep 2012, Marcos Douglas wrote: > >>> >>> I hope not :-) >> >> >> Of course the second is (a little) better. >> >> But, If you permits: >> for i := StardValue to EndValue do >> MyArray[i] := i; >> >> Now is more readable

Re: [fpc-devel] Local variable names and colision with attributes/properties names

2012-09-27 Thread Michael Van Canneyt
On Thu, 27 Sep 2012, Marcos Douglas wrote: I hope not :-) Of course the second is (a little) better. But, If you permits: for i := StardValue to EndValue do MyArray[i] := i; Now is more readable. More verbose than the first but less verbose than second. ;) And it's not about the size

Re: [fpc-devel] Local variable names and colision with attributes/properties names

2012-09-27 Thread Marcos Douglas
On Thu, Sep 27, 2012 at 2:26 PM, Michael Van Canneyt wrote: > > > On Thu, 27 Sep 2012, Marcos Douglas wrote: > However we can use "poor names" -- very difficult to happen a collision -- to represent a variable like A, J, D... but I do not think this is a good practice and you? >>> >

Re: [fpc-devel] Local variable names and colision with attributes/properties names

2012-09-27 Thread Marco van de Voort
In our previous episode, Marcos Douglas said: > > - Records... "R" (?) > - Constants... UPPER_CASE? cSomething? > > At least we would have a good and unique style. IMHO, that's taking it too far. Usually there is only made a difference between scopes (e.g. field and parameter, or global symbol a

Re: [fpc-devel] Local variable names and colision with attributes/properties names

2012-09-27 Thread Michael Van Canneyt
On Thu, 27 Sep 2012, Marcos Douglas wrote: However we can use "poor names" -- very difficult to happen a collision -- to represent a variable like A, J, D... but I do not think this is a good practice and you? I do think this is good practice. I will seldom use variable names of more than 2

Re: [fpc-devel] Local variable names and colision with attributes/properties names

2012-09-27 Thread Mattias Gaertner
On Thu, 27 Sep 2012 13:52:53 -0300 Marcos Douglas wrote: > On Thu, Sep 27, 2012 at 12:34 PM, Graeme Geldenhuys > wrote: > > On 2012-09-27 16:08, michael.vancann...@wisa.be wrote: > >> > >> The compiler helps you by forcing you to use a prefix in objfpc mode in > >> case you forgot. > > > > The c

Re: [fpc-devel] Local variable names and colision with attributes/properties names

2012-09-27 Thread Marcos Douglas
On Thu, Sep 27, 2012 at 1:58 PM, Graeme Geldenhuys wrote: > On 2012-09-27 17:52, Marcos Douglas wrote: >> >> I agree that is much simpler... but why nobody, in another language, >> do the same? Does not worth it? I do not know. > > Well, other languages have there own quirks like case sensitive >

Re: [fpc-devel] Local variable names and colision with attributes/properties names

2012-09-27 Thread Marcos Douglas
On Thu, Sep 27, 2012 at 1:55 PM, Graeme Geldenhuys wrote: > On 2012-09-27 17:46, Marcos Douglas wrote: >> >> This "feature" have the origin in a bug in compiler. > > Yeah, but it takes a human to debug such issues. The compiler might have > no problem understanding complex scopes, but the same cou

Re: [fpc-devel] Local variable names and colision with attributes/properties names

2012-09-27 Thread Marcos Douglas
On Thu, Sep 27, 2012 at 1:48 PM, Michael Van Canneyt wrote: > > > On Thu, 27 Sep 2012, Marcos Douglas wrote: > >> On Thu, Sep 27, 2012 at 12:08 PM, wrote: >>> >>> >>> >>> On Thu, 27 Sep 2012, Marcos Douglas wrote: >>> > > Yes, it's always possible. In practice, I haven't seen this happen

Re: [fpc-devel] Local variable names and colision with attributes/properties names

2012-09-27 Thread Graeme Geldenhuys
On 2012-09-27 17:52, Marcos Douglas wrote: > > I agree that is much simpler... but why nobody, in another language, > do the same? Does not worth it? I do not know. Well, other languages have there own quirks like case sensitive identifiers. Thank God, Object Pascal doesn't have that. Just imagi

Re: [fpc-devel] Local variable names and colision with attributes/properties names

2012-09-27 Thread Graeme Geldenhuys
On 2012-09-27 17:46, Marcos Douglas wrote: > > This "feature" have the origin in a bug in compiler. Yeah, but it takes a human to debug such issues. The compiler might have no problem understanding complex scopes, but the same could not always be said for programmers. My code was affected by thi

Re: [fpc-devel] Local variable names and colision with attributes/properties names

2012-09-27 Thread Marcos Douglas
On Thu, Sep 27, 2012 at 12:34 PM, Graeme Geldenhuys wrote: > On 2012-09-27 16:08, michael.vancann...@wisa.be wrote: >> >> The compiler helps you by forcing you to use a prefix in objfpc mode in >> case you forgot. > > The change in FPC mode objfpc was definitely a good thing. I had code > where a

Re: [fpc-devel] Local variable names and colision with attributes/properties names

2012-09-27 Thread Michael Van Canneyt
On Thu, 27 Sep 2012, Marcos Douglas wrote: On Thu, Sep 27, 2012 at 12:08 PM, wrote: On Thu, 27 Sep 2012, Marcos Douglas wrote: Yes, it's always possible. In practice, I haven't seen this happen a single time in the 10+ years that the compiler has had this feature. That doesn't mean tha

Re: [fpc-devel] Local variable names and colision with attributes/properties names

2012-09-27 Thread Marcos Douglas
On Thu, Sep 27, 2012 at 12:26 PM, Graeme Geldenhuys wrote: > On 2012-09-27 15:48, Marcos Douglas wrote: >> problem, IMHO, is that I can't choose when we talk about local >> variables. > > Just like there is a coding style (not language rule) that classes start > with the "T" prefix, and class fiel

Re: [fpc-devel] Local variable names and colision with attributes/properties names

2012-09-27 Thread Marcos Douglas
On Thu, Sep 27, 2012 at 12:08 PM, wrote: > > > On Thu, 27 Sep 2012, Marcos Douglas wrote: > >>> >>> Yes, it's always possible. In practice, I haven't seen this happen a >>> single >>> time in the 10+ years that the compiler has had this feature. That >>> doesn't >>> mean that it's impossible, but

Re: [fpc-devel] Local variable names and colision with attributes/properties names

2012-09-27 Thread Graeme Geldenhuys
On 2012-09-27 16:08, michael.vancann...@wisa.be wrote: > > The compiler helps you by forcing you to use a prefix in objfpc mode in > case you forgot. The change in FPC mode objfpc was definitely a good thing. I had code where a class had an Index property, and other methods of that class had an I

Re: [fpc-devel] Local variable names and colision with attributes/properties names

2012-09-27 Thread Graeme Geldenhuys
On 2012-09-27 15:48, Marcos Douglas wrote: > problem, IMHO, is that I can't choose when we talk about local > variables. Just like there is a coding style (not language rule) that classes start with the "T" prefix, and class field variable start with a "F" prefix, I applied that same coding style

Re: [fpc-devel] Local variable names and colision with attributes/properties names

2012-09-27 Thread Graeme Geldenhuys
On 2012-09-27 15:30, michael.vancann...@wisa.be wrote: > For me, it has become second nature never ever to have a variable with the > same name as a property, even in Delphi. +1 G. ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.

Re: [fpc-devel] Local variable names and colision with attributes/properties names

2012-09-27 Thread michael . vancanneyt
On Thu, 27 Sep 2012, Marcos Douglas wrote: Yes, it's always possible. In practice, I haven't seen this happen a single time in the 10+ years that the compiler has had this feature. That doesn't mean that it's impossible, but it's another factor in the "good to have" versus "causes more harm t

Re: [fpc-devel] Local variable names and colision with attributes/properties names

2012-09-27 Thread Marcos Douglas
On Thu, Sep 27, 2012 at 11:53 AM, wrote: > > > On Thu, 27 Sep 2012, Marcos Douglas wrote: > >> >> But this is a programmer's choice, ie, using or not the Self. The >> problem, IMHO, is that I can't choose when we talk about local >> variables. > > > You can: Use delphi mode. As I said, I know th

Re: [fpc-devel] Local variable names and colision with attributes/properties names

2012-09-27 Thread Marcos Douglas
On Thu, Sep 27, 2012 at 11:33 AM, Jonas Maebe wrote: > > On 27 Sep 2012, at 16:18, Marcos Douglas wrote: > >> On Thu, Sep 27, 2012 at 11:01 AM, Jonas Maebe >> wrote: >>> >>> >>> Yes, but the human brain is very good at confusing such things, and it's >>> very easy to accidentally assign something

Re: [fpc-devel] Local variable names and colision with attributes/properties names

2012-09-27 Thread michael . vancanneyt
On Thu, 27 Sep 2012, Marcos Douglas wrote: But this is a programmer's choice, ie, using or not the Self. The problem, IMHO, is that I can't choose when we talk about local variables. You can: Use delphi mode. Michael. ___ fpc-devel maillist - f

Re: [fpc-devel] Local variable names and colision with attributes/properties names

2012-09-27 Thread Marcos Douglas
On Thu, Sep 27, 2012 at 11:30 AM, wrote: > > > On Thu, 27 Sep 2012, Marcos Douglas wrote: > >> On Thu, Sep 27, 2012 at 11:01 AM, Jonas Maebe >> wrote: >>> >>> >>> On 27 Sep 2012, at 15:51, Marcos Douglas wrote: >>> >>> What is the advantages to the compiler return the error bellow? >>> ERROR: un

Re: [fpc-devel] Local variable names and colision with attributes/properties names

2012-09-27 Thread Jonas Maebe
On 27 Sep 2012, at 16:18, Marcos Douglas wrote: On Thu, Sep 27, 2012 at 11:01 AM, Jonas Maebe > wrote: Yes, but the human brain is very good at confusing such things, and it's very easy to accidentally assign something to a local variable instead of to a field. Only Pascal uses that way

Re: [fpc-devel] Local variable names and colision with attributes/properties names

2012-09-27 Thread michael . vancanneyt
On Thu, 27 Sep 2012, Marcos Douglas wrote: On Thu, Sep 27, 2012 at 11:01 AM, Jonas Maebe wrote: On 27 Sep 2012, at 15:51, Marcos Douglas wrote: What is the advantages to the compiler return the error bellow? ERROR: unit1.pas(31,3) Error: Duplicate identifier "FooVar" Why the compiler do n

Re: [fpc-devel] Local variable names and colision with attributes/properties names

2012-09-27 Thread Marcos Douglas
On Thu, Sep 27, 2012 at 11:01 AM, Jonas Maebe wrote: > > On 27 Sep 2012, at 15:51, Marcos Douglas wrote: > > What is the advantages to the compiler return the error bellow? > ERROR: unit1.pas(31,3) Error: Duplicate identifier "FooVar" > > Why the compiler do not respect the scope, ie, the local va

Re: [fpc-devel] Local variable names and colision with attributes/properties names

2012-09-27 Thread Jonas Maebe
On 27 Sep 2012, at 15:51, Marcos Douglas wrote: What is the advantages to the compiler return the error bellow? ERROR: unit1.pas(31,3) Error: Duplicate identifier "FooVar" Why the compiler do not respect the scope, ie, the local variable should have the preference, I'm not right? Yes, but th