alternative aliases [Re: [fpc-devel] Re: [fpc-pascal] Re: Ideas for namespace implementation]
fpc at mfriebe.de
Tue Jul 27 12:35:13 CEST 2010
On 27/07/2010 10:20, Alexander Klenin wrote:
> On Tue, Jul 27, 2010 at 02:27, Martin<fpc at mfriebe.de> wrote:
>> uses Foo in 'lcl' alias 'FooLCL', Foo in 'RTL' alias 'FooRTL'
> I think this is a reasonable idea, with the following caveats:
> 1) I think both aliases and namespaces should be identifiers, not strings
> (i.e. quotes are unnecessary distraction).
ok, by me
especially for the namespace (see the wiki page too), it solves the
uses Foo in 'LCL'; // a folder called lcl, in the project
uses Foo in LCL; // the namespace
alias without quotes is sensible too.
> 2) I think that namespace-like syntax is preferable, i.e.
> "LCL.Foo", not "Foo in LCL"., additionally, I do think it would do no harm
> to let programmer use "namespaced" unit without alias.
yes and no:
a) "in" is already established
b) ok, but this must only be allowed in the uses clause.
In the uses clause the dot as no ambiguity . In the source it can have
(see many earlier mails)
In the source, the unit should only be known by either it's name, or
if aliased by it's alias only.
Both alternatives could be allowed, they do not conflict.
Unless in $Mode Delphi, the dot will at some time be used in delphi
> 3) Finally, after a slight variation of syntax to avoid extra 'alias' keyword,
> we arrive at the following proposed syntax:
> FooLCL=LCL.Foo, RTL.Foo;
possible => but not my favourite
rather shorten "qalias" to "as"
uses LCL.Foo as LCLFoo
The beauty of the alias is, that the pascal source remains pascal, and
not a new form of java or C
also RTL.Foo.proc is ambigious.
there could be a
class procedure proc;
> which is quite similar to already existing 'alias' feature for types:
yes, but if you do the above uniot namespace with dot in source, you
could also read this as
unit TFoo, procedure Create(); // in namespace RTLUnit
uses RTLUnit.TFoo; RTLUnit.TFoo.Create();
More information about the fpc-devel