|
|
Tim Attwood <tim### [at] comcastnet> wrote:
> Yeah, IMO it'd be OK to continue suporting the "#command parameter"
> syntax for 4.0 scripting control structures. A #parse command probably
> wouldn't have parens, just quote delimited strings, string identifiers, or
> functions returning a string (like concat).
The main problem with parsing a string as SDL is not a syntactical one,
but related to implementation, especially if and when the new SDL will be
byte/JIT-compiled.
There's a reason why eg. C++ and Java don't support parsing strings and
interpreting them as C++ or Java. Even many interpreted scripting languages
don't have any parse function because it may not be quite trivial to
implement in them. The current SDL is a good example of this.
I don't know too much about scripting language interpreters and compilers,
but I can easily imagine a string parsing function being a nightmare to
implement properly. For example, a string could define a new function which
must then be callable from outside the string. This means that you are
creating new functions on the fly, during execution and can't create the
interpreter/compiler so that it just creates a static set of functions.
The string might define new types which should then be usable from the
outside, so the interpreter/compiler must somehow dynamically create
information about new types during runtime, as they are created. This
can easily make the interpreter/compiler much more complex than it would
otherwise be.
Of course it also means that the byte-compiler and the bytecode interpreter
cannot be independent and separated, but must be married together, as the
bytecode interpreter may need to call the byte-compiler. This effecively
makes it impossible to make a virtual machine which only interprets bytecode,
without a compiler.
Of course I'm not saying this is impossible. As far as I know, for example
PHP byte-compiles the program before interpreting it, *and* it also has an
eval() function, which effectively parses a given string as PHP code. So it's
definitely possible. Just not trivial.
--
- Warp
Post a reply to this message
|
|