A database query language built right into the program.
Tokens like "SELECT" and "INSERT INTO" could be changed to "SEL" and
"PUT" to make it more concise. (I've always found SQL too much like
COBOL - large silly reserved words that get in the way).
The "array of const" parameters would have to be sorted, tokenized, and
possibly some lightly parsed. Handling an "array of const" cleverly
means one can still make use of strong typing in pascal. This has some
similarities to parameterized queries or TDataset ideas.
By placing some sort of built in array of const query language into a
"module", it means that this special ability of FPC is stored in a
library and not in the compiler code base.
--Disadvantages of Array of Const Idea--
1. it is only a theory, I haven't tried it.
2. the abuse factor of it. forgive that for a moment
3. how to handle all the possible errors of bad array of const params
4. reminds me of Lisp, Ruby "domain specific languages" they call them
5. the 'quotes' add some noise here and there
Once someone gets a hold of these bag of tricks, they might obfuscate
their programs with all sorts of silly hacks, and we might all end up
like Paul Graham.. bragging about how FPC is better than all other
--Advantages of Array Of Const idea--
A built in mini language would be bound to a real language. Kind of like
how fpMake is powered by a real language, and not a poor gnu make style
limited language. This analogy isn't quite exactly what I'm trying to
get across.. but you might understand what I mean. One has the full
power of a strongly typed language.. pascal.. and also his built in mini
query language too. Not "either or" as in separate languages!
Verbose ugly concatenated SQL strings in our code aren't so type
safe..This array of const idea remains type safe and hides details from
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".
// F: File Of DataRec;
DB: Table of DataRec; // aka a RelVar
Query(DB, SELECT, 'foo', FROM, 'bar');
Crazy? Well even Write and WriteLn may have seemed crazy at one time -
the revolutionary idea to introduce the "File" and "Text" data types
into a language like pascal, instead of sticking with old Algol ideas..
may have seemed crazy. Give it some slack. Files are a poor storage
systems for data. Times have changed - people thought up object
relational mappers, TDataset, and languages such as Tutorial Dee. So
keep an open mind.. and do tell if you have better ideas.
Daniel and Michael were worried that those ideas from Atanas Atanassov
could bastardize the pascal language or the system.pp unit. I would be
worried too. Hence why some creative ideas are offered in this email
that would place a query language into a module. Or, a new innovation
like a File Of Record/Table Of Record type.
> 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".
> // 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.