String literals in Java 7: version 1.2

rssh at rssh at
Wed Mar 18 12:54:56 PDT 2009

> Hi All,
> 2009/3/18  <rssh at>:
> [snip]
>> Complex case:
>> Create special syntax for template processing inside strings - I guess
>> this can be a library issue.
>> We have jsr223. May be good ideaa is adding helper methods, which
>> process
>> string via choosed language interptreter, i.e.
>> ═s.scriptEval("velocity",binding);
>> ═.... but - from other side ═we can't receive binding between names and
>> values automatically for now.
> Not sure that a library would work, can you give an example of the
> call you propose?

Example of such call can be:

binding = new Binding();

 <?if ($x==$y) {?>
 <? } else { ?>
 <? } ?>

If PHP is avaible via JSR223 API, then string will be evaluated to A or B.
Or, if you does not like PHP, you can use velocity or java.

But creating binding by hands (first 3 strings of test) kill all :(

>From other side, in principle compiler can generate binding for local
variables automatically, so in principle it is possible to create 'magic
annotation', to write code like:

int someMethod();
int x=1;
int y=2;
Binding binding;

String s = """
 <?if ($x==$y) {?>
 <? } else { ?>
 <? } ?>



(I think about formalizing and submitting such proposal, but not sure that
it is possible correct define one in short terms.)

More information about the coin-dev mailing list