I use to always put my SQL code in specific files, because I came from ugly
Oracle SQL preprocessor where SQL and code where mixed like hell (JSP files
are the same BTW).
But, today I prefer Named Queries and/or JDBC 4.
I use to declare my ORM mapping and my Depency Injection in a separate XML
On Thu, Sep 3, 2009 at 01:53, Jess Holleje...@ptc.com wrote:
You don't embed this sort of thing. You use getResourceAsStream() and a
separate file along with MessageFormat or such to perform substitutions
of live data if need be.
Plain and simple.
Yup. Good idea. So you've now maximally
Hmm...
I've never really had an issue with simply doing
My string is really really really really really really really really
really +
really really really really really really really really really really
really really +
really really really long.
The extra 's and +'s are a non-problem in my
tell me how the compiler could possibly sort this out? The only way is
for the compiler to hand off the entire process of TOKENIZING this
stream to the DSL provider for 'longString', which is an entirely
different architecture - right now all java parsers do the fairly
usual thing of
Casper: I don't think you grokked my point.
I'm saying it's impossible to build any java, vanilla or otherwise,
that can handle this. For the reasons I stated: You'd have to flip the
architecture upside down and resolve 'DSL' properly midway through
tokenizing it. Be aware that this
The issue goes a little deeper than your simple use case though. The
Java enterprise world, due to the lack of expression trees, has to
work with many thousands lines of embedded DSL (JPQL/HQL/SQL etc.).
This poses several problems:
- How do you format/indent it?
- How do you copy-paste between
Hi,
or just do it like html does it...
@DSL(lang=Brainfuck) {
/*
++[
+-]++.+.+++..+++.++.+++
..+++.--..+..
*/
}
javac ignores the comment, preprocessors like projectlombok.org could
do whatever they want with the comment (convert to
Casper Bang wrote:
The issue goes a little deeper than your simple use case though. The
Java enterprise world, due to the lack of expression trees, has to
work with many thousands lines of embedded DSL (JPQL/HQL/SQL etc.).
This poses several problems:
- How do you format/indent it?
- How
Annotations are the recommended way however, as it facilitates
validation. If you use em.createQuery(...) everything is late-bound
and even less type checked than using a namedQuery. For SQL though,
you are absolutely right but sadly SQL is no longer considered trendy.
/Casper
On 3 Sep., 01:53,
For ARM-blocks you can have a look at the @Cleanup annotation of
Lombok and have ARM-blocks for Java right now!
The following code will close both streams correctly after they run
out of scope.
import lombok.Cleanup;
import java.io.*;
public class CleanupExample {
public static void
The neat thing about this is that we do not have to wait until the
Java API has been retrofitted with the Disposable interface. However,
you won't get the scope limitation benefits (the in and out variable
is scoped the whole method). I kind of wish we could use annotations
on blocks, so this
Caster, that is not entirely correct. The close methode (actually,
close is just the default, you can specify an other method name if you
want) will be called when the variable goes out of scope.
Unfortunately, java does not allow an annotation on a code block. So
an equivalent programm would be:
I think you misunderstood Roel. I am aware of the method name argument
override, I was merely exploring the different implementations and
implications of these two ARM blocks. The JDK7 version would have to
rely on a new interface Disposable being added to the libraries, as
the abomination known
Casper,
You are correct. I just wanted the other readers to know that it is
not limited to close. It is however limited to no-args methods.
Roel
On Sep 1, 4:10 pm, Casper Bang casper.b...@gmail.com wrote:
I think you misunderstood Roel. I am aware of the method name argument
override, I was
I actually prefer @Cleanup to the JDK 7 proposal in that it presumably
just cleans up at the end of the variable's scope ala C++.
If you need ordering amongst several @Cleanup variables, then you can
always introduce {...} scoping, right? If so, then I'd rather introduce
such things only as
True, but I don't think many are aware of this. The JDK7 proposal by
Joshua Bloch specifically adds the multi-scoping aspect over the
existing C# implementation, which only allows multi-scoping of the
same type.
Constructs that minimizes variable leakage into scope space (temporary
variables)
Yes, you can scope to your hearts content with {} blocks. For those
not aware of this:
There's a rarely used feature of the java language: separate blocks.
You can put { (statements) } anywhere in java code where a statement
is legal. Like any other occurrence of {} to delimit code, any
Casper Bang wrote:
True, but I don't think many are aware of this.
Hmm I've used {...} liberally for scoping in Java and C++ since I
first used C++. It's one reason I consider C unusable even compared to
C++'s and despite C++'s sins.
The JDK7 proposal by
Joshua Bloch specifically adds
for local variables, javac actually does almost nothin:it only frees
that local variable slot for a future local variable
theres a nice puzzle about that in the java specialists newsletter:
http://www.javaspecialists.eu/archive/Issue173.html
of course youre not suppose to know its about local
Don't know what happens underneath, but they appear to be parsed by
the production rule Block - {Statement*} and have the Tree node
associated with a com.sun.tools.javac.code.Scope hashtable that's
special in that they can be nested. That would make sense I guess,
going the other way, a
On Tue, Sep 1, 2009 at 5:44 PM, Mark Derricutt m...@talios.com wrote:
I've always been intrigued by these blocks we have in java, what does javac
actually generate for them?
Not much. It just reuses slots. But don't take my word for it
~/test$ cat Test.java
public class Test {
public
21 matches
Mail list logo