I don't see any problems. You have to import Thread to get synchronized in your scope. Thread will not compile if synchronized is made a keyword, but that is easy to fix with #pike.
/ Martin Nilsson (Åskblod)
Previous text:
2003-02-05 15:38: Subject: synchronized
Well, I think it would be unfortunate if it blocks using "synchronized" as a keyword or metaprogram in the future. I'd like something like this:
class X { synchronized (store_mutex) { mapping store = ([]); int last_id = 0; }
int add (mixed data) {
synchronized (store_mutex) { store[++last_id] = data; return last_id; } }
mixed get (int id) {
// This generates a compile time or runtime error: store is // accessed without holding store_mutex. return m_delete (store, id); } }
But it's not necessarily true that a Thread.synchronized has to interfere with this.
But this would work as implicit-lock creator too, so I think it's nice and does what you want<tm>:
Do you mean an implicit mutex creator? If so, do you actually think it's such a gain to not have to write the mutex declaration that it's worth the risk of silently getting more mutexes than you really want? To me it seems like a variant of the BASIC style implicit variable declarations.
/ Martin Stjernholm, Roxen IS