Here is my combination of a lot of other people’s ideas and a few of my own into what I believe is a rather consistent proposal, that would meet everybody’s needs and desires (at least, so far as not go much against other people’s).
First off, I think that the one real invariant I’ve seen for the use of ! in computer languages, is that the result is a boolean (or whatever the accepted values for true/false are, i.e. t and (), or 1 and 0, or true and false, etc.). I guess that’s why making ! to also be a bitwise operator seems so wrong to me.
The current definition makes ! not very useful, it’s only defined for Bool, Function, and Missing.
(The third one concerns me a bit, does it make sense that !missing is missing? Is that supposed to be for 3VL?)
So, my proposal:
& becomes and and ∧, and it could be freed up for something else (I have an idea for that!), and could even still be used for a Boolean only non-short circuiting AND, which then makes .& make sense on arrays of booleans.
| becomes or and ∨, and could then be used for piping, maybe.
$ has already become xor and ⊻ (note the nice visual consistency between the Unicode or and xor
)
~ (unary) becomes not and ¬, freeing up both unary and binary ~.
! could be used in a nice generic fashion with a lot of types:
! on an Integer would work as in other languages, and return true for 0, false for non-zero (i.e. the same as iszero, but much shorter), and of course would still work as always on Bool. It could also be used to like in Lisp, for isempty. !s on an AbstractString would then be the same as isempty(s) or (s == "") (that would have saved a lot of typing in my Strs.jl package!!!)
I think that having it as a generic operator that means iszero, isempty, isnull etc. would make sense, be very useful, and people would catch on to the meaning very quickly (just as they have with the use of && and || in Julia for short conditions, like isempty(foo) && break
Lastly, & would be free, and after I read Stefan’s comment (on GitHub?) that they hadn’t thought of any other use for it, I then remembered a very common use for it, in what was one of the most popular languages in the world - and it does match the semantic meaning of “and”, if I say I have foo and bar, well then, maybe that makes foobar! So then "foo" & "bar" means string concatenation, just as all those Basic versions out there.
(Waiting now for the tomatoes ![]()
![]()
to be thrown! ![]()
)