[Python-ideas] Python as meta-language

Josiah Carlson jcarlson at uci.edu
Mon Dec 25 16:27:00 CET 2006


Talin <talin at acm.org> wrote:
> 
> Josiah Carlson wrote:
> > Talin <talin at acm.org> wrote:
> >> One of my long-standing interests is in mini-languages, particularly 
> >> declarative languages. I'm always looking out for examples where a 
> >> declarative language is used to represent some idea or concept that is 
> >> not easily written in an imperative language. Examples are the behaviors 
> >> of particle systems, kinematic constraints, formalized grammars, logical 
> >> inferencing systems, query languages, and so on. In other words, you are 
> >> using a language to describe a complex set of relationships, but you 
> >> aren't giving specific commands to execute in a specific order.
> > 
> > If you haven't already seen it, you should check out Logix:
> > http://www.livelogix.net/logix/
> 
> I think I looked at it before, but I'll have another look. From what I 
> can tell, there's some interesting ideas here, but there are also some 
> things that are kind of kludged together.

I should have said a bit more.  Basically, my idea of suggesting that
you take a look at Logix was a veiled attempt at saying "I think the
base Python language syntax is fine".  While Logix does go to the
extreme of making Python syntax far more maleable than is generally
desired (in my opinion), there are cases where conservative use does
make life easier.  Say, for example, if one preferred C-style
conditional syntax to Python's conditional syntax.


> I'm not sure that I would want Python to be quite so malleable as Logix. 
> The reason for this is that it's hard to reason about a language when 
> the language is so changeable. Of course, this argument shouldn't be 
> taken too strongly - I don't mean to condemn programmable syntax in 
> general, I just don't want to take it too far.

The ultimate question is, "what is too far?"

[snip math operation discussion]

While it would be convenient to define all standard mathematic
operations, I don't believe that Python is the language for it.  Python
can be used as a language to do mathematics, it's not a computer algebra
system, and I believe the vast majority of mathematical operations
should be limited to computer algebra systems.  Say, for example, Sage.

Offering "production rules" a'la ::=, wile being an interesting idea,
can be represented with current syntax, if one uses certain "tricks" (AB
for concatenating A and B, | for offering alternatives, * for repetition,
etc., and the use of a custom namespace for name resolution):

    A = B | C | D.F | E

Anyways.  Come up with a set of operators.  I don't know if consensus is
where we should go with this, but the existence of Logix, in my opinion,
puts the realm of alternate/additional operators within the realm of
extension modules, and operators need to show that they have (or would
be used) significantly within the Python user community (like the
requirements for standard library module additions).  So far, aside from
matrix multiplication (which can be defined as * for all non-single
vector multiplications unambiguously), I've not heard any *compelling*
cases for operators.

Also, I'm sort of a curmudgeony jerk (I like my Python as it is), so
while you perhaps shouldn't take me *too* seriously when I say "Use
Logix", maybe you should take my advice to find a set of *useful*
operators, and specify *why* they would be useful (hopefully in a
general sense).

 - Josiah




More information about the Python-ideas mailing list