[pypy-dev] Project suggestions
Boria Feigin
boria at fbg.uklinux.net
Tue Sep 27 16:19:49 CEST 2005
Hi,
> As I understand pypy it can theoretically take a number of alternate front
> ends as well as back ends. I don't know how much work has gone into that,
That's my understanding as well -- from Armin Rigo's reply to my initial
post.
> but a whimsical idea that sprang to mind just now as an alternate project idea
> (that I'm not convinced should ever be done >:-) is this:
:)
> Last summer, for fun, I wrote a generic language parser that can handle
> almost anything you throw at it. The basic underlying idea was "what if in
> lisp you removed all the brackets and used a python-like syntax instead".
> (Or depending on the time of day "What if we removed all the keywords
> from python, could we still parse something that looked close to python>")
>
> The idea was that you would use :<newline><indent> stuff </dedent> where you
> would use nested brackets. I did leave in a small amount of infix support
OK. It's an alternative notation for writing down the AST.
[snipped]
> Similarly:
>
> pen down
> repeat 4:
> forward 10
> rotate 90
> end
>
> is two function calls - one to pen, and one to repeat. Repeat takes 3
> arguments here - 4, the code block and the "end" tag.
Aha, I see. Essentially, you should get Lisp's famed ability for
domain-specific languages (themselves a big and hot topic).
> Anyway, the code is here: cerenity.org/SWP/ - that also includes a pdf of the
> lightning talk I gave at ACCU (though not the slightly nicer version I gave
> at europython I notice... Hmm... ) Slide 8 shows how nuts this can get with
> mixing of an L-System description language with an SML-esque syntax for a
> structural stack, with a logo type language, and started off with a
> python-esque bootstrap. At europython I also had an SQL-like statement in
> there for added silliness. (The point was that the example parsed cleanly,
This isn't silly at all -- just look at the C# 3.0 spec
(http://msdn.microsoft.com/vcsharp/future/, the section on ``Query
Expressions'' specifically)
> not whether it meant anything)
There's the rub. For example, one could write,
if foo > 10:
threshold = 20
end
select:
from titles
where (id < threshold)
end
The question then becomes, is there a way to leverage PyPy (type
inference) to _statically_ verify that `id' and `threshold' are of the
same type?
> Anyway, as an alternate front end this could be a mad (but fun) little
> project. I'm not convinced it would actually be a GOOD idea to do
> though :)
In any case, thanks for the suggestion :)
P.S. This may be off-topic, but you may also like to have a look at this
http://www.martinfowler.com/articles/languageWorkbench.html piece by
Martin Fowler.
--
Boris
More information about the Pypy-dev
mailing list