On Tue, Nov 12, 2019 at 10:52 AM Abe Dillon <[email protected]> wrote:
>
> Many fields develop their own specific short-hand notation and vocabulary for 
> communicating the complex yet recurring ideas within that field easily. In 
> many cases, this is a modification of an existing language or, in some cases, 
> many different languages.
>
> This idea is a bit half-baked, but what if we could define a meta language 
> that allows people to describe how to alter Python into some domain-specific 
> language. Code written in the meta-language would be called a "domain 
> specification" and it would describe new reserved-words and syntax for that 
> DSL. It might even release some reserved words from reservation.
>
> This might provide an interesting way to try new syntax proposals. I don't 
> know how something written in a DSL would interoperate with regular Python, 
> they may have to use separate interpreters and pass messages between the two. 
> I also don't know how you would link a script to a domain specification. 
> Maybe this idea is less than half-baked. 1/4th baked?
>
> That way someone could write a version of Python where the assignment 
> operator is "→" or "->" or "(╯°□°)╯︵ ┻━┻".
>

I'd recommend exploring two paths:

1) MacroPy
2) Preprocessors/compilers

MacroPy is an insanely powerful tool for messing around with Python.
You may well be able to do what you want that way. If you can't,
though, what I'd recommend is a parser that reads your modified script
and spits out a valid Python program - you can either think of that as
a preprocessor (if it makes only a few small tweaks here and there),
or as a compiler that emits Python code (if it makes extensive
changes). If you want to generalize, as you're saying here, then you
could have a generic preprocessor/compiler that takes a domain
specification and a source file, and spits out the corresponding
Python code.

Since Python code is all text, it's something you can very easily
manipulate with Python itself.

ChrisA
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/43JPCYRH2VQOEZYATNVJHCH4SYHELG3Q/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to