On Monday, 17 August 2015 at 06:08:35 UTC, Ali Çehreli wrote:
On 08/16/2015 10:57 PM, Ozan wrote:
[...]
From the way you use it below, a better name for that class
would be FamilyMember but I get the point.
Yes, you're right.
[...]
> father.greeting;
> son.greeting;
What you mean is that the call above causes a compilation error:
Error: no property 'greeting' for type 'deneme.Family'
> }
>
[...]
My experience with OOP is limited to C++ and D. I think what
you are describing is how dynamically typed languages work. It
is impossible in compiled languages like C++ and D. When a type
is used in an expression, the compiler ensures that the call is
bound to a function.
> In D, it starts with the class definition.
Actually, 'interface' is a better fit in most cases:
interface FamilyMember
{
// ...
}
class Dad : FamilyMember
{
// ...
}
[...]
Ali
Interfaces are very helpful to avoid large inheritance trees in
OOP. On the other hand, there are not designed as workarounds
for OOP implementation problems.
The kind of OOP in D is a classical way to handle it. Dynamic
languages tries to close the gap between theoretical and
practical OOP for the price of speed.
I think that Adam's jsvar idea is a great way to bring more
flexibility into D. The same in OOP would be also great.
Regards, Ozan