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 Python vs ?)


On Mon, Jul 10, 2000 at 08:59:33AM +0300, Moshe Zadka wrote:
> On Sun, 9 Jul 2000, Lalo Martins wrote:
> 
> > Also, many "smart" languages (like Python and Scheme itself)
> > have a few "tricks" and proposital idiosyncrasies (like
> > __getitem__, __len__, __getattr__ etc in Python) which would
> > probably be inpractical to emulate; so we can more or less
> > safely say there will never be a real Python->Scheme
> > translator, but instead from a language with the same syntax as
> > Python but not exactly the same semantics, to something Guile
> > can read (perhaps Scheme, perhaps some internal representation).
> 
> 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.

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...

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.

Other things that can be a pain to implement are module
systems. Python's module system is a philosophy on its own, and
Perl's would be an outright nightare IIRC...

[]s,
                                               |alo
                                               +----
--
          Hack and Roll  ( http://www.hackandroll.org )
            News for, uh, whatever it is that we are.


http://zope.gf.com.br/lalo           mailto:lalo@hackandroll.org
         pgp key: http://zope.gf.com.br/lalo/pessoal/pgp

Brazil of Darkness (RPG)    ---     http://zope.gf.com.br/BroDar

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