[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Support for Meta-Programming
At 02:46 PM 11/12/98 +0800, acken@informatik.uni-kl.de wrote:
>> From: hartmut Goebel <hartmut@oberon.noris.de>
>> Date: Thu, 10 Dec 1998 23:25:04 +0100
>>
>> Michael van Acken (Michael.van.Acken@de.uu.net) schrieb:
>>
>> >Oberon variables don't need to be initialised AFAIK.
>>
>> Except for poiners when using a GC.
>>
>> >As long as `Ref' does not include stack frames, adding such
>> >meta-programming support to OOC (or oo2c) is possible.
>>
>> Meta-Programming w/o acces to the stack frames is rather worthless
>:-(
>
>Why? Inspecting stack frames is a very minor application of such a
>`Ref' module. You would still be able to inspect all of the heap and
>global variables.
>
>Of course, if you see `Ref' as a tool for exception handling or a
>debugger, then you are lost. Otherwise `Ref' is incredibly useful.
I agree. Refs are still very useful.
The Blackbox framework uses meta-programming extensively for things like:
- Embedded SQL commands (Hartmut already gave an example of this),
- Mapping dialog controls onto program variables. This allows you to
construct intelligent controls that automatically behave appropriately
according to the type of program variable that are attached to. This
allows, to an extent, any program variable to be treated as a model in the
"Model-View-Controller" sense. For example, a function of the Refs system
might be to send notifications when a variable has been changed (via Refs,
of course). I don't know of any systems that actually do this, but it would
be a novel way to implement MVC.
- Dynamically naming handlers in sub-systems. For example, when you open a
communication stream, you specify the protocol as a string. This is then
mapped onto a module name; via meta-programming the named module is used to
create an object of the appropriate type.
BTW, even if it is not possible to access local variables, it would still
be possible to produce a backtrace that gives you the names each function
in the call-stack. This would still be very useful for debugging purposes.
- Stewart