[fpc-devel] Differences between 'tsym' and 'tdef'

Joost van der Sluis joost at cnoc.nl
Fri May 18 12:16:43 CEST 2012


On Fri, 2012-05-18 at 11:31 +0200, Sven Barth wrote:
> Am 18.05.2012 09:49 schrieb "Joost van der Sluis" <joost at cnoc.nl>:
> > Also not. (I know, it is strange behavior. But there are more
> strange
> > things, as there is no type-checking in attributes. It seems like
> they
> > just hacked this together rather quickly...)
> >
> 
> You mean typechecking regarding the constructor arguments? Would it be
> possible to add this?

I think I can. But in Delphi you can also give a non-exsisting
attribute, ie:

  TMyClass=class
  private
    FName: string;
  published  
    [TThisTypeIsNowhereDefined('You','Can','Enter','Anything','here'1)]
    property Name: string read FName;
  end;

This will compile in Delphi, but it won't work. This is especially
annoying if you forgot to add the unit in which
TThisTypeIsNowhereDefined is defined. In that case it will also compile,
but it will not work. And you will seek for that error for long. I
know. ;)

> Another note: does Delphi allow/support attributes in interfaces? If
> so you need to check that GUIDs are handled correctly (AFAIK they can
> also be string constants instead of "naked strings")

I started my implementation by copying the part where interface GUID's
are parsed, so I already took care of that. (But it's simple: interfaces
do not support attributes)

Joost




More information about the fpc-devel mailing list