logoalt Hacker News

josephgyesterday at 10:37 PM1 replyview on HN

By that definition a void* pointer in C is a sum type. By that definition assembly has sum types.

This argument feels like the “we have sum types at home” meme. Ergonomics matter.

I write a lot of rust. Rust has traits which are similar to Go’s interfaces. But the features aren’t the same, and I use enum all the time. (I also use trait all the time, but I use trait and enum for different things).


Replies

9rxtoday at 12:36 AM

> By that definition a void* pointer in C is a sum type.

No. That doesn't make any sense. void* is essentially equivalent to any in Go, which isn't sum types either.

You can construct sum types in C by combining structs, enums, and unions, but it is not an out of the box feature like in Go. Sum types are a first-class citizen in Go.

> Ergonomics matter.

Math doesn't care about ergonomics. You might care about ergonomics, but logically when talking about those ergonomics you'd call those ergonomics by name, not by some unrelated thing from type theory.

show 1 reply