Proposed new syntax
Rustom Mody
rustompmody at gmail.com
Fri Aug 18 09:46:58 EDT 2017
There is code and there are machines
There are Turing machines and Universal Turing machines
There are programs and there are programming languages
There are (il)legal programs and best/worst (software engineering) practices
As best as I can see most of us are talking of the respective latters above
while Steven insists on taking this whole discussion exclusively in terms of the formers
Picked up some quotes from the thread above and ALLCAPSed the phrases that
would hopefully show the difference
Paul writes
> Sure, and floating point arithmetic is inherently imprecise and
> doesn't follow the associative laws for either addition or
> multiplication. There are times when we have to be aware of those
> details. Usually, though, WE WANT TO ACT AS IF they represent the
> mathematical reals, and we read Python statements involving floats as
> if they were mathematical statements involving reals.
Marko Rauhamaa writes:
> Nothing prevents you from using Python's comprehensions that declarative
> way. THE QUESTION IS, IS IT BAD STYLE—OR EVEN AN ERROR—to rely on the
> execution order of the comprehension loops? Is a Python implementation
> allowed to parallelize or otherwise reorder the evaluation loop?
Greg Ewing writes:
> Perhaps what I should say is that relying on side effects in
> an expression occurring in a particular order IS A BAD IDEA. (not wrong)
Ben Finney writes:
At what point will you accept the feedback: That the comprehension
syntax *does not* necessarily CONNOTE (not denote) a procedural loop, but
instead can quite REASONABLY (not guaranteedly/necessarily) be interpreted as
its designer intended, a single conceptual operation.
I just want to emphasise that (for myself) Ive no quarrel with the current semantics
My issue is that the tutorial introduces comprehensions backwards, as though
they are a macro for the for-loop
https://docs.python.org/3/tutorial/datastructures.html#list-comprehensions
Compare the well-known haskell tutorial
http://learnyouahaskell.com/starting-out
whose comprehension intro starts:
| If you've ever taken a course in mathematics, you've probably run into set
| comprehensions. They're normally used for building more specific sets out of
| general sets. A basic comprehension for a set that contains the first ten even | natural numbers is
| S = {2·x | x ∈ ℕ, x ≤ 10}
Analogous thing shown at ghci prompt:
| ghci> [x*2 | x <- [1..10]]
| [2,4,6,8,10,12,14,16,18,20]
More information about the Python-list
mailing list