Wednesday, December 10, 2008

Enhancing Java: multiline strings and un-escaped strings

Here's my initial proposal for enhanced String handling in Java that I would like to implement as part of the Kijaro project, which is an experimental fork of OpenJDK where Java hackers can try out new language features that they feel are missing.

Any comments are welcome!

Link to Google Doc with the specs:
http://docs.google.com/View?docid=d36kv8n_32g9zj7pdd

Quick teaser:

String sql = """
SELECT col1, col2, col3
FROM Table1
WHERE col1 = 'Test'
AND col2 = ?
ORDER BY col1""";




7 comments:

Jarek Andrzejewski said...

Why don't use @"....." syntax, like in C#. @" seems much simpler than multiple double quotes...

Jacek Furmankiewicz said...

yeah, but we want tohandle multiline too..and @ is already reserver for annotations (like [] attributes in C#)

Anonymous said...

I'm all about multi-line strings. But how is the leading whitespace handled? Included in the string? Stripped in some fashion a la javadoc?

If we want to strip it a la javadoc, which uses * as a begin-line indicator, perhaps we can use a single double-quote for each line beginning? It would require escaping double-quotes to begin lines but it would help with the leading whitespace issue.

Just a thought.

Jacek Furmankiewicz said...

Anonymous, this is already (partially) described in the document (as per the YAML specs).

On the Kijaro mailing list, there was a suggestion to handle it the way Python does it and that's probably what we will agree too.

https://kijaro.dev.java.net/servlets/ReadMsg?list=dev&msgNo=79

bertvanbrakel said...

+1 for something along these lines. I've been wanting to have this for ages.

I like the triple double quotes as its quite natural and already used elsewhere in java land.

How would we handle content with multiple doubles quotes as part of the content, like in wiki markup? Should the rule be that the closing triple quotes be on a line all by itself?

Also like the idea of being able to specify a custom DSL though not sure about the approach yet.

Could we also add in support for named parameters in the string parsing. The current index based printf is a step forward but eyeball unfriendly.

Anonymous said...

Ultima Online Gold, UO Gold, crestingwait
buy uo gold
buy uo gold
buy uo gold
buy uo gold
buy uo gold
buy uo gold
buy uo gold
buy uo gold
buy uo gold
buy uo gold
lotro gold
wow gold
warhammer gold
buy aoc gold
buy aoc gold
buy aoc gold
buy aoc gold
buy aoc gold
buy aoc gold
buy aoc gold
Age of Conan Gold, AOC Gold

Anonymous said...

When I begin to play this Seal Online game, I first go to buy seal online cegel to buy some my favorite and beautiful clothes to dress up my character. I have spent cheap seal cegel to buy my favorite cloth. I mean we have anime and some necessary seal online cegel based games that do not look really kid dish. Though I will admit with my own seal cegel I went crazy on leveling with DECO. Some of the skills that we can use our sealonline cegel to improve to look amazing, and are fun to just watch honestly.