Sign in Join

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

Mailing lists / fpc-devel / 2006-03

Type definition

8 messages · 6 people · –

Reply by email Subscribe to this list Your subscription

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

Paul Davidson

If there compelling reason why type definitions cannot be included in class/object definitions?
Make it mode FPC to keep folks happy :)

Quite often a type is defined in INTERFACE part, but only used within class/object defined in same unit.
1) This means that type is public. This is not always good thing in OOese.
2) Unit must be specified in child's child's USE list.

P Davidson
Corax Networks Inc.
http://CoraxNetworks.com

IMPORTANT NOTICE: This message is intended only for the use of the individual or entity to which it is addressed. The message may contain information that is privileged, confidential and exempt from disclosure under applicable law. If the reader of this message is not the intended recipient, or the employee or agent responsible for delivering the message to the intended recipient, you are notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify Corax Networks immediately by email at Thank you.

Reply by email

Ales Katona
to Paul Davidson
Paul Davidson wrote 30 lines
If there compelling reason why type definitions cannot be included in class/object definitions? Make it mode FPC to keep folks happy :) Quite often a type is defined in INTERFACE part, but only used within class/object defined in same unit. 1) This means that type is public. This is not always good thing in OOese. 2) Unit must be specified in child's child's USE list. P Davidson Corax Networks Inc. http://CoraxNetworks.com IMPORTANT NOTICE: This message is intended only for the use of the individual or entity to which it is addressed. The message may contain information that is privileged, confidential and exempt from disclosure under applicable law. If the reader of this message is not the intended recipient, or the employee or agent responsible for delivering the message to the intended recipient, you are notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify Corax Networks immediately by email at Thank you. _______________________________________________ fpc-devel maillist - http://lists.freepascal.org/mailman/listinfo/fpc-devel

I second this request. Throw in const fields too..

Ales

Reply by email

Paul Davidson
to Micha Nelissen
unit aUnit;
interface
	type
		aType = ( at_First, at_aaa, at_bbb, at_Last );
		aObj = class
			aVar : aType
unit bUnit;
interface
	uses aUnit;
	type
		bObj = class( aObj )
unit cUnit
interface
	uses bUnit;
	type
		cObj = class( bObj )
implementation
	aVar := at_Last;   <----------- ERROR!

The implementation of cUnit requires a USE aUnit; in order to compile since at_last is no longer visible.

Micha Nelissen wrote 17 lines
On Sat, 4 Mar 2006 10:24:14 -0500 Paul Davidson wrote: > Quite often a type is defined in INTERFACE part, but only used within > class/object defined in same unit. > 1) This means that type is public. This is not always good thing in > OOese. > 2) Unit must be specified in child's child's USE list. Can you elaborate on the second point ? Micha _______________________________________________ fpc-devel maillist - http://lists.freepascal.org/mailman/listinfo/fpc-devel

P Davidson
Corax Networks Inc.
http://CoraxNetworks.com

IMPORTANT NOTICE: This message is intended only for the use of the individual or entity to which it is addressed. The message may contain information that is privileged, confidential and exempt from disclosure under applicable law. If the reader of this message is not the intended recipient, or the employee or agent responsible for delivering the message to the intended recipient, you are notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify Corax Networks immediately by email at Thank you.

Reply by email

Peter Vreman
to Paul Davidson: If there compelling reason why type definitions cannot be included in class/object…
Show quoted text 9 lines
If there compelling reason why type definitions cannot be included in class/object definitions? Make it mode FPC to keep folks happy :) Quite often a type is defined in INTERFACE part, but only used within class/object defined in same unit. 1) This means that type is public. This is not always good thing in OOese. 2) Unit must be specified in child's child's USE list.

It breaks code and is therefor incompatible. A type symbol is never searched in an object, class or record symtable.

Reply by email

Michael Van Canneyt
to Peter Vreman
Peter Vreman wrote 12 lines
> If there compelling reason why type definitions cannot be included in > class/object definitions? > Make it mode FPC to keep folks happy :) > > Quite often a type is defined in INTERFACE part, but only used within > class/object defined in same unit. > 1) This means that type is public. This is not always good thing in > OOese. > 2) Unit must be specified in child's child's USE list. It breaks code and is therefor incompatible. A type symbol is never searched in an object, class or record symtable.

At the most we could introduce a 'Private' type section in the unit interface section.

But even that is not needed, as you can perfectly solve the problems without it, just use a class factory and inheritance.

Michael.

Reply by email

Vincent Snijders
to Paul Davidson: unit aUnit; interface type aType = ( at_First, at_aaa, at_bbb, at_Last ); aObj = class…
Paul Davidson wrote 20 lines
unit aUnit; interface type aType = ( at_First, at_aaa, at_bbb, at_Last ); aObj = class aVar : aType unit bUnit; interface uses aUnit; type bObj = class( aObj ) unit cUnit interface uses bUnit;

I think some Pascal dialect have

   reuse bUnit;

Then all bUnit is used, pull the units in the interfaces uses clause.

Show quoted text 9 lines
type cObj = class( bObj ) implementation aVar := at_Last; <----------- ERROR! The implementation of cUnit requires a USE aUnit; in order to compile since at_last is no longer visible.

Reply by email