On Thu, 30 Jun 2011 06:31:58 +0300, Ary Manzana <[email protected]> wrote:

The solution is to be able to override new. In Ruby you can do this:

---
class Foo
end

class Bar
def self.new
Foo.new
end
end
---

Now you do:

Bar.new #=> #<Foo:0x0000010180bf90>

and as you see, you get a Foo instance.

Ruby is a dynamic language, that is why i said irrelevant :)

In fact, I don't understand well what's the problem with point 1 in the article. If you want to show the users how to use your class, document its usage. Don't just throw the code at them...

---
Declare the implementation as private:
#include "implementation.h"

class Foo
{
private:
    ... the implementation ...

// the interface
public:
    void bar()
    {
        ... manipulate the implementation ...
    }
};
---

With "point 1" if you mean this one:

For starters it is not an interface but the implementation itself.
Many C users rightly criticize when they see codes like this, most C++ users won't say anything. It is perfectly fine for your own code, that everything is in your hand.

* Nothing is hidden, you can see and change everything.
* Whenever you make a change to the implementation, you also change the interface. You have to distribute both.
...

Taft types in C is great. As a result every single C API relies on it.

Well well, i was expecting some discussions.
Looks like my troubles with languages are not among the popular ones!

Reply via email to