Re: [Lazarus] array[0..n] of class of TSomething

2011-07-13 Thread Flávio Etrusco
On Wed, Jul 13, 2011 at 6:36 AM, Hans-Peter Diettrich
drdiettri...@aol.com wrote:
 Flávio Etrusco schrieb:

 Err, why pollute the namespace with an identifier you'll only refer
 once?

 For clarity? Code is not only written for the compiler, but also for human
 readers. Look at the C syntax for type declarations, where some constructs
 are nearly unparsable by humans (without pen and paper).

 The name also may be useful in debugging and RTTI, and with every usage of
 an array element in code.

 Pascal is a strongly typed language, where e.g. for local variables or
 parameter types a unique type name is a must!

 DoDi


I agree with on your principles - and your observation on C syntax ;-)
- but disagree this specific case goes against these principles.

Best regards,
Flávio

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] array[0..n] of class of TSomething

2011-07-13 Thread Mark Morgan Lloyd

Hans-Peter Diettrich wrote:

Flávio Etrusco schrieb:


Err, why pollute the namespace with an identifier you'll only refer
once?


For clarity? Code is not only written for the compiler, but also for 
human readers.


As are comments. Particularly for a rarely-used construct like 'class 
of' I think it's reasonable to split it out and say why it's there.


(* An element is either a scalar or a column in a (row in a) table, and 
is  *)
(* directly associated with the action of getting or setting a value via 
SNMP.  *)


typeCNodeContent= class of TNodeContent;

TNodeContentArray= array of CNodeContent;

CNode= class of TNode;

TNodeArray= array of CNode;

TNodeContent= class(TObject)
  public

Also (as shown above) there's the potential for forward references, in 
which case I suggest it's good practice to be consistent.


--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] array[0..n] of class of TSomething

2011-07-12 Thread leledumbo
Seems like codetools parser bug. Try writing it type by type:

type
  Tp2pMessageClass = class of Tp2pMessage;
  Tp2pMessageClassArray = array [0 .. 1] of Tp2pMessageClass;
const
  MsgTypes: Tp2pMessageClassArray = (
...
  );


--
View this message in context: 
http://free-pascal-lazarus.989080.n3.nabble.com/Lazarus-array-0-n-of-class-of-TSomething-tp3162813p3163033.html
Sent from the Free Pascal - Lazarus mailing list archive at Nabble.com.

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] array[0..n] of class of TSomething

2011-07-12 Thread Sven Barth

On 12.07.2011 18:38, leledumbo wrote:

Seems like codetools parser bug. Try writing it type by type:

type
   Tp2pMessageClass = class of Tp2pMessage;
   Tp2pMessageClassArray = array [0 .. 1] of Tp2pMessageClass;
const
   MsgTypes: Tp2pMessageClassArray = (
 ...
   );


Free Pascal supports class of in declarations while Delphi does not, 
but it's a seldom used feature so the developers of the code tools might 
not have noticed that problem at all :)


@Bernd: Would you create a bug report, please?

Regards,
Sven


--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] array[0..n] of class of TSomething

2011-07-12 Thread Hans-Peter Diettrich

Sven Barth schrieb:

On 12.07.2011 18:38, leledumbo wrote:

Seems like codetools parser bug. Try writing it type by type:

type
   Tp2pMessageClass = class of Tp2pMessage;
   Tp2pMessageClassArray = array [0 .. 1] of Tp2pMessageClass;
const
   MsgTypes: Tp2pMessageClassArray = (
 ...
   );


Free Pascal supports class of in declarations while Delphi does not, 
but it's a seldom used feature so the developers of the code tools might 
not have noticed that problem at all :)


IMO this comfort is a misfeature, that bloats the compiler and all 
other parsers. It has not been introduced in Delphi for good reason.


DoDi


--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] array[0..n] of class of TSomething

2011-07-12 Thread Flávio Etrusco
On Tue, Jul 12, 2011 at 7:53 PM, Hans-Peter Diettrich
drdiettri...@aol.com wrote:
 Sven Barth schrieb:

 On 12.07.2011 18:38, leledumbo wrote:

 Seems like codetools parser bug. Try writing it type by type:

 type
   Tp2pMessageClass = class of Tp2pMessage;
   Tp2pMessageClassArray = array [0 .. 1] of Tp2pMessageClass;
 const
   MsgTypes: Tp2pMessageClassArray = (
     ...
   );

 Free Pascal supports class of in declarations while Delphi does not, but
 it's a seldom used feature so the developers of the code tools might not
 have noticed that problem at all :)

 IMO this comfort is a misfeature, that bloats the compiler and all other
 parsers. It has not been introduced in Delphi for good reason.

 DoDi


Err, why pollute the namespace with an identifier you'll only refer
once? It's hardly essential but surely not a misfeature either.

-Flávio

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus