help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Useless functions in matlab function library.


From: Paul Kienzle
Subject: Re: Useless functions in matlab function library.
Date: Wed, 11 Jul 2007 19:07:24 -0400


On Jul 11, 2007, at 8:56 AM, Guillem Borrell Nogueras wrote:

I am not against OO. In fact I am a happy python and C++ user. It's just that the OO implementation in matlab is broken (IMO). It's the only programming language where objects are not instances of a class.

<pedantic>

There are other languages which have objects without classes. See for example the wikipedia entry on prototype based programming:

        http://en.wikipedia.org/wiki/Prototype-based_programming

One could argue that any use of interface style programming is classless. In python, you can use any object that implements an interface in a function which expects an object of that interface (duck typing: if it quacks like a duck it is a duck). The class infrastructure is mere convenience, since you can add all the instances you need to a bare object:

>>> def h(self,b): return self.x+b
...
>>> class A: x=3
...
>>> a = A()
>>> import new
>>> p = new.instancemethod(h,a,a.__class__)
>>> setattr(a,p.func_name,p)
>>> a.h(4)
7

</pedantic>


        - Paul



reply via email to

[Prev in Thread] Current Thread [Next in Thread]