This is the mail archive of the guile@sources.redhat.com mailing list for the Guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Translators, yet once more (Re: PHP fork project- Guile vs Pythonvs ?)


On Mon, 10 Jul 2000, Lalo Martins wrote:

> > With all due respect, that is not true. Have a look at JPython, a
> > Python-to-Java translator. It supports the Python language perfectly, and
> > Java is a much more prmitive language then Scheme.
> 
> Well, that's because JPython is not a Python-to-Java
> translator, but a Python-to-Java-Bytecode compiler. In may
> aspects, it's a reimplementation of the Python interpreter.

That's wrong: previous versions worked like that, the interactive
interpreter works like that, but the regular JPython compiler works
through a Java intermediary.


> Of course there are proposital idiosyncrasies in languages that
> it won't be worth copying exactly; perhaps emulating "more or
> less". Actually, my example wasn't a good one because
> __getitem__, __len__, __getattr__ and friends can be converted
> into generic methods by the translator, so that "foo[5]" would
> translate to e.g. "(python::getitem foo 5)" which would
> evaluate to the method you provided for foo.__getitem__ thanks
> to GOOPS...
> 
> Now, getattr would be trickier because every object in Python
> is a first-class namespace to which you can add arbitrary
> elements (foo.bar=2 when foo's class doesn't have a "bar"
> attribute - in fact, classes _never_ have attributes in the
> sense we're used to in other OOPLs) and even controlled more
> finely via __getattr__. Perhaps the attributes of Python
> objects could be stored in Scheme's object-properties instead
> of proper GOOPS slots? Or, of course, a __dir__ slot with an
> alist or something...

What I'm thinking is to "generic method" the whole "access", so

foo[5] --> ((python:getattr foo '__getitem__) 5)

> See? Whatever route you take to emulate this behaviour won't be
> exactly the same as Python, and will probably make the script
> harder to integrate with Scheme code (and the application, if
> what you're doing is application extension), and incur some
> performance penalty.

Python *is* a performance penalty <wink> -- it's just that you gain a lot
for this penalty. I fail to see why the Python objects should use GOOPS.
However, Python should know about GOOPS, to talk with everyday guile
objects.

> Other things that can be a pain to implement are module
> systems. 

Again, I'm for reimplementation of the module system, but where you say "C
module" in current Python, you should be able to say "guile module" in
guile-Python. Again, something like JPython's philosophy.


> Python's module system is a philosophy on its own, and
> Perl's would be an outright nightare IIRC...

Perl is near impossible, if only because there is no clear-cut language
definition.

--
Moshe Zadka <moshez@math.huji.ac.il>
There is no GOD but Python, and HTTP is its prophet.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]