invalid-token syntax hook (was Re: Hack request: rational numbers)

Jeff Epler jepler at inetnebr.com
Mon Jan 29 11:28:39 EST 2001


Jeff Epler wrote:
> > Why not go all the way and make the whole Python grammar extensible
> > in Python?
 
On Mon, Jan 29, 2001 at 02:33:52PM -0000, Tony J Ibbs (Tibs) wrote:
> Ooh! Ooh! I have two immediate reactions:
> 
> 1. What a great idea - I can *use* that (when I ever get back to the
> mxTextTools preprocessor - an extension to the language is *so* much
> more elegant than a preprocessor - and there's something fun about using
> Spark to parse code to allow one to use mxTextTools)

Yes -- on the one hand, having the ability to extend Python's grammar
for a particular situation is one that sounds wonderful.

> 2. What a scary idea - would I ever trust anyone (possibly including me)
> to use that?

On the other hand, you're right here too.  As a rule, Python people have
disdain for the TMTOWTDI mindset of another language, and in fact one of
the chief quarrels with that language is the introduction of a bit of
syntax for every cute little thing ("unless" and "if" as operators;
"or" and "||" boolean operators with differing precedence, etc).

In fact, the idea that served as an inspiration to Mobius is one that I
think everyone in the room will find repugnant -- The ability to use the
HTML tag to introduce nested program blocks.  I had a vision of
HTML-producing Python programs that would read like

    <HTML>
	<HEAD>
	    <TITLE> "This is really cool, eh?"
	<BODY>
	    <TABLE>
		for item in news():
		    <TR> item.tohtml()
	    "generated by"
	    <A HREF="http://incolor.inetnebr.com/pyhtml"> "PyHTML"

> I'll be very interested to know what the BDFL thinks (although I guess
> that I can guess).

I have no illusion that our BDFL would accept something like Mobius into 
core Python, but on the other hand, Mobius is itself a pure Python
program and will be distributed under the Python license, so that anyone
can include it in their project.  Whether anybody will choose to do so
is an open question, because working on Mobius has been a fun adventure
for me.

Jeff




More information about the Python-list mailing list