Invariant in BOOLEAN_REF

3 messages Options
Embed this post
Permalink
Alexander Kogtenkov [ES]-2

Invariant in BOOLEAN_REF

Reply Threaded More More options
Print post
Permalink
Hi,

The current invariant in BOOLEAN_REF has a clause

    involutive_negation: (not (not Current)) ~ (Current)

When evaluated outside the class BOOLEAN it results in False,
because "not" returns BOOLEAN and the type of Current is not
BOOLEAN.

What is the best way to fix the issue? I can see two approaches:

1. Change the signature of "not" to return "like Current" instead of "BOOLEAN".
2. Change the class invariant clause to look like
    involutive_negation: not (not item) = item

The first approach is more general, but may require somewhat smarter code generation.
The second one is simpler, but changes the original class invariant.

Any comments?

Thanks,
Alexander Kogtenkov

------------------------------------------------------------------------------
_______________________________________________
freeelks-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freeelks-devel
Eric Bezault

Re: Invariant in BOOLEAN_REF

Reply Threaded More More options
Print post
Permalink
Alexander Kogtenkov wrote:

> Hi,
>
> The current invariant in BOOLEAN_REF has a clause
>
>     involutive_negation: (not (not Current)) ~ (Current)
>
> When evaluated outside the class BOOLEAN it results in False,
> because "not" returns BOOLEAN and the type of Current is not
> BOOLEAN.
>
> What is the best way to fix the issue? I can see two approaches:
>
> 1. Change the signature of "not" to return "like Current" instead of "BOOLEAN".
> 2. Change the class invariant clause to look like
>     involutive_negation: not (not item) = item
>
> The first approach is more general, but may require somewhat smarter code generation.
> The second one is simpler, but changes the original class invariant.
>
> Any comments?

Personally I'm in favor of keeping the result type of all
boolean operations to be BOOLEAN.

--
Eric Bezault
mailto:[hidden email]
http://www.gobosoft.com

------------------------------------------------------------------------------
_______________________________________________
freeelks-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freeelks-devel
Alexander Kogtenkov [ES]-2

Re: Invariant in BOOLEAN_REF

Reply Threaded More More options
Print post
Permalink
Eric Bezault wrote:

> Personally I'm in favor of keeping the result type of all
> boolean operations to be BOOLEAN.

Then we have the following possibilities:

     involutive_negation: not (not item) = item

     involutive_negation: not (not Current) = item

     involutive_negation: (not (not Current)).item = item

The first and the last one work for both "BOOLEAN" and
"like Current" type of "not", so I would avoid the second one
that works only when the type of "not" is BOOLEAN.

Alexander Kogtenkov

------------------------------------------------------------------------------
_______________________________________________
freeelks-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freeelks-devel