4 ms·
This is not an unique feature today, you can do the same in D and Rust and even C++14, I think.
by CyberShadow 12y ago
This is not an unique feature today, you can do the same in D and Rust and even C++14, I think.
- namuol 12y ago"Hey Nim, 2014 called... they want their language features back." I jest. But seriously, D, Rust, and C++14 are about as familiar to me as Nim.
- CyberShadow 12y agoTo be fair, D has had it since 2007 :)
- Symmetry 12y agoRust is planning to add that eventually, but in the meantime: fn foo(n: i32) -> i32 { n * 2 } const y: i32 = foo(3); error: function calls in constants are limited to struct and enum constructors [E0015]
- pcwalton 12y agoYou can do it with a compiler plugin; I suspect that's what the parent comment was referring to. Admittedly compiler plugins are pretty experimental at this time.
- CyberShadow 12y agoSorry about that. I haven't tried this myself, I was told by a Rust user that its CTFE was on par with D's. I guess he was mistaken.
- Jweb_Guru 12y agoNot even close, sadly.
- tokenrove 12y agoOr Common Lisp, 30 years ago.