English-like Python

Aaron Brady castironpi at gmail.com
Wed Jan 21 09:48:22 CET 2009


On Jan 20, 9:16 pm, MRAB <goo... at mrabarnett.plus.com> wrote:
> Terry Reedy wrote:
> > Joe Strout wrote:
> >> Aaron Brady wrote:
>
> >>> I think it would be a good step if you could make some sensible
> >>> interpretation of a typical statement without its parentheses.
>
> >>> f "abc" 123
> >>> -->
> >>> f( "abc", 123 )
>
> > How would you differentiate
>
> > f 'abc' + 'def'
> > as
> > f('abc') + 'def'
> > versus
> > f('abc' + 'def')
>
> >> Such a language is possible -- take a look at REALbasic sometime.  RB
> >> certainly has its problems (mainly bugs), but the language syntax is
> >> beautiful.  To your point, parentheses are not required around any
> >> method call that (1) has no return value, or (2) requires no
> >> parameters.  Example:
>
> >>  LogError "Walk has gotten too silly", CurrentTime
>
> > LogError('walk', Time) # versus
> > LogError('walk'), Time
>
> > Perhaps RB does not have tuple literals.
>
> Parentheses wouldn't be required if it's a procedure call (I'm not sure
> about a function that's called as a procedure) or if there are no
> parameters to pass. Thus:
>
>      f 'abc' + 'def'
>
> does:
>
>      f('abc' + 'def')

Where functions are first-class objects, a bare function object isn't
distinguishable either from its call.  I'm granting that it's useful
to return values a lot.  For example:

a= f

could mean either, 'a= f' or 'a= f()'.  Once again the return values
save the day.

In the case of Terry's example, it's covered by Joe's caveat that
functions can't return values without parentheses, since '+' is a
function.  However, order of precedence could help.

Python and C of course allow string concatenation by adjacency, so
there's further ambiguity there.  It might fall under Terry's case.

You can look at English to get started, and try to see how native
speakers resolve the ambiguities.  It doesn't just happen with verbs,
either.  Firstly, Python lacks the notion of determiners (denoting
phrases) per se.  That is, there's no way to say 'the black dog'.
Here's an approximation though.

"The black dog and the cat walked to the store."

walked( ( dogs( color= black ), cat ), store )

Secondly, Python is entirely imperative, something I was alluding to
in another post, which was about a relation object.  English declares
the event, while Python commands it:

( dog, cat ).walk( store )

It addresses the subjects, and gives them orders.  On a tangent, I
think the 'join' method on threads is a little counter-intuitive,
since the entity you're giving the instruction to is actually the
caller, not the object.  The verb is a little counter-intuitive,
though, since if I say 'Team, join us!', it actually just means, 'Us,
wait for the team'.  It's not like 'join' causes the target to break
early or hustle or anything.



More information about the Python-list mailing list