PROPOSAL: Language Escape Operator

brucechapman at paradise.net.nz brucechapman at paradise.net.nz
Thu Mar 26 20:13:33 PDT 2009


Quoting Reinier Zwitserloot <reinier at zwitserloot.com>:

> Isn't it easier to do this with a keyword?
> 
> Right at the top of your java file (after all, a non-java language 
> would work at least on CompileUnits, if not entire Modules/Packages/ 
> directories), put something like:
> 
> language groovy;
> 
> some sort of guarantee by java, in the vein of your proposal, that 
> java will never make:
> 
> language (anything-but-"java", literally);
> 
> legal. That's not to say that "language java;" at the top WOULD be 
> legal, just that "language foo;" at the top would NEVER be legal.
> 
>  --Reinier Zwitserloot
> 

I think you misunderstood the intent( or I have misunderstood you - either way -
my fault). 

It is NOT about mixed language applications at the file level (file extensions
do a fine job of that), but about having mixed content within a single source
file, down to the granularity of statement and expression level and possibly
even finer.

The point is that a tool can interpret the language escape operator and do
something different with the content. By the time it get to the compiler the
language escape operator should have disappeared because the java compiler
doesn't handle mixed language files. That's why I describe the behaviour as
raising a compiler error.

Many of the other coin proposals define themselves purely as a syntax and
desugaring of that to more verbose java code. Such desugarings can done as a
view element within an IDE (and code folded back to the sugared form in the view
- the model is still bulk standard Java). This proposal offers a low impact
indicator to the IDE that what follows is something that is not Java, so please
treat it specially (for example by recognizing the syntax and desugaring).  That
is one use of a language escape.

Another slant:

JSP embeds java code within XML so that various parts of a web page can be coded
with an appropriate syntax. That doesn't need a java language escape character
because the java is inside the XML and XML itself and the JSP schema defines
which bits are java. But if you invert that model and want to put something that
isn't Java inside something that is primarily Java, then the escape operator is
the mechanism that the code author and tool can use to indicate and detect the
start of the non java stuff. 


For further background check out my bog
http://weblogs.java.net/blog/brucechapman/archive/2009/03/meta_coinage_ro_1.html

and the slides from my JUG presentation
http://weblogs.java.net/blog/brucechapman/archive/JUG%20Aug%202008%20Mark%20II%20Pecha%20Kucha.ppt

And if you have Netbeans, try out the proof of concept module (reference at end
of proposal) for using a language escape operator to do properties. I really
must do one of those sexy screencast thingies showing that plugin in use so that
people don't need to install it in order to experience it. Geertjan can you help? 

Apologies if I am not doing a good job of getting this concept across.

Bruce




More information about the coin-dev mailing list