Re:Ultibo – Environment for embedded development on Raspberr...
by pjmlp on Friday June 15, 2018 @09:17AM
(#17319513)
Yeah I loved sets, enumerations and sub-ranges as well.
You can achieve some parity in C++ and other languages with similar type systems, but it does require some tricks and I am not sure if everyone would appreciate it.
Object Pascal was always a lot more free with setting the bounds of an array too - you could specify any arbitrary range or even an enumeration. That's one thing I miss in C like languages. Being able to define an enumeration, then set the array bounds to that type - and then access it via the enumeration's values.
On a side note, I also miss sets. They were a first party part of the language, not a set of bolted on classes in the runtime library. I remember that I would quite often defined an enumeration, and array that used that enumeration as the subscript and a set to allow parts of the enum to be turned on and off when accessing the elements of the array. That was pretty cool. It made certain things a lot simpler - like defining errors that were raised by an action and then getting their textual error messages - all without having to do any conversion or anything fancy.