Discovered that this operator is undefined by default, since β is, it should also be defined. We should probably take a pass through all defined operators that have a naturally symmetric pair and make sure that they have the appropriate definitions.
Does it make sense to define β if you can get the same thing with β and a reverse order? Blah blah blah properly factored functions blah blah blah
As much as it makes sense to have >
even though you could write everything with <
.
Isn't there an issue for lowering things like EXPR1 β EXPR2
to let x = EXPR1, y = EXPR2; y β x; end
; or perhaps I'm misremembering?
As much as it makes sense to have > even though you could write everything with <
Does it?
Isn't there an issue for lowering things like
EXPR1 β EXPR2
tolet x = EXPR1, y = EXPR2; y β x; end
; or perhaps I'm misremembering?
This would be an alternative general solution.
Does it?
Are you proposing that we get rid of the >
operator?
Well it's something I've pondered, anyway
Not being able to write a > b
would be really annoying. It would be better to do the lowering thing where a > b
is lowered to the moral equivalent of b < a
.
I wrote the definition for β, β, β
before your comments, so might as well share it here even if the general solution suggested above seems nicer than having
β(l, r) = issubset(r, l)
β(l::Set, r::Set) = !β(l, r)
β(l::Set, r::Set) = <(r, l)
for each operator with a mirrored counterpart.
If it helps, I can put up the WIP PR for β, β, β
in a bit, once the tests finish running. /edit: see link below.
You can't do this with lowering if you want to have both <
and >
available as first-class functions. We already have the definition >(x, y) = y < x
, along with a note that new types should implement <
.
This isn't a matter of proper code factoring, just notational convenience.
One could always make >
a shorthand for (args...)->(<)(reverse(args)...)
everywhere βΒ then it would be possible to use it as a first-class object as well, but then you might as well just provide that as a default definition and let people provide a new definition of the want.
That definition wouldn't have a splatting penalty?
notational convenience
I'm not too invested here, but I can't think of an example where >
is more convenient than <
pop!(A) > pop!(A)
?
Clever. Though I'm not sure that's the clearest way to write that code.
last_one = pop!(A)
second_to_last_one = pop!(A)
second_to_last_one < last_one
At risk of taking this question too seriously, sort(x, lt = <)
vs. sort(x, lt = >)
?
sort(x, lt = <, rev = true)
?
Or even:
reverse(f) = (a, b) -> f(b, a)
sort(x, lt = reverse(<) )
And perhaps you get tired of writing reverse(<)
, and want a short name for it. If only there were a standard symbol for that.
If only there were a standard symbol for that.
β(<)
?
Certainly everything can be expressed with just <
. Similarly, we can express all control flow constructs with gotos. Minimalism is not the end goal, just a sometimes-useful heuristic. People like to use both <
and >
in mathematical notation, and we're interested in making it easy to just transcribe mathematics in a way that matches the original text βΒ excluding >
does not help that.
Julia enables and eases communication of computational ideas among humans; imo, pair accordingly.
Closed by #21469
Most helpful comment
And perhaps you get tired of writing
reverse(<)
, and want a short name for it. If only there were a standard symbol for that.