L schrieb:
A creative idea:

--Another idea--
Remember the "file of Record" innovation in pascal?

Table of Record...

A "file of record" allows one to remain strongly typed. What about a "DatabaseTable of Record".

var
 // F: File Of DataRec;
 DB: Table of DataRec; // aka a RelVar


We do something similar with our dbGonzales Database engine with standard pascal code. The tables are typed and have coresponding interface classes in oo-pascal. A table can hold any of the subclasses of its baseclass. If you access a "record" you get automatically the corresponding interface class and can use its methods.

A small demo to visualize this is here http://www.db-gonzales.de/download/GDemo.zip. The demo draws objects (circle, line, rectangle, ellips) stored in database and animates them (or adds new). If you start more instances of the demo, you can see what the other instance is doing with the objects.

If you look at the source of the demo, you can see, that it is also possible to write queries with pascal notation, which are already checked at compile time - but I must admit, that this a little bit clumsy.

       qy:= TGdfFilteredTableOp.Create(tb, [],
TfComp.New(tb.BaseClass.FieldByName('ParentID'), TvVariant.Val(Null), [cvEQ]));

could also be written as:

       qy:= TGdfFilteredTableOp.Create(tb, [],
TfComp.New(TPaintObject(tb.BaseInterfaceClass).ParentID, TvVariant.Val(Null), [cvEQ]));

and is the same as:

       qy:= TGdfFilteredTableOp.Create(tb, [],
           'ParentID is null' );

which is better readable.


So my opinion is - we don't need to change pascal to achieve things like that, it's already in the language

Cheers, Adrian.

p.s: The information on the webpage about the database is outdated - i haven't found the time to write a documentation.
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to