Kaz Kylheku ha escrito: > Kay Schluehr wrote: > > Juan R. wrote: > > > A bit ambiguous my reading. What is not feasible in general? Achieving > > > compositionality? > > > > Given two languages L1 = (G1,T1), L2 = (G2, T2 ) where G1, G2 are > > grammars and T1, T2 transformers that transform source written in L1 or > > L2 into some base language > > L0 = (G0, Id ). Can G1 and G2 be combined to create a new grammar G3 > > s.t. the transformers T1 and T2 can be used also to transform L3 = (G3 > > = G1(x)G2, T3 = T1(+)T2) ? In the general case G3 will be ambigous and > > the answer is NO. But it could also be YES in many relevant cases. So > > the question is whether it is necessary and sufficient to check whether > > the "crossing" between G1 and G2 is feasible i.e. doesn't produce > > ambiguities. > > See, we don't have this problem in Lisp, unless some of the transfomers > in T1 have names that clash with those in T2. That problem can be > avoided by placing the macros in separate packages, or by renaming.
Or simply namespacing! foo from package alpha --> alpha:foo foo from package beta --> beta:foo But what composition of different languages? E.g. LISP and Fortran in the same source. > In > In the absence of naming conflicts, the two macro languages L1 and L2 > combine seamlessly into L3, because the transformers T are defined on > structure, not on lexical grammar. The read grammar doesn't change (and > is in fact irrelevant, since the whole drama is played out with > objects, not text). In L1, the grammar is nested lists. In L2, the > grammar is, again, nested lists. And in L3: nested lists. So that in > fact, at one level, you don't even recognize them as being different > languages, but on a different level you can. > > The problems you are grappling with are in fact created by the > invention of an unsuitable encoding. You are in effect solving a puzzle > that you or others created for you. -- http://mail.python.org/mailman/listinfo/python-list