Python is readable
showell30 at yahoo.com
Wed Mar 21 07:52:47 CET 2012
On Mar 20, 10:40 pm, Chris Angelico <ros... at gmail.com> wrote:
> On Wed, Mar 21, 2012 at 3:58 PM, Steve Howell <showel... at yahoo.com> wrote:
> > So saying "push(stack, item)" or "push(item, stack)" seems very
> > unsophisticated, almost assembly-like in syntax, albeit at a higher
> > level conceptually than assembly.
> Perhaps it does, but "push(stack, item)" and "stack.push(item)" are so
> close to identical as makes no odds (in a number of languages, the
> latter is just syntactic sugar for something like the former) - yet
> they "read" quite differently, one with verb first, one with noun
On the one hand, you say that "push(stack, item)" reads quite
differently from "stack.push(item)".
On the other hand, you say they are "so close to identical as makes no
I'm trying to make sense of that. Are you saying that the way the two
idioms read makes no odds, despite reading quite differently?
> Code doesn't follow the same grammar as English prose, and forcing it
> to usually makes it sound odd. Reader.can_comprehend(code) is True.
Code shouldn't necessarily follow the example of English prose, but it
seems that English has had some influence:
1 push(stack, item) # Push on the stack the item
2 push(item, stack) # Push the item on the stack
3 stack.push(item) # On the stack, push the item
4 stack item push # On the stack, take the item and push it
5 item stack push # Take the item and on the stack, push the
6 item push stack # Take the item; push it on the stack.
The first three ways are the most common ways of arranging the grammar
in mainstream programming languages, and they are also the three most
natural ways in English (no pronouns required).
#1/2 are imperative. #3 is OO.
#4 and #5 are sort of Forth-like, maybe? #6 is just downright
More information about the Python-list