I have several constraints on an object of my meta-model but for some of them, the invariant should be evaluated only if another invariant was evaluated positively (didn't produce an error).

In fact, I first evaluate certain condition and if they are not fulfilled, I don't want to evaluate another invariant (it doesn't make sense in the situation).

Is it possible to do something like that ?

Thanks,

Cédric]]>

No, but thanks for reminding me of this use case.

A previous discussion suggested a special dependency syntax. After a bit

more thought it seemed that making a constraint available as a

property/operation would allow a dependent constraint to be written as

inv SimpleConstraint: ...

inv ComplexConstraint: SimpleConstraint implies ...

you could do this manually now by

def checkSimpleConstraint() : Boolean = ...

inv SimpleConstraint: checkSimpleConstraint()

inv ComplexConstraint: checkSimpleConstraint() implies ...

which argues for no change needed. Just requires a smarter evaluator to

do a little Common Subexpression Elimination to detect the dependencies.

Enhancement request raised as

https://bugs.eclipse.org/bugs/show_bug.cgi?id=401786.

Regards

Ed Willink

On 26/02/2013 13:11, Cedric Moonen wrote:

> Hello,

>

> I have several constraints on an object of my meta-model but for some

> of them, the invariant should be evaluated only if another invariant

> was evaluated positively (didn't produce an error). In fact, I first

> evaluate certain condition and if they are not fulfilled, I don't want

> to evaluate another invariant (it doesn't make sense in the situation).

>

> Is it possible to do something like that ?

>

> Thanks,

> Cédric]]>

Thanks for your quick reply, as usual

I could indeed have an additional operation returning a boolean checking the simple constraint.

Thanks,

Cédric]]>