Python is readable
clp2 at rebertia.com
Wed Mar 21 08:16:49 CET 2012
On Tue, Mar 20, 2012 at 11:52 PM, Steve Howell <showell30 at yahoo.com> wrote:
> 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
> 6 item push stack # Take the item; push it on the stack.
> #4 and #5 are sort of Forth-like, maybe? #6 is just downright
#6 is just an infix binary operator (likewise with its cousin #3, just
remove the punctuation). If you change the name slightly, it becomes
more sensical. One could easily write in Haskell:
item `pushOnto` stack
which would just be syntactic sugar for #2. Not that I endorse #6,
merely saying it's less weird than you think.
More information about the Python-list