Just thought I would let you know...
http://www.malcolmgroves.com/blog/?p=476
Regards,
- Graeme -
_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/

Mailing lists / fpc-devel / 2009-08
23 messages · 6 people · –
Reply by email Subscribe to this list Your subscription
Read-only archive. Use j and k to move between messages.
Just thought I would let you know...
http://www.malcolmgroves.com/blog/?p=476
Regards,
- Graeme -
_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/
Graeme Geldenhuys wroteJust thought I would let you know... http://www.malcolmgroves.com/blog/?p=476
Hm
Website not accessible. Can you give us the gist of what is so interesting ?
Michael.
In our previous episode, Michael Van Canneyt said:
Has been hinted at several times, so I can make an educated guess:
The project is called exRTTI, and provides RTTI for nearly everything, weak linked to avoid bloating, and directives to indicate a non-weak (strong?) linking, in the case of plugin archs etc.
Hm Website not accessible. Can you give us the gist of what is so interesting ? Michael.
2009/8/16 Michael Van Canneyt :
Website not accessible. Can you give us the gist of what is so interesting ?
Weird. Anyway, I placed the web page content in a OpenDocument Text format available at:
http://opensoft.homeip.net/~graemeg/rtti_and_attributes.odt
Hope that helps.
Regards,
- Graeme -
_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/
Just thought I would let you know... http://www.malcolmgroves.com/blog/?p=476 - Graeme -…
Graeme Geldenhuys wroteJust thought I would let you know... http://www.malcolmgroves.com/blog/?p=476
This reminds me our previos discussion about property attributes: http://wiki.lazarus.freepascal.org/Property_attributes
Best regards,
Paul Ishenin.
Hm Website not accessible. Can you give us the gist of what is so interesting ? Michael.
In our previous episode, Michael Van Canneyt said:
I had that too, but later it worked. Now I've also seen the syntax, and I think sb should explain those Delphi devels that in C-like languages function modifiers come BEFORE the declaration, and in Pascal AFTER :-)
2009/8/16 Marco van de Voort :
I had that too, but later it worked. Now I've also seen the syntax, and I think sb should explain those Delphi devels that in C-like languages function modifiers come BEFORE the declaration, and in Pascal AFTER :-)
Very true! Now lets see what they say on the CodeGear newsgroups. :-)
Regards,
- Graeme -
_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/
2009/8/16 Michael Van Canneyt : Weird. Anyway, I placed the web page content in a…
It does, thank you.
However, it's not so spectacular:
Attributes are simply old .NET stuff they ported to Win32. Seems they had to use a workaround through an attribute class.
I never understood the need for it. RTTI is more than enough for 99.99% of the cases.
Michael.
In our previous episode, Michael Van Canneyt said:
Give the customer what he wants. And a customer doesn't know enough to show any restraint. More is always better, and if sb else has it, I also want it.
It does, thank you. However, it's not so spectacular: Attributes are simply old .NET…
2009/8/16 Michael Van Canneyt :
I never understood the need for it. RTTI is more than enough for 99.99% of the cases.
I agree 100%.
Regards,
- Graeme -
_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/
It does, thank you. However, it's not so spectacular: Attributes are simply old .NET…
Michael Van Canneyt wroteI never understood the need for it. RTTI is more than enough for 99.99% of the cases.
Imagine you have a db framework which maps delphi classes to database tables. It reads class properties from the rtti and creates db tables automatically.
For example:
TStudent = class(TPersistent)
published
property ID: Integer read FID write FID;
property Name: String read FName write FName;
property Age: Integer read FAge write FAge;
property Group: String read FGroup write FGroup;
end;How db framework can create a table based on this information? It needs some more info about field types, primary keys.
Now using attributes we can extend our class declaration:
TStudent = class(TPersistent)
published
[TDBField('Integer', 'primary key')]
property ID: Integer read FID write FID;
[TDBField('VarChar(100)')]
property Name: String read FName write FName;
property Age: Integer read FAge write FAge; // db field type can be
guessed from the property type here
[TDBField('VarChar(20)')]
property Group: String read FGroup write FGroup;
end;This is just one example. If you remember we thought to use property attributes for the LCL previously.
Best regards,
Paul Ishenin.
In our previous episode, Paul Ishenin said:
I know what .NET uses it for, but that was not the question.
The question is why does this have to be solved using a language construct? Why can't you simply register the Object-Relation mapping somewhere else?
What is the value of making it RTTI? Sure you can abuse RTTI to hang information on any identifier, and make a nice example out of it, but does that really display the requirement for RTTI?
I guess it's grouping information that belongs together. Like with OOP.
Jonas
Imagine you have a db framework which maps delphi classes to database tables. It reads…
But that needs to be registered separately anyway, because this varies on the storage back-end. The object-db mapping should never be in the object itself, that is bad design.
Michael.
Imagine you have a db framework which maps delphi classes to database tables. It reads…
2009/8/16 Paul Ishenin :
Imagine you have a db framework which maps delphi classes to database tables. It reads class properties from the rtti and creates db tables automatically.
tiOPF has metadata classes to do just this, but in both cases they work only well if you have quite simple design. Anything complex (and unfortunately my designs seem to be) those property -> db field mappings simply don't coupe.
I also have tables in by database, where one table contains information for various classes. I have to use tiOPF's hard-coded visitors, so I can manually implement the complex mapping and create/populate the correct classes from a single query.
But yeah, I guess for the general public they could have some uses. I haven't found a use for me though (not yet).
Regards,
- Graeme -
_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/
But that needs to be registered separately anyway, because this varies on the storage…
2009/8/16 Michael Van Canneyt :
But that needs to be registered separately anyway, because this varies on the storage back-end. The object-db mapping should never be in the object itself, that is bad design.
+1
And what about classes that can be stored in various backends? For example, in tiOPF the same class can be stored in CSV, Tab delimited, XML or any SQL DB - all with a compiler define or parameter to the , foreign keys and primary keys don't mean
anything to XML, CSV etc...
Regards,
- Graeme -
_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/
In our previous episode, Paul Ishenin said: I know what .NET uses it for, but that was…
Because it is a more natural way. I want to give full property declaration in a one place.
What is the value of making it RTTI? Sure you can abuse RTTI to hang information on any identifier, and make a nice example out of it, but does that really display the requirement for RTTI
Currently RTTI is very limited - using it you can only enumerate published members, learn their types and default values (for properties). Attributes completely eliminates limitations.
Best regards,
Paul Ishenin.
2009/8/16 Michael Van Canneyt : +1 And what about classes that can be stored in various…
That's what I meant with 'this varies on the storage back-end.'... :-)
Michael.
2009/8/16 Michael Van Canneyt :
That's what I meant with 'this varies on the storage back-end.'... :-)
I was agreeing with you. I simple wanted to explain it a bit clearer to other readers. Many always assume RDBMS are used - which is not always the case.
Regards,
- Graeme -
_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/
Because it is a more natural way. I want to give full property declaration in a one place.
2009/8/16 Paul Ishenin :
Currently RTTI is very limited - using it you can only enumerate published members, learn their types and default values (for properties). Attributes completely eliminates limitations.
Explain limitations? Surely you do not want any foreign class to query your private or protected fields? Hence you decide what is viewable by others, making them published. Plus, with the current RTTI you can ever execute published methods etc.. I fail to see what everybody always talk about when they say the RTTI limitations compared to Reflection?
An exact example would be very helpful. And the old "property mapping to database field" doesn't could, because that's a design preference and such mappings are not always appropriate or possible.
Regards,
- Graeme -
_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/
Graeme Geldenhuys wroteAn exact example would be very helpful. And the old "property mapping to database field" doesn't could, because that's a design preference and such mappings are not always appropriate or possible.
What I have in mind isn't quite an example but I'd like to voice a need I felt a many times over the years and attributes seem to fulfill it.
Some of these attributes would include 'help', 'copyright' and things like that.
I would use the attributes to display help for any property in the property editor in design time.
I.e. instead of having to read a help file, by pressing a button next to that property I'd see a popup explaining it.
The information provided in these 'help's could also be extracted to generate a help file too.
Same thing for 'copyright', of course, and similar to 'help' it would apply to the class as well as properties and code.
I'd like these to be keywords and similar XML (or like Pascal's 'begin..end') they would also have a closing tag/keyword; so that, for example, 'help_begin' would have 'help_end' as its closing tag/keyword.
Other attributes could be references to external systems such as databases. i.e. field mappings to databases.
While I would like these to be both designtime and runtime, with appropriate compiler swithces we could strip them out of final executable.
2009/8/16 Marco van de Voort : Very true! Now lets see what they say on the CodeGear…
Graeme Geldenhuys wroteVery true! Now lets see what they say on the CodeGear newsgroups. :-)
Oh boy - I got them throwing there toys out the cot again. :-) I should really stop doing that. ;-)
Regards,
- Graeme -
It does, thank you. However, it's not so spectacular: Attributes are simply old .NET…
2009/8/16 Michael Van Canneyt :
However, it's not so spectacular: Attributes are simply old .NET stuff they ported to Win32. Seems they had to use a workaround through an attribute class.
Yes you have to create a descendant of TCustomAttribute when you want to add any attribute to a class. I was curious as to who is responsible for instantiating that class and when does it get freed. It gets instantiated when you query with RTTI and you are responsible for freeing that class.
Here is some more information...
http://wings-of-wind.com/2009/08/17/rad-studio-2010-review-9-%E2%80%93-attributes-the-new-rtti-and-db-access/
Regards,
- Graeme -
_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/