evincarofautumn / kitten

A statically typed concatenative systems programming language.
http://kittenlang.org/
Other
1.1k stars 39 forks source link

Full read/show instances plus relational operators #186

Closed ColonelJ closed 7 years ago

ColonelJ commented 7 years ago

Added missing relational operators e.g. unsigned comparisons and = <> for Booleans (~ looks a bit redundant for booleans since it's the same as <> really, but it's still a useful operator for other stuff such as bitwise). Further extended this to make Booleans ordered by false < true and created lexicographical orderings and comparisons for many types of lists (done away with the == form of equals since it's a bit useless, preventing basic usages of comparisons for example with the elem function on a list of strings).

Added show instances for floating point values, and implemented polymorphic 'read' trait for parsing back in all the basic types supported by show (so you should be able to invert a show by doing a read and from_some).

evincarofautumn commented 7 years ago

I think I’ll hold off on merging this until we have generic trait instances, because this copying and pasting is a bit too much.

ColonelJ commented 7 years ago

I've gone through and edited out most of the unnecessary copy and pasting so I think it looks ok to merge now. I left the functionality for only List<Int32> and List<Char> (strings) so now it's only duplicating code once, and therefore it's easy to see where the code needs to be made more generic to cover all the other possible types (once the generic instances of traits are properly supported).