[spec] New idea about Error Management
Mildred
ml.mildred593 at online.fr
Mon Sep 1 16:20:46 UTC 2008
Hi,
This month, I just had an idea about a system to make error management
semi-automatic in Lisaac.
Why? I think I explained it during the workshop, bt to be brief, manual
error management is painful and add a lot of overhead to the source
code. And we can't do without error management. My goal is to arrive at
a point where even clone could send an error (if there is not enough
memory, a case we should handle).
First, during the workshop, I had just a small idea, I don't know if it
is a good idea or not, but:
receiver.slot_that_can_throw_an_error parameter
on_error { + reason:ERR;
// Handle error
};
But, I didn't started this email to talk about this, now the real idea
begins:
* First of all, imagine that you change every statement like this:
local_variable.slot param.slot param.slot param;
into:
tmp1 := local_variable.slot param;
tmp2 := tmp1.slot param;
tmp3 := tmp2.slot param;
You can notice that all the receivers of these statement are local
variable (not slots) and this is the important thing, because we are
going to use these local variables.
* Each of these local variables is associated with an error code of
type ERR (which is an enumerated type).
* You can access this error code in both reading and writing the
following way:
local_variable.Error // reading the error code
local_variable.Error := ... // writing
* Imagine that ERR.is_ok is a special code that signifies that there is
no error. This is also the default value of any ERR.
* Now, if a message is sent, the error code associated with the
variable used as receiver is checked:
If there is no error (receiver.Error = ERR.is_ok):
- This is as usual, the message is sent.
if there is an error (receiver.Error ≠ ERR.is_ok):
- The message is not sent !
- The variables that may have been assigned to the return value of
the message are not assigned, and their error code is set to the
error code of the receiver.
- If the message took BLOCKs as parameter, and if these BLOCKs
modify local variable defined earlier in the function, these
local variables take the error code of the receiver
* A message can fail. When a message fails, it return error codes along
with its results. There is an error code per variable returned.
* If a message returns a VOID, then even if there is no returned
variable, it can return an error. The syntax to do so is to add as a
return value:
Error (<exporession:ERR>)
* In order to be able to check errors on VOID messages, there is the
possibility to use the following syntax:
<expression>.Eror
instead of:
local := <expression;
local.Error
That's all.
There are just two flaws I identified:
* Errors on VOID returning messages are not automatically enforced.
That may or may not be a problem
* I just discovered it: if the return value of a message is directly
assigned to a slot (not a local variable) the error is discarded.
Possible solution: for such cases, an error code is associated with
the slot only for the lifetime of the function. But still ...
Mildred
--
Mildred Ki'lya
Site: <http://mildred632.free.fr/>
XMPP: <mildred at jabber.fr> (GoogleTalk, Jabber)
GPG: 197C A7E6 645B 4299 6D37 684B 6F9D A8D6 [9A7D 2E2B]
More information about the Lisaac-devel
mailing list