Elektrine lite

← Feed

@typeswitch@gamedev.lgbt

Post #4187987

2026-07-29 04:11 UTC

a lot of confusion people have about types come from the mess that is mutable state in most languages. people conflate subtypes with subsets, which only really works when values are immutable. otherwise e.g. if a nonempty list is a list, and pop is a method on lists, you would be able to pop the last item from a nonempty list and it would still have be a nonempty list! ofc in this case the liskov substitution principle says nonempty lists aren't lists actually. mutability is not intuitive.

Replies (1)

  • @Girgias@phpc.social 2026-07-29 07:48

    @typeswitch@gamedev.lgbt this *feels* similar to the quadrilateral - rectangle - square class hierarchy problem. A lot of these things are not obvious and it can be quite challenging to explain the nuance between those. Not sure if trying to talk in terms of super types or going straight to dependent types would help :/

    Open ##4187986