psychoslave / englishest

A Ruby gem which allows a more literate coding style
MIT License
0 stars 0 forks source link

If possible, make `non-` a strict equivalent of the unary boolean prefix negation `!` #7

Open psychoslave opened 2 years ago

psychoslave commented 2 years ago

Strict here would especially mean "must respect the same precedence", unlike for example the not operator:

not true && false # true
!true && false # false

So the expected implementation would allow the following:

untruth = false
non-untruth # true
reality = true
non-reality # false
non-reality && untruth # false

The most obvious implementation would be to have a non global variable, as identifier to the singleton Negator class whose ::- method would take a single topicargument and return !topic. But of course in Ruby, naming a global variable non won't be possible, the closest achievable thing that can be implemented are to use $non as identifier, or create a non method on Kernel or BasicObject that would return Negator.

psychoslave commented 2 years ago

Relevant resources include: