[fpc-devel] FPC implementation of attributes for language parts.

Sven Barth pascaldragon at googlemail.com
Wed Apr 13 11:19:47 CEST 2016


Am 13.04.2016 09:42 schrieb "Maciej Izak" <hnb.code at gmail.com>:
> Michael Van Canneyt really doesn't like them :) :

I don't like their use for this either. For their intended purpose, namely
to decorate types or properties I have no complains (aside the syntax, but
that's a different topic).

> If attribute is used you already know that it has more "flag idea" (by
analogy to RTTI attributes, anyway it does not have to be just like a
flag), as in our example presented in "Initialize/Finalize management
operators and Default intrinsic" topic - is more visible whole context.
Introducing many new keyword is the waste and can collide with existing
keywords.
>
> I don't want the language with thousands of keywords, some things can be
delegated to attributes. *That helps to keep main language more clear*.
>
> Usage of attributes is more readable than mix of many keywords (it
depends of context ofc). I think in many areas it is matter of taste. Of
course is possible to implement new keywords, but
> *the main idea of using attributes for syntax elements is to omit
explosion of new keywords*... Just imagine this as attributes for nodes of
compiler. Pure theory:
>
>   // open mp - attributes way
>   [OmpParallel]
>   begin
>     [OmpFor]
>     for i := 1 to 10 do
>       WriteLn(i);
>   end;

And this is something I'm strongly opposed to and which is exacty the
orthogonality Michael was talking about. Attributes are supposed to be
related to the RTTI, but adding them to blocks or fors does not extend any
RTTI, because there is none to begin with! And that is where this whole
thing stinks!

> FINAL COMPROMISE: is good to allow selected attributes for Delphi
compatibility (in Delphi mode only) for example to allow usage of [ref].
I'd like to run my Generics.Collections in Delphi too :). No big deal:
>
> procedure Foo([ref] const X: TFoo);
>
> can be interpreted just like:
>
> procedure Foo(constref X: TFoo);

Then just use an ifdef then.

That "[ref] const ..." Is even more an abomination than the attribute
syntax itself already is.

> or in the future:
>
> [Volatile] FRefCount: Integer;
>
> can be interpreted like:
>
> FRefCount: Integer; volatile;

Variable/field access is always volatile anyways.

Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20160413/f4a6082e/attachment.html>


More information about the fpc-devel mailing list