Re: [Oopic-compiler-devel] Re: [oopic] Re: Oopic compiler issues - The low down.
Status: Planning
Brought to you by:
ndurant
From: Neil D. <nd...@us...> - 2004-05-06 02:31:56
|
> Dan Sandberg wrote: >> With the THEORETICAL syntax I was mentioning earlier, >> combined with the kinda of objects that the OOPic >> already supports, we could do something like this: >> >> background void activateSolenoid() { >> if ( button.pressed ) { >> solenoid = true; >> solenoidTimer = 5; >> solenoidTimer.operate = true; >> } >> } >> background void deactiveateSolenoid() { >> if ( solenoidTimer.operate and solenoidTimer == 0 ) { >> solenoid = false; >> solenoidTimer.operate = false; >> } >> } D. Daniel McGlothin wrote: > The more I think about Dan Sandberg's idea, I like it. > > The notation of 'background' as an attribute of the routine is essentially > what I was thinking of with my Delphi unit 'sections' approach. But what would "background" actually mean to the function? The OOPic can't execute these functions in the background, so it could be misleading. Are you suggesting that basically the above example would translate into an oWire and an oEvent, triggered by the button press? If so, then it's a nice idea, and cleans up the messy way you have to wire up oEvents. The thing I dislike about this syntax is that the use of "background" implies that the first statement in the function must be an "if", which seems a bit kludgey to me. Unless I'm misunderstanding you. Another alternative would be to use an "event table", which would work a bit like the message map system in MFC, if you've used MFC. Basically syntax along these lines (either transformed by preprocessor or within the compiler itself): EVENT_TABLE { LINK(button.pressed, activateSolenoid) } void activateSolenoid() { solenoid = true; solenoidT8mer = 5; solenoidTimer.operate = true; } ...which would link "button.pressed" to a function (oEvent handler) called activateSolenoid. The first parameter of the LINK macro would be an attribute of a named object. The problem is that translating stuff into oEvent handlers will only work if the "if" clauses can be easily converted into virtual circuits, and so the whole thing can operate in the "background". If the "if" clause relies on scripting language expressions, then it would be non-trivial to make it an entirely backgrounded piece of code. Neil -- Neil Durant <nd...@us...> |