Comment by LorenPechtel

2 years ago

Yes, this was a really nice advantage Pascal had that I'm amazed hasn't been picked up by things like C#. It's not just zero or one based.

(It's been long enough I'm not completely sure of the syntax) Time : Array [2000..2100, 1..12, 1..31] of OneDayInfo;

Avoid allocating the 2000 years in the past while allowing directly indexing with the year field.

And you could use enum types as array indexes. In C# you're always casting them to int whenever an enum is an array index and every cast is a case where the compiler won't have your back in hunting for errors.

And it did *not* use duck typing.

Month: 1..12 DaysOfChristmas: 1..12

You couldn't assign which day of Christmas to a month.

The stricter the compiler the fewer bugs will even compile and the faster you'll find the problem.

As for his color assignment issue--you still need to be able to set it to "purple", but representing it his way pushes this back to whatever routine parsed the configuration. There's only one place that needs to make the check and anything bogus will be caught during startup.