String literals in Java 7: version 1.2 (original) (raw)
Howard Lovatt howard.lovatt at iee.org
Wed Mar 18 15:41:30 PDT 2009
- Previous message: String literals in Java 7: version 1.2
- Next message: Embedded expressions in string literals.
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
I don't see your binding proposal as an improvement over what we have got for many use cases, that is not to say that it isn't valuable as an API. It is an API for string processing and therefore should be a suggested library change; not part of coin. The string literals with expressions and your API proposal would be complementary, particularly if they had similar syntax. Also see a formal proposal for embedding expressions into strings on coin, it is called Proposal: Embedded Expressions for String Statements and is from Stefan Schulz.
2009/3/19 <rssh at gradsoft.com.ua>:
Hi All,
2009/3/18 <rssh at gradsoft.com.ua>: [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(); binding.put("x",x); binding.put("y",y); """ A B """.evalScript("PHP",binding); 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; @GenerateVariableBinding Binding binding; String s = """ A B """.evalScript("PHP",binding); System.out.println(); } (I think about formalizing and submitting such proposal, but not sure that it is possible correct define one in short terms.)
This email has been scanned by the MessageLabs Email Security System. For more information please visit http://www.messagelabs.com/email
- Previous message: String literals in Java 7: version 1.2
- Next message: Embedded expressions in string literals.
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]