Re: embedding java code in auto generated code

"Joachim Durchholz" <joachim_d@gmx.de>
25 Feb 2001 11:00:41 -0500

          From comp.compilers

Related articles
embedding java code in auto generated code rblasch@web.de (2001-02-01)
Re: embedding java code in auto generated code eeide@cs.utah.edu (Eric Eide) (2001-02-04)
Re: embedding java code in auto generated code joachim_d@gmx.de (Joachim Durchholz) (2001-02-25)
| List of all articles for this month |

From: "Joachim Durchholz" <joachim_d@gmx.de>
Newsgroups: comp.compilers
Date: 25 Feb 2001 11:00:41 -0500
Organization: Compilers Central
References: 01-02-020
Keywords: Java
Posted-Date: 25 Feb 2001 11:00:41 EST

Hmm... I hope this isn't too late (I'm still working on my backlog), but
anyway, here goes:


Ronald Blaschke <rblasch@web.de> wrote:
>
> I would like to embed some java code blocks in automatically generated
> code:


The simple answer is Don't Do This.


You can achieve the same effect by making an abstract class with
"execute" as its sole abstract member, then derive from it.


There's a general problem with embedded code of this type: "execute"
will access any available data in a rather uncontrolled way, so you'll
have trouble if you ever want to modify the frameword surrounding
"execute". This problem will be there regardless of whether you use a
code generator or inheritance. Well, in Java there's a slight
advantage for inheritance: you can make members private so they aren't
accessible to "execute", so at least these remain open to framework
evolution. The problem is to decide what should become private, but
that's a general problem of OO...


However, there is one massive advantage to the inheritance approach:
it will spare you parser writing, parse and run-time error handling,
documentation of your tool, and keeping up with the changes in the
Java language/compiler/libraries.


Regards,
Joachim


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.