Skip to content

Junctions with comparisons - or why is != meta #319

@2colours

Description

@2colours

!= appears to behave like a meta-operator construction with junctions which results into confusing semantics ("all elements aren't equal to $n" turns into "not all elements are equal to $n" !); while other comparisons like > have their non-meta counterparts (like <=), I don't see anything similar for == (or eq, for that matter).

There seems to be some discrepancy with the semantics of junction comparisons and the implementation adds to it.
so all(1,3) > 2 #False
so all(1,3) <= 2 #False
In these cases, it seems like the semantics is "for all elements listed, the substitution results into a True value".

However
so all(1,3) == 3 #False
so all(1,3) != 3 #True!
The last line seems to contradict this semantics - indeed, it doesn't hold for all values that they aren't equal to 3. What does hold, though, is that not all of them is equal to 3... Actually, we don't have to play this guessing game:
all(1,3) != 3 #True
It collapsed the junction straight away.

It seems to me != is implemented using the ! meta-operator so eventually all(1,3) != 3 is the same as !(all(1,3) == 3). This behavior can be replicated by using !> instead of <=.

I think it's arguable whether this behavior of the ! meta-operator is reasonable at all - the bigger problem is that != is THE negation of == and we don't really have much choice or control over this meta-behavior, unlike in the case of > where we can use an equally "real" operator as the negation of it, without collapsing the junction.

Metadata

Metadata

Assignees

No one assigned

    Labels

    languageChanges to the Raku Programming Language

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions