[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Exception with multiple irritants
From: |
Maxime Devos |
Subject: |
Re: Exception with multiple irritants |
Date: |
Sun, 8 Jan 2023 18:31:02 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.5.1 |
On 25-11-2022 01:03, Zelphir Kaltstahl wrote:
ice-9/boot-9.scm:1685:16: In procedure raise-exception:
ERROR:
1. &contract-violated
2. &message: "contract violated"
3. &origin: bla
4. &irritants: (> foo 10)
5. &irritants: (> 10 10)
I don't understand this -- (> 10 10) is always false, no? I would
interpret such an error message as 'you can't call this procedure at
all, it requires a contradiction to hold'. What's the purpose of (> 10
10) here? I guess 'foo=10'?
If you want to include the value of 'foo', this can be made more
explicit, e.g.:
4. &unsatisfied-constraint: (> foo 10)
5. &argument: foo, 10 (i.e. this &argument condition has two fields)
That would avoid the vague '&irritants' -- I mean,
A base type used for storing information about the causes of
another condition in a compound condition.
is rather vague, it could refer to 'the condition causing this
condition', or the values of the arguments, or some property of those
arguments, or ...
~~~~
Nice! Now I have the value of `foo` in this case as well and that could
be
useful information in cases, when I get a violated contract unexpectedly.
However, having irritants twice seems a bit weird. Is this something,
that is safe to do? Something expected and probably unchanging in future
versions of GNU Guile? Or does it merely work by chance?
I could always make another exception type like
"exception-with-irritant-values"
or something and use that, instead of a second "with irritants" call.
I don't know if having multiple instances of the same condition type
inside a single condition is supported.
However, given that &irritants is plural (instead of a singular
&irritant), and the documentation also mentions 'causes' (plural!):
A base type used for storing information about the causes of
another condition in a compound condition.
... why not make the value of &irritants a list, e.g.:
> 1. &contract-violated
> 2. &message: "contract violated"
> 3. &origin: bla
> 4. &irritants: ((> foo 10) (> 10 10))
Greetings,
Maxime.
OpenPGP_0x49E3EE22191725EE.asc
Description: OpenPGP public key
OpenPGP_signature
Description: OpenPGP digital signature