> Do you have examples here?

There are several use-cases I often see.

1. The task is to allow declaration of some container structure (vector, tree, 
etc.)
The mechanism to create it must have enough flexibility to define/parametrize 
at compile-time in one go:
- keys are integers in 0..N-1 only or any type supporting equality testing. 
  That user decision should influence container code and its manual code 
optimizations, e.g. special cases like indexing, appending/removing/etc.
- are keys always sorted? => influences insertion, search, etc.
- values are primitive types (not having destruction phase - just dealloc) or 
it should call Finalize/Free/"Assign nil" on destroying.
- if values are records - all accessors should return pointers instead to be 
able to modify fields without "read, modify, write" ceremonies.
- does structure generate events on insertion/deleting/etc? => influences event 
property declarations + actual code to trigger those
- what kind of interface user prefers for the container - class, record, 
interface with reference counting or any combination of those?
- all its generic functions like map, filter, destructive map, etc. should be 
overloaded functions existing both as structure methods and free form (globals 
with additional argument). Their argument should accept all kinds of callbacks 
- simple functions, methods ("of object" type), nested ("is nested") and 
possibly future "reference" (closure FPC does not support yet).
- grow strategy - user-defined, with given coefficient, etc.

... currently all above is generated using m4 producing entire FPC module. 
That's old times philosophy - structures amount is small, functions to work 
with them are numerous and coherently named. Something similar to C++ STL, but 
without exponential build times and more tailored to users' needs.

2. Meta declarations for global entities with names/ids/descriptions/etc. 
The mechanism to create it must have enough flexibility to define/parametrize 
at compile-time in one go:
- create Pascal native declarations as enums
- create Pascal functions to convert to/from strings/integers/etc
- create overloaded serialization functions for XML, streams, etc.
- create foreign code declaration (C, Lua, etc.)
- native Pascal foreign code marshalling (e.g. Pascal <-> Lua via Lua stack)

3. Dynamic libraries exports.
The mechanism to create it must have enough flexibility to define/parametrize 
at compile-time in one go:
- compile in Pascal "generics" / m4 templates to support other processes / 
languages
- exported functions should accessible via specific foreign import (e.g. it 
should generate corresponding header files for use in C/C++)

4. Published functions/classes/ into interpreted languages
- just declare which classes and their methods should be accessible e.g. from 
Lua and code should generated for make it happen.
- FFI import/export - declare functions / types / names - get boilerplate to 
make it happen.


That's more or less it. 
At least those I quickly gathered from real project.

-- 
Regards,
Denis Golovan
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to