On Mar 21, 12:16 am, Chris Rebert <c...@rebertia.com> wrote: > On Tue, Mar 20, 2012 at 11:52 PM, Steve Howell <showel...@yahoo.com> wrote: > > On Mar 20, 10:40 pm, Chris Angelico <ros...@gmail.com> wrote: > >> On Wed, Mar 21, 2012 at 3:58 PM, Steve Howell <showel...@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 > >> first. > > > 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 > > odds." > > > 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 > <snip> > > 6 item push stack # Take the item; push it on the stack. > <snip> > > #4 and #5 are sort of Forth-like, maybe? #6 is just downright > > strange. > > #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. >
Ha, you're right, verb-in-the-middle is just infix. So, if you don't care about the order of the nouns, you have three forms: verb first: English-imperative ("boil water", "add noodles/salt", "serve in dish") or math-functional, e.g. sum(a,b,c) verb middle: infix, arithmetic-like ("5 plus 4", "10 divided by 2") or English-descriptive ("Dog bites man") verb last: Forth-like, maps well to simple underlying implementation I guess the OO syntax is really verb-first when you think of "stack.push" as the verb. -- http://mail.python.org/mailman/listinfo/python-list