According to coverage at
http://arstechnica.com/apple/reviews/2009/08/mac-os-x-10-6.ars/10
, Snow Leopard, the latest version of Mac OS X, added "blocks" to C.
The article illustrates this new language construct with the by-now
canonical ARM and home-grown-control-structure examples.
Hey, Java!
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 mai
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 woul
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
Fabrizio Giudici wrote:
> mbien wrote:
>
>> Hi Fabrizio,
>>
>> I 'll work on a JNI/GlueGen based OpenCL binding to Java as part of my
>> bachelor thesis. If everything works well it will be an optional
>> extension of JSR231 aka JOGL (and will also fully interoperate with
>> JOGL).
>>
>> ...ope
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 a
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 wrote:
> I think you misunderstood Roel. I am aware of the method name argument
> override, I was merely exploring
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 ne
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) app
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
variable
Hi Friends,
I need your help.
I have written this code to get the transliteration in Java. BUt it
gives me incorrect output for > 4 words...
<%@ page language = "java" %>
<%@ page import = "java.sql.*" %>
<%@ page import = "java.util.*" %>
<%@ page import = "java.io.*" %>
<%@ page import="jav
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
I've always been intrigued by these blocks we have in java, what does javac
actually generate for them? I'd always hoped that the closures proposals
might just start small and make these blocks a first class citizen.
From:
public void test() {
int foo = 1;
{
int bar = foo + 2;
}
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 va
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 member-wi
On Tue, Sep 1, 2009 at 5:44 PM, Mark Derricutt 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 void test() {
16 matches
Mail list logo