4 ms·
I wish Janet used Option types instead of using nil. No idea why modern Lisps don't borrow from Rust's goodness.
by lenkite 4y ago
I wish Janet used Option types instead of using nil. No idea why modern Lisps don't borrow from Rust's goodness.
- James_K 4y agoOption types are inherently a bad idea for languages without value semantics. In rust, the Some variant of an option type can just be allocated on the stack at almost no cost, but doing this here would require a million small allocations every time you want to return something. Beyond that, it makes no sense to have union types when every value is already a union of all possible types.
- shakow 4y agoI love option types, but I don't think they make a lot of sense in dynamically typed languages.
- fredrikholm 4y agoAgreed. We used them at work (Clojure) and it didn't solve anything; normal idioms don't apply to monads and the mental overhead of having to know when they are used is the exact same as having to know when something might be nil.
- germandiago 4y agoI would say from Boost C++ or from C++ std. Rust came far later.
- rafaelrc 4y agoOr from Haskell
- butterisgood 4y agoOr OCaml
- dnsco 4y agoOr ML
- germandiago 4y agoMaybe
- avgcorrection 4y agoOh, that’s funny.
- dgb23 4y agoLisps and nil have a symbiotic relationship, not an adversarial one. They are an everyday falsy value that you program _with_ not around. Nil doesn't signal that you forgot to initialize a value. It simply means stuff like "I don't have this" or "no more". You don't check for it at every corner like an anxious squirrel, but pass it around freely, knowing that your code knows, accommodates and embraces nils.
- butterisgood 4y agoRust did not invent Option types.
- porcoda 4y agoOption types are from ML, not rust. ML predates rust by about 40+ years.