RES: [fpc-pascal] dot within unit file name
Vinzent Hoefler
JeLlyFish.software at gmx.net
Mon Jan 21 08:05:53 CET 2008
On Friday 18 January 2008 20:12, John Stoneham wrote:
[Ada package system]
> However, you can also do:
> with Unit_1; use Unit_1;
> This imports the namespace of Unit_1 into the current file so that
> now you *can* refernce "foo" without a qualifier. It's as if all the
> identifiers in Unit_1 were defined in the current file (and so yes,
> you can get conflicts).
Yes, and that's what "uses Unit_1;" in Pascal does. The only difference
between Pascal and Ada is that Ada complains about ambiguities (same
identifier in different modules) while Pascal's "scope model" just uses
the identifier from the last used module (while you're still able to
overwrite that behaviour by prefixing the identifier just like you're
required to do in Ada in case of ambiguities).
So, the only difference is that Ada plays it safe and complains about
ambiguities while a Pascal compiler tries to resolve the ambiguity by
itself (and sometimes fails in a horrible way - I still remember the
issue I once had, when I just reordered the "used" units and without
changing any code, the application suddenly started crashing, because
it used a different "DisposeStr" then. BTW, that's one of the reasons
why I always use prefixed notation in Pascal now, just like I do in
Ada).
(As written before, this explanation is more from a user's point of view
than from the view of a compiler writer.)
Vinzent.
More information about the fpc-pascal
mailing list