"multi morphic" classes
BCS
BCS at pathlink.com
Thu May 1 15:07:37 PDT 2008
I'm working on a compiler and have run into a bit of a design challenge.
The issue is that I want to be able to manipulate a number of aspects of
the compiler at run time so that command line switches can turn on and
off a number of different features. For example, modified lookup rules
or auto typing of function returns.
This is somewhat complicated by the fact that I want to have the bulk of
the code be unaware of the features that can be turned on. This is
because I want the default behavior to be to function as a standard
compiler and the the feature to implement extensions. However I want the
standard portions of the code base to, as much as practical, be
independent of the extensions.
One way I have thought of to do this would be to implement the AST node
types using the default behavior but at runtime construct the AST with
nodes of types that are modified copies of the base types. This would be
done by having each extensions be implemented as a derived types and
then, at runtime, construct new v-tbls that have selected methods
replaced with the derived type methods. Then this would be used in the
construction of nodes.
This would give a sort of "dynamically created" type. I think I could
hack together a (highly non portable) implementation but would rather be
able to do it within the bounds of the language. I have no idea what the
syntax for this would be though.
thoughts ideas?
More information about the Digitalmars-d
mailing list