Suggested enhancement
- Posted by JEFF ZEITLIN <jeff.zeitlin at EXECNET.COM> Apr 17, 1997
- 1080 views
I had previously made a suggestion for something equivalent to BASIC's "CHAIN" statement; several people gave some quite useful suggestions as to how roughly equivalent functionality could be implemented. I have been using them, with acceptable results (though I still think a CHAIN would be marginally better). Today, however, inspiration walked up behind me and whacked me upside the head with a two-by-four, which leads to an Idea that I think, if implemented, would be quite a nifty (dare I say "elegant") enhancement to Euphoria: Allow a procedure/function call "execute" (or something along those lines) which takes a sequence of characters forming valid Euphoria statements, and returns whatever executing those statements results in - or nothing at all, if there's no return value in the statements. This would allow: 1. A CHAIN facility - read a Euphoria program text into the variable foo, then "execute(foo)". 2. A macro facility for any Euphoria program - let the user define macros using Euphoria, and any interface that the program author feels is best for the purpose, then "execute(macrovariable)". 3. A procedural parameter capability - you could write highly generic routines without needing to redefine procedures or functions for (for example) comparisons. "function sort(fooseq, compareproc) ... if execute(compareproc) = -1 then ..." 4. A dynamic code facility - since "includes" are idempotent, and cannot be done except at the absolute top level of the program, there's no simple way of defining what gets done "on the fly" such that you can have the Euphoria-knowledgeable user instruct you as to how to handle unforseen situations, and be able to implement those solutions immediately (i.e., without shutting down and restarting the program). "while 1 do ... userproc = ... execute(userproc) ..." Comments? Questions? Discussion? ========================================================================= Jeff Zeitlin jeff.zeitlin at execnet.com --- ~ OLXWin 1.00b ~ I have seen the future and it is now the past.