Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

>Just for fun: I'd argue it still depends on the data it operates on... in this case, the empty set!

Void is not an empty set. It is void. Nothing. I am referencing the category void here. I'm not too familiar with rust but in rust this is just an empty enum.

Note that functions with parameter void can never be called because the void type can never be instantiated. You cannot instantiate nothing. This is a very theoretical concept, but I believe in rust you can actually define (not call) a function of this type.

   fn absurd<T>(x: SomeEmptyEnumType) -> Int { 1 }
It's def hard to write a useful program made up of functions that can't even be called.

>So, in essence: I think we agree on the problem but disagree on the culprit. It's not OOP. It's C++/Java/C#/etc.

Took me a bit to parse what you're saying. I get it and you're right. What is the problem with C++/Java/C#/etc?



Void is just another name for the empty set. It's not an empty set, it's the empty set. Since it has no members it indeed cannot be instantiated.

As a Rust library: https://docs.rs/void/1.0.2/void/enum.Void.html Notice how the empty enum is called... Void.

In Rust you have "!" (never) too, which cannot be instantiated either but coerces into any other type.

> What is the problem with C++/Java/C#/etc?

Is-a polymorphism.


Polymorphism? Aren't interfaces a formalization of polymorphism?


Notice I said "is-a" polymorphism (I should've said inheritance to avoid confusion: class Person; class Employee is-a Person; class Client is-a Person; etc.). I mean an ontology of classes.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: