www.digitalmars.com         C & C++   DMDScript  

D - Cover handler for a statement or a block of statements.

reply Vincent Risi <vincent.risi gmail.com> writes:
I would like to suggest a method for defining code statement
covering. Some examp1es of a cover are as follows :-
  - try ... finally - this is defined in dotnet as a using
  - try ... (catch)+
  - cursor save and display others ... restore saved cursor

a possible syntax

  cover Hourglass(Application &app)
  {
    Cursor save = app.cursor;
    app.cursor = HOURGLASS_CURSOR;
    ~ code ~
    app.cursor = save;
  }

usage could be something like

  mixin(Hourglass(application))
  {
    ...
  }
Jun 05 2011
parent Robert Clipsham <robert octarineparrot.com> writes:
On 05/06/2011 13:03, Vincent Risi wrote:
 I would like to suggest a method for defining code statement
 covering. Some examp1es of a cover are as follows :-
    - try ... finally - this is defined in dotnet as a using
    - try ... (catch)+
    - cursor save and display others ... restore saved cursor

 a possible syntax

    cover Hourglass(Application&app)
    {
      Cursor save = app.cursor;
      app.cursor = HOURGLASS_CURSOR;
      ~ code ~
      app.cursor = save;
    }

 usage could be something like

    mixin(Hourglass(application))
    {
      ...
    }

You should re-post this on digitalmars.D.learn - this newsgroup is unused. -- Robert http://octarineparrot.com/
Jun 05 2011