www.digitalmars.com         C & C++   DMDScript  

D - new control structure

reply "DeadCow" <deadcow-remove-this free.fr> writes:
Here is just an idea.

Consider the following code :

lock.acquire();
doSomthing();
lock.release();


acquire & release are tightly related : when you call one, you *must* call
the other. There is many other exemple of that : acquiring a connection from
a connection pool, thread from a thread pool, notify to the system that you
start painting an area then notify that it's over, transactions ...

What about something like that :

interface Acquirable {
    void acquire();
    void release();
}

and this controle structure :

acquire( Acquirable ) {


    // here Aquirable is released.
}



acquire( lock ) {
    doSomething();
}


Well ... i dont know if it's realy usefull.

-- Nicolas Repiquet
Aug 01 2003
parent "Mike Wynn" <mike.wynn l8night.co.uk> writes:
somewhere back in the archive there is something from me about this
using a templated auto class
I wanted

instance foo(T).obj OBJ;
with( auto new OBJ(p) ) {
}

rather than
{
    auto OBJ obj(p);
}

allowing any type of acquire/lock via a simple template.

"DeadCow" <deadcow-remove-this free.fr> wrote in message
news:bgesvf$1fq8$1 digitaldaemon.com...
 Here is just an idea.

 Consider the following code :

 lock.acquire();
 doSomthing();
 lock.release();


 acquire & release are tightly related : when you call one, you *must* call
 the other. There is many other exemple of that : acquiring a connection
from
 a connection pool, thread from a thread pool, notify to the system that
you
 start painting an area then notify that it's over, transactions ...

 What about something like that :

 interface Acquirable {
     void acquire();
     void release();
 }

 and this controle structure :

 acquire( Acquirable ) {


     // here Aquirable is released.
 }



 acquire( lock ) {
     doSomething();
 }


 Well ... i dont know if it's realy usefull.

 -- Nicolas Repiquet
Aug 01 2003