I'm wondering why you used D rather than Rust? Was it just that you were curious about the D language or is there something about Rust that you don't like?
I recently came upon this post and couldn't agree more with it: https://www.quora.com/Which-language-has-the-brightest-futur...
I prefer meta-programming in D as I don't get to think at the AST level; its practical in Lisp because the code is the AST, but everywhere else I like compile-time function evaluation better - it feels more natural. It's the same reason why I don't like template-Haskell.
D also has string mixins for the rare occasion when templates reach their limits. You get something akin to "eval" in javascript, but as a compile-time construct. Mixed with the other compile-time features of D (function evaluation, reading files, full reflection and more) it makes for the most powerful thing I know of after Lisp macros. I never have to write offline code analyzers and generators again!
I prefer interfacing with C in D because I don't get to mess with a FFI; I can copy/paste the C definitions in D, run a few Emacs macros and I'm good to go. (Although that's becoming a non-issue over time as more and more bindings are published!)
As far as I know (correct me if I'm wrong!) there's no way to declare pure functions in Nim. This is something I do all the time in D!
Nim has memory-safety only when using the GC while D has decoupled it from the allocation strategy. D's memory-safety is actually part of the type-system (as function annotations) and I absolutely love it!
That's about what comes to mind right now :)
Please note that these points merely makes D a better fit for my own use-cases, I'm also biased from knowing D a whole lot more than Nim, so take what I say with a grain of salt ;)
I continue to dabble in Rust, but D is so much more comfortable.
https://github.com/aswyk/oxidation/blob/master/oxidation/src...
Of course, Rust's own lexer is also written in Rust.
ETA: I can't promise my lexer is actually any good... it's really the first non-trivial thing I've written in Rust. But it works ;)
enum MyLanguage {
Var(String),
Int(i32),
Sum(Box<MyLang>, Box<MyLang>),
Let(String, Box<MyLang>, Box<MyLang>)
}
(Apologies if I got a few things wrong; I just mean the general idea)Seems like without a construct like this, you'd have to use subclasses or something similar, which (to me) isn't quite as nice.
alias MyLanguage = VariantN!(<insert types here>);
edit: not that it proves anything, just that "it can eventually be done".
enum ConnState {
Disconnected,
Connecting,
Connected(net::TcpSocket),
Transferring(net::TcpSocket),
}