This is the mail archive of the
java-discuss@sourceware.cygnus.com
mailing list for the Java project.
Re: JvSynchronize nitpick
- To: Paul Fisher <pnfisher at redhat dot com>
- Subject: Re: JvSynchronize nitpick
- From: Tom Tromey <tromey at cygnus dot com>
- Date: Mon, 27 Mar 2000 19:05:37 -0800 (PST)
- Cc: java-discuss at sourceware dot cygnus dot com
- References: <y68wvmnesq3.fsf@idoru.labs.redhat.com>
>>>>> "Paul" == Paul Fisher <pnfisher@redhat.com> writes:
Paul> For JvSynchronize, why not make `synchronized' a macro (or
Paul> slightly name mangled) that expands into the current
Paul> JvSynchronize syntax?
I don't know. It was this way when I started working on it.
One problem is choosing a variable name.
Paul> So C++ code would look like:
Paul> { synchronized (OBJ); CODE; }
Paul> which is more in line with the Java syntax.
We could even play some trick using "for" and a helper object to let
us write code like this:
synchronized (foo)
{
...
}
(untested, with poor names)
class helper
{
JvSynchronize sync;
int count;
helper(obj) : sync (obj), count (0) { }
operator bool () { return count == 0; }
helper &operator++ () { ++count; return *this; }
}
#define synchronized(Object) for (helper x (Object); ! x; ++x)
That might be too magical, not to mention slow.
Tom