From: Kaz Kylheku on
On 2009-11-17, Janis Papanagnou <janis_papanagnou(a)hotmail.com> wrote:
> Dominic Fandrey wrote:
>> Janis Papanagnou wrote:
>>> Dominic Fandrey wrote:
> [...]
>>>> Inheritance can be VERY useful, but often is not required at all.
>>> Well, YMMV, but OO just *starts* with inheritance; one of the few basic
>>> OO features is polymorphism, and inheritance is a precondition for that.
>>
>> No it isn't. It only is a precondition if there is type safety.
>
> You're again wrong with your claim.

Hi Janis,

It is indeed the case that inheritance is not required for polymorphism.

Inheritance is not a requirement object-orientation at all.

The statement ``it's only a precondition if there is type safety'' is a bit
misleading. I suspect it's intended to say ``if there is compile-time typing''.

In that case the statement is in fact true.

That is to say, inheritance is in fact workaround for supporting limited
forms of dynamic polymorphism in static languages. (Inheritance is
more than that, of course, but it /serves/ this way).

In order for an X to be a kind of Y, the static language requires us
to somehow declare that type X is derived from type Y. Then we are permitted,
by the compiler, to substitute an X into parts of the program that expect a Y.

In a dynamic language, we don't need types X and Y to be related by inheritance
in order to work with the same set of methods. We can simply pass X and Y to
the same parts of the program, period. (But we may still have inheritance
because it provides useful, experssive tricks: implementation sharing,
multi-methods, ...).

But a dynamic language does not lack type safety. I, ahem, ``object'' to that.

At the barest essence, ``object oriented'' means that type is a property
of a datum, rather than of the program operating on the datum.

Further embellishments to this definition tend to be increasingly
ideological. People promoting a particular language which has OO features wll
tend to say that OO is exactly that set of features, and nothing more or less.
So idelogical definitions of OO get laced with irrelevant concepts:
``It's not OO if there is no access control''. ``It's not OO if there
is no inheritance''. ``It's not OO if there is no encapsulation''.
``It's not OO if it doesn't have a GUI builder''. Etc.
From: Dominic Fandrey on
Kaz Kylheku wrote:
> On 2009-11-17, Janis Papanagnou <janis_papanagnou(a)hotmail.com> wrote:
>> Dominic Fandrey wrote:
>>> Janis Papanagnou wrote:
>>>> Dominic Fandrey wrote:
>> [...]
>>>>> Inheritance can be VERY useful, but often is not required at all.
>>>> Well, YMMV, but OO just *starts* with inheritance; one of the few basic
>>>> OO features is polymorphism, and inheritance is a precondition for that.
>>> No it isn't. It only is a precondition if there is type safety.
>> You're again wrong with your claim.
>
> Hi Janis,
>
> It is indeed the case that inheritance is not required for polymorphism.
>
> Inheritance is not a requirement object-orientation at all.
>
> The statement ``it's only a precondition if there is type safety'' is a bit
> misleading. I suspect it's intended to say ``if there is compile-time typing''.
>
> In that case the statement is in fact true.
>
> That is to say, inheritance is in fact workaround for supporting limited
> forms of dynamic polymorphism in static languages. (Inheritance is
> more than that, of course, but it /serves/ this way).
>
> In order for an X to be a kind of Y, the static language requires us
> to somehow declare that type X is derived from type Y. Then we are permitted,
> by the compiler, to substitute an X into parts of the program that expect a Y.
>
> In a dynamic language, we don't need types X and Y to be related by inheritance
> in order to work with the same set of methods. We can simply pass X and Y to
> the same parts of the program, period. (But we may still have inheritance
> because it provides useful, experssive tricks: implementation sharing,
> multi-methods, ...).

Even dynamic languages can offer type safety (some do so optionally, like
PHP5, at least for objects), in which case inheritance becomes necessary, too.
So my statement is valid - type safety is the hook that makes inheritance
necessary for polymorphism.

Of course, static languages always have type safety, so I agree with
everything else you say.

Just look at Python, polymorphism without inheritance is quite common
there. Programmers just expect people to use their code with objects
conforming to the expected interface, which is as I understand it,
what you are talking about.

--
A: Because it fouls the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
From: bsh on
Dominic Fandrey <kamik...(a)bsdforen.de> wrote:
> bsh wrote:
> > Dominic Fandrey <kamik...(a)bsdforen.de> wrote:
> > > ...
> > (How is it that your English is so fluent and idiomatic?)
> I have no idea what idiomatic means. The explanations I found
> do not really enlighten me. I glimpse that it might mean that
> the meaning of my words is clouded. If so I apologize, I am
> not a native speaker as you no doubt have recognized.

This deserves a response -- peace! I was in no way being
sarcastic or duplicitous. Your English is most certainly better
than my German, especially as you mention that you've not
practised English in a native English-speaking country,
which I suspected.

Don't think of me as being patronizing if I take the opportunity
to mention Heiner Steven's "translate" script to translate
from English to German. HS runs the pre-eminent site for shell
scripting: shelldorado.com.

"translate.sh":
http://shelldorado.com/scripts/quickies/translate.txt

Nowadays, dictionary.com is probably a better resort.

> > I would be interested in what you have to saw about your
> > "bsda_obj.sh" in regards to the below list of prior attempts
> > to add an OOP paradigm to k/sh. It is a (mostly) comprehensive
> > list.
> > ...
> Pursuing this will take me some time. Maybe as much as two or
> three weeks. Your list and questions are very appreciated.
> Be assured, I will not forget to respond when I am ready.

Two or three weeks? Again, I am sincere in my surprise
insofar as I have been working on certain non-trivial scripts
for more than a decade -- for my shell IDE, as mentioned.

Being a compiler/language designer, I do program in O-O
low-level languages, including Java and C++, so I know the
paradigm of O-O design and implementation; however, I have
no experience in ksh93t+ O-O programming. I stopped developing
a O-O framework of my own, presumably much like yours, when
O-O in ksh93 become available, but programming or using one
will be invaluable for my function library and framework within
my IDE.

It seems like your framework is to shell as (older) "dynace"
was to C: a intermediate (and fairly successful!) attempt to
hack a language into a O-O paradigm. I programmed in this
when C++ was still new -- and buggy.

"dynace.c": "DYNAmic C Extension" -- O-O enhancement to C
http://algorithms.us/software/

Perhaps you would like to repost your query to the
development team and forum for ksh93 and utilities? A
list from most to least pertainent is:

"shell-discuss Mailing List":
http://opensolaris.org/mailman/listinfo/shell-discuss
https://www.opensolaris.org/jive/forum.jspa?forumID=138

"ksh93-integration-discuss Mailing List"
http://mail.opensolaris.org/pipermail/ksh93-integration-discuss/
^ Also: https://www.opensolaris.org/jive/forum.jspa?forumID=103

"AST-developers Mailing List"
https://mailman.research.att.com/pipermail/ast-developers/

"AST-users Mailing List"
https://mailman.research.att.com/pipermail/ast-users/

=Brian