Proposed new syntax

Steve D'Aprano steve+python at pearwood.info
Sun Aug 20 02:33:20 EDT 2017


On Sun, 20 Aug 2017 02:28 pm, Rustom Mody wrote:

>> >> | S = {2·x | x ∈ ℕ, x ≤ 10}
[...]
> There's more than just a nit-pick wrong with that expression

The expression is fine. It is a mathematical expression, not Haskell code, so
your example of Haskell code is irrelevant to judging maths notation.


> Here’s an actual Haskell run
> 
> Prelude> [x*2 | x <- [1..], x <= 10]
> [2,4,6,8,10,12,14,16,18,20^CInterrupted.
> Prelude>
> 
> ie after “…,20” instead of printing a ']' and giving back the  "Prelude>"
> prompt it hangs… searching in the entire set of integers > 10…
> for an integer <= 10 (!!)
> …until a Control-C is given

If only Haskell supported the Clojure syntax:

(for [x (range 1) :while (<= x 10)] x*2)

(I may have got the order of x and 10 backwards, I haven't tested the above in a
Clojure interpreter.)

http://clojuredocs.org/clojure.core/for


> What’s the conclusion?? Take your pick:
> - Functional programming is stupid
> - Haskell is not all that intelligent
> - Halting problem is unsolvable
> - Converting the borderline uncomputable notion of set builder /comprehensions
>   into the computational framework of programming is fraught with trouble
> - Sets are a harder data-structure from computational pov than lists
> - ??

None of the above. How about...?

- abstract mathematics is not programming.


[...]
> Lives today in python in the fact that the russel-set gives a straightforward
> syntax error and nothing more grandly profound
> 
>>>> R = {x if x not in x}
>   File "<stdin>", line 1
>     R = {x if x not in x}
>                         ^
> SyntaxError: invalid syntax

Rustom, please write 100 times on the blackboard, "I cannot mechanically
translate abstract maths notation into programming languages without
understanding the semantics of both."

Thank you.

All you have demonstrated is that mechanically translating abstract maths
notation into Python code without considering the semantics of either is, in
general, doomed to fail.



> Strawman argument as usual!

If I had a dollar for every time somebody misused "strawman argument" to mean "a
valid argument against my position that I cannot counter", I'd be able to
afford to purchase a small island in the Pacific. Such as New Zealand.


> For myself, thanks to Peter's clarification that 'comprehension' is best
> thought of as 'comprise', I am now going to teach to my students:
> “Comprehension is a misspelling of comprision”

Only if you wish to mislead your students.

"How do you know that, Herr Doktor Professor Mody?"

"Oh, some random person on the internet gave me his guess as to the etymology of
the word, I made up my own word 'comprision', and put 2 and 2 together to get
7. Any other questions?"

Comprehension is not a misspelling of anything, and I don't think Peter is
correct. According to the OED, the etymology of "comprehension" comes from
French compréhension or Latin comprehensio, to seize. Comprise is also derived
from the same words, but independently. Both are first attested to in the late
Middle Ages.

By the way, this was discussed in detail at least once before:

http://code.activestate.com/lists/python-list/123564/


-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.




More information about the Python-list mailing list