4 ms·
I'm not exactly sure. I think they may be at odds. Scala can handle AnyTypes in lists, but I think you have to decide whether you want compile time type checkin
by sjayasinghe 11y ago
I'm not exactly sure. I think they may be at odds. Scala can handle AnyTypes in lists, but I think you have to decide whether you want compile time type checking or run time dynamic type checking as from my knowledge you can't have heterogenous lists in languages like OCaml (and from the little I know of Haskell, Haskell as well).
- urs2102 11y agoHm, that's what I'm thinking as well. Scala's Any list is probably not the same, but I think with Haskell you can do it if you make a union of types. I just want to see if there are ways to allow type inference while keeping the list flexible and heterogenous as otherwise the Lisp loses power if I need to use functions like (car-int '(1 2 3)) to get an int. Do you know how pattern matching works in the case of matching cars to their respective types.
- Xophmeister 11y agoA sum type (union type) solves the problem by making the list homogeneous. A `car` against such a list would return a member typed as this sum type and it would then need to be extracted (e.g., with pattern matching) to get at the value.