Re:Why Pascal Is Not My Favorite Programming Language (1981)
by dvfjsdhgfv on Monday February 25, 2019 @02:52AM
(#19243854)
It's an interesting read and at the same time a relief to realize that many if not most of the problems have been addressed years ago. E.g. sorting an array in FreePascal is a very simple task (not to mention that dynamic arrays and generics are also supported).
[ Parent
| on HN ]
Re:Why Pascal Is Not My Favorite Programming Language (1981)
by clouddrover on Monday February 25, 2019 @02:56AM
(#19243867)
And in the recent versions of Delphi you can use TArray which supports generics and simply call its Sort method:
http://docwiki.embarcadero.com/Libraries/Rio/en/System.Gener...
It's a shame more people don't use Object Pascal. I like it a lot.
Re:Why Pascal Is Not My Favorite Programming Language (1981)
by nine_k on Monday February 25, 2019 @03:19AM
(#19243971)
It's funny that generics are supported in Pascal, but not in its spiritual successor, Go.
(Of course, Go's succession goes not directly from Pascal, but through Modula-2 and Oberon.)
Re:Why Pascal Is Not My Favorite Programming Language (1981)
by magicalhippo on Monday February 25, 2019 @05:27AM
(#19244551)
Delphi has compile-time generics, which is kind of a "worst of both worlds" approach. It has all the constraints of templates, but none of the benefits of run-time instantiated generics like .Net has.
For example you can't make a generic function that uses the + operator to add two parameterized elements together, because there's no way to constrain the types to only those which has the + operator defined. But unlike templates in C++, the compiler doesn't just try and see if it works but rather emits an error.