Feb. 9th, 2014

juan_gandhi: (VP)
...with Comp Sci PhDs that do not understand category theory but are trying hard to come up with some "science", because they have to. It all mostly looks pretty ridiculous.

just got it

Feb. 9th, 2014 07:38 pm
juan_gandhi: (VP)
In 2009 James Iry wrote about Nothing type in Scala: http://james-iry.blogspot.com/2009/08/getting-to-bottom-of-nothing-at-all.html

I got the idea eventually

If you have an empty class, it is the initial object (aka bottom); and in OOP there's probably no way to even express the idea.

Kind of obvious, right? Null has a value, hence it is not an initial object (Daniel Spiewak probably meant something else); anything that has a value is no good.

Void is not a good candidate either, but it could be, if it were not owned by Java.

scala> def nothingness: Nothing = {println("This is nothingness");throw new RuntimeException("byte me")}
nothingness: Nothing

scala> def vacuum:Void = {println("you are in space, char!"); throw new RuntimeException("I am void but not null")}
vacuum: Void

scala> def eatSpace(space:Void) = { println("I eat space"); println("and I got " + space)}
eatSpace: (space: Void)Unit

scala> eatSpace(vacuum)
you are in space, char!
java.lang.RuntimeException: I am void but not null
	at .vacuum(:7)
	at .(:10)
	at .()
	at .(:7)
	at .()
	at $print() 
// etc

scala> eatSpace(nothingness)
This is nothingness
java.lang.RuntimeException: byte me
	at .nothingness(:7)
	at .(:10)
	at .()
	at .(:7)
	at .()
	at $print()
//etc

Profile

juan_gandhi: (Default)
Juan-Carlos Gandhi

August 2025

S M T W T F S
      12
3456789
10 11 12 13141516
17181920212223
24252627282930
31      

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Aug. 15th, 2025 11:36 am
Powered by Dreamwidth Studios