On 2021-10-18 15:58, Steven D'Aprano wrote:
On Mon, Oct 18, 2021 at 10:20:17AM -0000, Mathew Elman wrote:

despite a driving idea of python syntax being readability in english, the function signature is distinctly not english.

Python's syntax was not really modelled on English, as far as I can
tell. It was (I think) modelled more on Pascal, Modula-2/3, C and most
of all, ABC:

https://www.artima.com/articles/the-making-of-python

All of those languages (like most programming languages) use English
keywords, but not English grammar. In Python's case, I think it is
better to say that the language aims to read like executable
pseudo-code, not English.

If Guido is reading, he might like to step in and correct me, but as far
as I know, the intent was never to make Python code read as English.

There are languages that do that. The ultimate example of that is quite
probably Inform7, a specialised game language that reads like this:

     Afterlife is a room. "Fluffy white clouds gather round you here in
     the afterlife." The Pearly Gates are a door in Afterlife. "The
     Pearly Gates - large, white, wrought-iron and splendidly monumental
     - stand above you." Heaven is a room. The Gates are above the
     Afterlife and below Heaven.

Yes, that is actual source code, not documentation, taken from the
Inform website.

http://inform7.com/

Inform 7 is specialised for making text games, but a more general
purpose English-like languague comes from the XTalk family of languages,
starting with Apple's Hypertalk in the 1990s. In XTalk languages, we can
write English-like statements like these:

     put the date into field "Today"
     get the second line of todo_list
     put prefix before the third word of it
     get the number of words of password
     if it < 10 then answer "Your password is too weak"
     add seven to the name of button id 21
     put any word of field 1 after the middle word of field 2

Aside from mentioning that "field" here refers to editable text entry
fields in the GUI, I probably don't have to explain what any of those
lines do.

I have a soft spot in my heart for Hypertalk and its GUI builder,
Hypercard, so I completely understand your desire to write code with a
more English-like syntax.

If my memory is correct, in Hypertalk you could take any function of one
argument and write it as either of these forms:

     function(argument)
     the function of argument

So it is not a huge step to imagine a new syntax that looks like your
example:

      insert 1 into container

That's practically the same as Hypertalk's "put ... into ...".
(Hypertalk also supported put...after and put...before.) So what you are
asking for is certainly *possible*.

But I do not think it is a good fit for Python's syntax. I love
Hypertalk's syntax, but it does not fit well with Python's existing
syntax.

English-like code and Python code are both great, but a mix of the two
in the same file would be like some sort of horrible surgical experiment
gone wrong.

I once had to do something in Appletalk. If you wanted to refer to the title of a window you would say "title of window" or "window's title".

So, how would you refer to the program's title?

If it borrowed from Smalltalk it would be "title of windows of self". That didn't work.

If it borrowed from C++ it would be "title of windows of this". No luck.

After a bit more guesswork I tried "title of window of me". That worked.

Alternatively, you could have "me's window's title". Not "my", but "me's".

I felt that it was trying too much to be like English whist not being English, so it wasn't as clear what was actually legal.

I think that a programming language needs to be different enough from a natural language to remind you that it's a programming language and that the computer isn't that smart. The computer will do as you say, not as you mean.
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/DG7SNHQZODG22GNA7TA56KD7V27ZSLWP/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to