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

Zero is good for "absence of failure". It's a "yes" in the sense that "this worked". Whereas any one of the myriad non-zero codes is "no, it didn't work".

If we have a situation in which there are many numeric codes, exactly one of which means "success", it's probably best if that one is assigned zero.



Except that Curtis strongly (and snarkily) claims that Hoon is a typed language:

https://news.ycombinator.com/item?id=11819810 item #3 (and subsequent discussion)

So why are they punning integers and booleans in the first place?


Punning means that we have two types, and we somehow interchange them; use an object of type A, as if it were of type B. We thereby leave behind the type system and take responsibility for that being correct.

If a language doesn't have a Boolean type, and some other type serves for indicating truth/falsehood, then that is a representational technique distinct from punning.

A language with no Boolean type can be statically typed. It just means that the conditional operators work with some non-Boolean, like integer, yet according to well-understood rules. For instance if we have some "if expr foo bar" such that either foo or bar is evaluated based on whether or not expr is zero. This would be statically well-typed if expr has integer type and foo and bar have the same type.

Of course, we can't do pattern-matching whereby a value is classified as Boolean or integer in separate cases. (Unless we use the language's type construction ability to define a Boolean type which wraps integer, or whatever).


I don't want to quibble over terminology, so fine: Hoon doesn't pun integers and booleans, it conflates them. Whatever you call it, it's still a horrible hack, and IMHO if you put in your language you surrender your snark privileges when comparing your language to Lisp.


Common Lisp conflates all types with Boolean. NIL, the sole instance of the NULL type in Common Lisp, is false, and an instance of every other type is true. (Of course, this situation quite good).


> Common Lisp conflates all types with Boolean

Yes, I know.

> (Of course, this situation quite good).

I think that's debatable. Javascript, for example, does something similar but it takes all empty containers as false, along with zero and a few other things. (Not that I am necessarily holding up Javascript as an example of good language design. My point here is just that there is not a consensus on how (or whether -- c.f. Scheme) to conflate booleans with other types.)

The salient differences between CL's boolean conflation and Hoon's are:

1. CL's conflation design is justifiable in terms of how it simplifies coding recursion over a list, which is the single most important Lisp coding idiom.

2. Hoon tries to justify using zero as true by saying that non-zero integers can carry information about the nature of a failure. (At least I've heard some people try to justify it in this way. I'm not sure if Curtis does not not.) But now you are no longer conflating integers with booleans, you are conflating integers with multiple enum types, one for every possible set of failure types. Flouting convention is one thing. Flouting convention in order to enable conflation of integers and enums undermines Hoon's claim of being strongly statically typed (at least in any interesting way).


CL's conflation also means that can use NIL to indicate the absence of an object (in the usual situation in which NIL isn't a valid value). We can test for this absence glibly, using a conditional. This is at least as useful as the benefits in list recursion.

The Javascript design means that we cannot test for the absence of an integer in this manner, because a negative result could mean that a zero is present.

It could be handy from time to time. I propose a NAUGHT function for Lisp which returns true for empty sequences, empty hashes, zero (integer, real or complex) and any other nothing you can think of.


Sure, but if you want to make that argument then you have to deal with the fact that there is no false value which indicates the "absence of an object" in the case where the value being tested is a list. Having multiple false values really can be a feature. (They just shouldn't be integers!)




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

Search: