4 ms·
> So in this example, since it's a (List Any), in order to get this to work would we cast the Any to be an Int to then put it through sqrt? I wouldn't recommen
by DonaldFisk 11y ago
> So in this example, since it's a (List Any), in order to get this to work would we cast the Any to be an Int to then put it through sqrt?
I wouldn't recommend you use casting the way it's done in C. It defeats the purpose of having a strong type system if you can change the types like that. Having a function which checks the type and gives an error if it's not the type you expect is, I think, a better approach.
I'm still actively developing Full Metal Jacket. Glad you find it interesting. An interpreter for the basic language is almost complete. I'll soon add to my tutorials (http://web.onetel.com/~hibou/fmj/tutorials/TOC.html http://web.onetel.com/~hibou/fmj/tutorials/TOC.html) how to do inlining and substitution macros, and how to define new types. Then I'll make my code more robust, possibly add a compiler, and arrange a release on a shared-source licence.
- urs2102 11y agoOh yeah, my mistake - you're totally right. So in this case what type does car output (or how do I write the type definition for car), because it can't output multiple types otherwise I wouldn't be able to check its value at compile time? And yeah, Full Metal Jacket seemed cool (and it's a great name). Do post it here when you start putting those tutorials up!