how to get the ordinal number in list

Steven D'Aprano steve+comp.lang.python at pearwood.info
Tue Aug 12 22:11:14 EDT 2014


Rustom Mody wrote:

> I guess part of the problem is that evidently you and I use 'concrete'
> and 'abstract' in almost diametrically opposite ways.
[...]
> But now you are turning the tables and saying that the FP types/constructs
> are more abstract than the conventional ones.
[...]
> In my book, FP is easy and pleasant and smooth because (among other
> things) FP types are concrete, whereas OOP types are abstract.

I wrote about how your view of sorted() was an abstraction, not an Abstract
Base Class. I thought that was clear enough: you ignore the concrete
details of how one sorts (bubblesort, quicksort, timsort, ...) and
everything but the result returned. I shouldn't think that is
controversial. Let me repeat what I said at the time:

    You are abstracting away the details of the real computer 
    implementation into an abstraction of a pure mathematical
    function...

I am not talking about *abstract types* in the object-oriented sense.

I then went on to say:

    But abstractions leak, and someday someone is going to ask 
    "Why does it take 45 minutes to find the five largest values
    of my list?", and if you persist in insisting that sorted()
    is a pure mathematical function you will have no clue on how
    to even begin solving this [...]

(I don't actually believe that *you personally* are incapable of thinking
about the implementation of sorted(). It is a hypothetical situation.)

For the record, Wikipedia defines abstract types as:
  
    In programming languages, an abstract type is a type in a
    nominative type system which cannot be instantiated directly.
    Abstract types are also known as existential types.

and contrasts them with "concrete types" like Python's float, list, str.

I am using "abstract" in the sense of an abstraction, as opposed to
something concrete and real, not as a mechanism for specifying interfaces in
Java or Python. Python's float is a leaky abstraction of mathematical Real
numbers, and Python's softed() is a leaky abstraction of the concept of
sorting a collection. Both are abstractions, because they are *intended* to
gloss over real world details of Real numbers and sorting, but both leak
because the implementation of the abstraction spoils the abstraction.

http://www.joelonsoftware.com/articles/LeakyAbstractions.html



-- 
Steven




More information about the Python-list mailing list