Arc Forumnew | comments | leaders | submitlogin
5 points by rntz 5202 days ago | link | parent

That's a bad idea. Not because it is intrinsically wrong, but because it leads to a bad habit, namely, using an operator whose meaning depends upon the type of the thing you are applying it to.[1] In this case, you're making the meaning of ~ change on non-function objects. Suppose you're writing a function 'foo, one of whose arguments is 'x. Then:

a) foo might call ~x on an argument. Then you want ~x to mean what it does currently. But x need not be a function -- it could be a hashtable, since hashtables can act as lookup-functions, or a list. So suddenly ~x is simply incorrect.

b) foo might not care whether x is a function or not; but then you can't use ~x on it, because then if you pass in a function for x to foo, it will behave incorrectly. But if you accustom yourself to using ~x to mean (no x) when x isn't a function, you might accidentally write ~x when you really do mean no.x.

Admittedly, both of these can be avoided through careful programming, but the point of ssyntax is as a convenient abbreviation for common operations, to avoid even the minimal cost of parsing parentheses and a function name when using them. This totally defeats the purpose.

[1] Note that this is different from, but can overlap with, polymorphism, where the implementation of the operator you are applying depends upon the type of the object. The meaning of an operation and its implementation can be separated; an example polymorphic operation which has the same meaning is addition: addition of integers, of floating-point numbers, and of vectors of integers are all implemented differently, but mean the same thing. An example of meaning-non-preserving polymorphism is the use of the left-shift operation on a stream in C++ to print an object to it.



1 point by garply 5201 days ago | link

Thanks for taking the time to dissect the downsides of what I'm increasingly convinced is a bad idea. I agree with your reasoning, particularly with regard to the scenarios involving hashtables and lists.

Nonetheless, variable negation is something I imagine we all encounter with relative frequency, what do you guys think of a negation symbol equivalent to "no." (i.e., ¬)?

Since "!" is used elsewhere, "^" strikes me as a natural choice, probably because I associate it with set complements for POSIX regular expressions.

-----