How does Ruby compare to Python?? How good is DESIGN of Ruby compared to Python?

John Roth newsgroups at jhrothjr.com
Wed Feb 25 17:57:59 EST 2004


"Joe Mason" <joe at notcharles.ca> wrote in message
news:slrnc3ob0q.i6n.joe at gate.notcharles.ca...
> In article <c1h1sb$1it26i$1 at ID-169208.news.uni-berlin.de>, Greg Ewing
(using news.cis.dfn.de) wrote:
>
> > * In Python, functions are first-class, and
> > methods are implemented in terms of functions. In Ruby,
> > methods are the fundamental concept, and there are no
> > first-class functions. The result is that Python lets
> > you obtain a bound method from an object and use it like
> > any other function. You can't do that in Ruby. You can
> > get a method object in Ruby, but you can't call it using
> > normal calling syntax.
>
> I don't see the distinction.  "normal calling syntax" in ruby involves
> an object, so "unbound function" isn't a meaningful concept.  I mean, if
> you get a method the begins with the self parameter, you still need an
> object to call it, right?  Even if you're calling it as "foo(obj,
> params)" instead of "obj.foo(params)".  I don't see what the ability to
> use the other syntax gets you, except the ability to pass functions
> around independantly of objects, which I'm pretty sure you can do with
> methods in Ruby anyway.

I think you've missed the point here. Python has a concept
of a "callable," that is, some object that can be called. Bound
methods are useful precisely because they carry their instance
around with them and also because they look exactly like any
other callable; there is no special syntax that is required either
to create one or to invoke it.

Unbound methods, on the other hand, require the caller to provide
the instance explicitly which limits their usefulness quite a bit.

John Roth
>
> Joe





More information about the Python-list mailing list