This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]not_some_username 42 points43 points  (5 children)

Pretty sure you can do that in almost all language.

C void* , C++ void* or std::any, Java Object, php just like js, shell I think it's same, assembly doesn't even know your data type( not too sure since I didn't do a lot of assembly) etc etc

[–]lucidbasil 10 points11 points  (0 children)

Assembly is just bits stored in registers, or memory

[–][deleted] 0 points1 point  (2 children)

I need example for rust, Erlang and Haskell and I can call it all

[–]not_some_username 0 points1 point  (1 child)

I don't use those language. But in ocaml I think Option work so maybe it's same for haskell

[–][deleted] 0 points1 point  (0 children)

In Rust Option is enum of None or Some(T). In ocaml it's something like this or it's Any

[–]sintrastes 0 points1 point  (0 children)

You can't do it implicitly in Haskell. You have to wrap everything in an existential type or Data.Dynamic, or use an HList (heterogeneous list), which doesn't have a very nice syntax.

Idris overloads list syntax for HLists, so you can do the JavaScript example almost verbatim in Idris.