-- Leo's gemini proxy

-- Connecting to republic.circumlunar.space:1965...

-- Connected

-- Sending request

-- Meta line: 20 text/gemini

Absolute Truth in programming languages


Is enforcing truthfulness the opposite of beauty?


Can 2 + 2 = 5?


Improvements, corrections, further contributions are welcome.


$ cat five.cpp
#include <iostream>
int operator+( int x, int y ) { return 5; }
int main() {
   std::cout << 2 + 2 << std::endl;
}
$ g++ five.cpp
five.cpp:2:29: error: ‘int operator+(int, int)’ must have an argument of class or enumerated type


$ python
>>> int.__add__ = lambda y: 5
TypeError: can't set attributes of built-in/extension type 'int'


$ cat five.hs
import Prelude hiding ((+))
x + y = 5
main = print ( 2 + 2 )
$ ghc five.hs && ./five
5


$ cat five.rb
class Fixnum
   def +(y)
       5
   end
end
print 2 + 2
$ ruby five.rb
5


$ mzscheme
> (define (+ x y) 5)
> (+ 2 2)
5


Originally posted at 2014-08-22 08:38:00+00:00. Automatically generated from the original post : apologies for the errors introduced.


original post

-- Response ended

-- Page fetched on Mon May 27 02:22:28 2024