From: Jason Gorman (email@example.com)
Date: Wed 29 May 2002 - 09:13:15 BST
If it's a boolean expression shouldn't it be something along the lines of exception.oclIsTypeOf(DepositException) ? Jason Gorman Independant Consultant firstname.lastname@example.org +44 7785 712367 ----------------- Original message follows ----------------- Date: 28/05/2002 - 5:08 p.m. (UTC) From: Brian Smith <email@example.com> To: firstname.lastname@example.org Subject: Re: OCL: dealing with exceptions Anneke Kleppe wrote: > The current status of OCL 2.0 is that it is aligned with the UML 1.4. > As soon as the UML 2.0 submissions stabilize, we will align OCL 2.0 > with UML 2.0. As the core of the UML 2.0 is to be the core of the MOF > 2.0 also, the alignment of OCL with MOF follows. > > Now to answer your question: no there is currently no explicit support > in OCL 2.0 for these MOF exceptions. There might be later on, if > during the alignment this proves to be an important issue. > > BTW, you say you are expecting it, but there have not been any > requests to the OCL submission team to include this. Please tell us, > if you want something in. We are only human, you know. :-) Well, I think it seems useful to be able to specify directly, in the postcondition for an operation, what exceptions will be thrown under what circumstances. In particular, I think that you would want to be able to type-check something like this: context Bank:deposit(x : int) post: if x > 0 then balance = balance@pre + x else raised DepositException end if The type-checker would type this postcondition as "boolean" since, if it returns anything at all, it will return a boolean (like in ML). Your examples type-check to boolean too. But, what if you want to say this (admittedly, a contrived example): context Bank::deposit(x : int) post: let with-interest = if x >= 0 then x * sqrt(x) else raised DepositException end if in balance = balance@pre + with-interest Now, interest(x) has to type-check to a rational number. But, it isn't clear to me how, using any approach, how I can express with-interest in a type-safe manner. Even without the above, the examples cited still seem very awkward to use in practice, compared to something like "raised" above. I think users of UML/OCL would want a "raised" facility in OCL, especially for languages like Java where exceptions are as much a part of the postconditions as normal returns (i.e. you want to distingush between "undefined behavior" and "exception XXX raised"). Perhaps the specifics of such a construct are difficult to specify though? Thanks, Brian To remove yourself from this list please mail email@example.com with a message containing the word "unsubscribe".