programming languages - Generating strings and executing them as programs during runtime -
this tough question word , i'm not sure proper term (if any). i'm curious languages allow "build up" string during program execution, , execute part of program. language know of allows snobol.
reading wikipedia entry tcl however, sounds may able also?
i thought nifty feature if may not used much. thanks.
ps: tag snobol, spitbol, don't have reputation create new tags.
i'm curious languages allow "build up" string during program execution, , execute part of program.
look languages support eval, or, more generally, runtime meta-programming. pretty every language supports eval (even strongly, statically typed languages haskell). many runtimes built languages implemented via bytecode interpretation (such lisp-like languages, erlang or java) support ability insert new (byte)code @ runtime. once can insert new code dynamically, can write eval, or "monkey patching".
even in language implementations without specific support full meta-programming, or dynamic linking, there ways dynamically generate code under programmer control, either via reflection mechanisms or code generation support libraries (such llvm).
beyond simple one-stage eval, more generally, languages support multi-stage computation allow generation of programs 1 stage next, arbitrary numbers of stages, making possible safely, arbitrarily nest evals.
to quote taha, who's thesis on multi-stage programming models introduces of theory.
program generation powerful , pervasive technique development of software. has been used improve code reuse, product reliability , maintainability, performance , resource utilization, , developer productivity
the languages you're looking provide 3 primitives, in form or another:
- delay
- splice
- run
for delaying computation 1 stage (e.g. quoting fragment string), splicing running program, , executing fragment (in lisp, back-quote, comma, , eval).
lisp , eval
- mccarthy, john, history of lisp, sigplan not. 1978. -- introduces
eval
generalizing eval multi-stage programming
on multi-stage programming:
- taha, multi-stage programming: theory , applications
- nielson, flemming , nielson, hanne riis, two-level functional languages, -- introduced 2-level languages.
- taha, walid , sheard, tim, multi-stage programming explicit annotations -- simple operators support runtime metaprogramming techniques.
giving types multi-stage programming
formal descriptions of multi-stage computation quite tricky, , involve unusual techniques (for programming languages) modal logic.
giving types meta-programs:
- wickline, philip , lee, peter , pfenning, frank , davies, rowan, modal types staging specifications run-time code generation.
security issues
the trickiness of formalzing semantics of multi-stage programming explains why they're confusing systems work with, , why eval can open many security concerns: becomes unclear code executing when, , data being turned code. getting name capture 1 stage next tricky, leading code injection attacks. such complexity doesn't security.
Comments
Post a Comment