Are the critiques in "All the things I hate about Python" valid?
Michael F. Stemper
michael.stemper at gmail.com
Wed Feb 21 11:35:20 EST 2018
On 2018-02-18 22:55, Paul Rubin wrote:
> Steven D'Aprano <steve+comp.lang.python at pearwood.info> writes:
>>>> "positive odd integers greater than 10 but less than 15003 divisible by
>>>> 17 except for 850, 867 and 1394; or primes that aren't Mersenne
>>>> primes"....
>> It *could* be a type, if your type system was sufficiently flexible to
>> allow you to specify something in that level of detail. Of course no
>> existing type system is.
>
> Of course dependent types could do that (they have a type for every
> proposition in constructive predicate calculus). You might also be able
> to do it with Liquid Haskell's refinement types, though automatically
> checking them might not be so easy.
>
>> That's an easy one: even Pascal in the 1970s could deal with enumerated
>> types like the values 1, 3, 5, 7, 9. (I think.)
>
> Idunno about Pascal, but Ada has integer range types.
Back in the early 1980s, I took a few courses involving Pascal,
and it certainly supported subranges then. Quoting from my
text[1]:
A _scalar subrange_ data type is a data type composed of
a specified range of any of the other standard or user-
defined scalar types, except type REAL.
We define a subrange type with a TYPE declaration of the
following format.
TYPE type-name = lowerlimit..upperlimit;
[...]
Examples of subrange declarations are:
TYPE EXAMSCORES = 0..100;
Of course, Pascal being Pascal, a function to return the sum
of an array of INTEGER would refuse to return the sum of an
array of EXAMSCORES.[2]
[1] _An Introduction to Programming and Problem Solving With
Pascal_; Schneider, Weingart, and Perlman; (C) 1978
[2] Kernighan examines a similar issue in Section 2.1 of
"Why Pascal is Not My Favorite Programming Language",
<http://www.cs.virginia.edu/~cs655/readings/bwk-on-pascal.html
--
Michael F. Stemper
You can lead a horse to water, but you can't make him talk like Mr. Ed
by rubbing peanut butter on his gums.
More information about the Python-list
mailing list