PROPOSAL: Language Escape Operator

Reinier Zwitserloot reinier at zwitserloot.com
Thu Mar 26 20:35:25 PDT 2009


The problem then is: When does the special magic end?

If there is no end, then this is no different from a 'language'  
indicator at the top.

I am very much in favour of editing a vanilla java AST that involves  
lots of sugaring, but I don't think such an operator is neccessary or  
even useful for it; all those backticks would become mighty ugly fast.  
Also, because you're doing AST editing, those backticks aren't  
anywhere on disk, so they become a keystroke to indicate: The next few  
things I'm going to type are definitely intended as non-java sugar  
that you should java-ize for me.

Two things come to mind:

1) That's what cmd/ctrl/alt is for. Typing a backtick on most keyboard  
is very difficult; I'd rewire a cmd+something to generate it instead,  
easier on the fingers.

2) *any* IDE that is going to do this correctly also needs to know all  
about java. Therefore, if an IDE can only handle up to java6 (+AST- 
based sugaring), and you want to type something java7, which so  
happens to also be legal sugaring, then - that's only a minor pain.  
You can't use java7 in this IDE, it doesn't know the syntax. It's  
unfortunate that this AST sugar now needs to find another syntax, but  
isn't that part of the point of AST sugaring? Ease of switching  
around? I really doubt any kind of AST sugaring system is going to  
make 'start with a backtick' a prerequisite.


  --Reinier Zwitserloot



On Mar 27, 2009, at 04:13, brucechapman at paradise.net.nz wrote:

> 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