Hi!
I have a question concerning the use of units.
Consider this example:
(*****************) (** Queue.pas **) (*****************)
unit Queue;
interface
function isEmpty : boolean; {..}
implementation
{..}
begin {..} end. { Queue }
(**************) (* Test.pas *) (**************)
uses Queue;
begin {..}
if Queue.empty then writeln('Queue is empty!');
{..} end. { Test }
I expected to be able to use a "Queue." qualifier in front of the empty call in the test routine. But the compiler complains about an undeclared symbol Queue.
Is this a bug or a feature?
If the latter, how am I supposed to differentiate between the empty function of an Queue and a Stack, if not by using Queue.empty / Stack.empty?
Regards, Marc
Hi!
Marc van Woerkom wrote:
[...] if Queue.empty then writeln('Queue is empty!'); [...] I expected to be able to use a "Queue." qualifier in front of the empty call in the test routine. But the compiler complains about an undeclared symbol Queue.
Is this a bug or a feature?
This is a bug, or, a missing feature (qualified identifiers).
If the latter, how am I supposed to differentiate between the empty function of an Queue and a Stack, if not by using Queue.empty / Stack.empty?
You can declare objects `Queue' and `Stack' with a method `empty'. (Both can have a common abstract parent that exports a dummy virtual method `empty' that always returns `true', etc.:)
Hope this helps :-]
Peter
You can declare objects `Queue' and `Stack' with a method `empty'. (Both can have a common abstract parent that exports a dummy virtual method `empty' that always returns `true', etc.:)
Dang. That smells like BP OOP.
Brings me directly to the question what standard you are aiming for.
Seems like there are a lot:
- Standard Pascal (Jensen/Wirth or still different?) - Iso Pascal (seems to be a bit extended) - Turbo/Borland Pascal 2, 3, 4, 5, 6, 7, .. Delphi? - GNU extensions
And having read a bit through the Unit/Module issues, some features are overlapping.
Any plans to enforce certain behaviours with switches like the gcc -ansi switch?
Regards, Marc
Marc van Woerkom wrote:
You can declare objects `Queue' and `Stack' with a method `empty'. (Both can have a common abstract parent that exports a dummy virtual method `empty' that always returns `true', etc.:)
Dang. That smells like BP OOP.
It is BP-compatible OOP. ;-)
Brings me directly to the question what standard you are aiming for.
Seems like there are a lot:
- Standard Pascal (Jensen/Wirth or still different?)
- Iso Pascal (seems to be a bit extended)
GPC supports "ISO-7185 Standard Pascal (level 0 and level 1)" and large parts of "ISO-10206 Extended Pascal".
- Turbo/Borland Pascal 2, 3, 4, 5, 6, 7, .. Delphi?
BP7, with some few Delphi extensions.
- GNU extensions
Yes. Lots of.
And having read a bit through the Unit/Module issues, some features are overlapping.
Yes. See the online documentation or the ISO Standards themselves (a link is on our home page).
Any plans to enforce certain behaviours with switches like the gcc -ansi switch?
There are already such switches:
--standard-pascal-level-0 --standard-pascal --extended-pascal --borland-pascal
See: info -f gpc -n "Pascal Dialect Options"
Peter
GPC supports "ISO-7185 Standard Pascal (level 0 and level 1)" and large parts of "ISO-10206 Extended Pascal".
Yes. See the online documentation or the ISO Standards themselves (a link is on our home page).
Someone (at Slashdot?) uses to quote Tanenbaum:
"I like standards, there are so many to choose from"
Will try to find out and poke a bit on this one:
--standard-pascal
Thanks for the references! Marc