comp.lang.ada
 help / color / mirror / Atom feed
* Ada wikibook help needed (O-O)
@ 2017-04-23 10:22 G.B.
  2017-04-23 10:52 ` Dmitry A. Kazakov
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: G.B. @ 2017-04-23 10:22 UTC (permalink / raw)


Hi all,

for a number of years, the Wikibook subsection on O-O in Ada
seems to have suffered from lack of clarity, according to a number
of comments still present, a few written a number of years ago.

Some here may say that this state of presentation is caused by
Ada using type extension and so forth in the first place.
But still, if the book does place Ada in contrast with C++,
say, or explains Ada O-O, then it should be possible to
precisely use Ada vocabulary to make readers profit by adding
unmistakable carity.

https://en.wikibooks.org/wiki/Ada_Programming/Object_Orientation

If you have a moment, could you kindly substantiate whether or not,
e.g.,  the following are absolutely and demonstrably correct and well put?


The page goes to some length to explain static dispatching
vs. dynamic dispatching, but fails to introduce "dispatching"
first, as a term, or to reference some suitable definition.
Then,

   "A conversion to the class-wide type makes [components] visible again."

Is "visible" correct?


Is it correct to say “static call” at all, other than when waving hands,
(not helpfully IMHO) in

   "within Op1, the first call to Op2 is therefore also a static call "

where

  procedure Op1 (This: Root) is
  begin
    ...
    Op2 (This);               -- not redispatching
    ...
  end Op1;

The idea being that “static call” is not really defined in Ada AFAICT,
other than to mean a call of a static function in a static expression.
So, not the same thing as discussing O-O, or static binding,
or dynamic dispatch.


    "In other OO languages, a method is either dispatching or not.
     In Ada, a routine is either _available_ for dispatching or not. "

The wording of LRM N(28) seems to not be in line with the second
of these  statements.

...

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Ada wikibook help needed (O-O)
  2017-04-23 10:22 Ada wikibook help needed (O-O) G.B.
@ 2017-04-23 10:52 ` Dmitry A. Kazakov
  2017-04-23 16:09   ` G.B.
  2017-04-24 22:06   ` Randy Brukardt
  2017-04-24 22:03 ` Randy Brukardt
  2017-06-30 13:54 ` Norman Worth
  2 siblings, 2 replies; 11+ messages in thread
From: Dmitry A. Kazakov @ 2017-04-23 10:52 UTC (permalink / raw)


On 2017-04-23 12:22, G.B. wrote:

> The page goes to some length to explain static dispatching
> vs. dynamic dispatching, but fails to introduce "dispatching"
> first, as a term, or to reference some suitable definition.

It does in the section "Polymorphism, class-wide programming and dynamic 
dispatching". Dispatching is a mechanism of polymorphic call 
implementation for the case of dynamic polymorphism.

> Then,
>
>   "A conversion to the class-wide type makes [components] visible again."
>
> Is "visible" correct?

Why not? The text IMO just explains specific implementation of 
class-wide objects in Ada. That is, the same representation of 
class-wide and specific objects.

> Is it correct to say “static call” at all,

Why not? A statically bound call.

> The idea being that “static call” is not really defined in Ada AFAICT,
> other than to mean a call of a static function in a static expression.
> So, not the same thing as discussing O-O, or static binding,
> or dynamic dispatch.
>
>    "In other OO languages, a method is either dispatching or not.

The first sentence is wrong. A non-dispatching operation is not a 
method. In OO nomenclature that is called "free" operation. So, all 
operations are subdivided into methods and free operations. In Ada 
methods are called primitive operation (in some arguments/result). There 
rest is free operations.

>    In Ada, a routine is either _available_ for dispatching or not. "

The second sentence is meaningless to me. There is no difference between 
Ada and other languages in that respect.

Maybe the writer meant the difference that some languages like C++ are 
inconsistent in the sense that the same name may mean polymorphic 
(dispatching) or non-polymorphic (specific) call depending on the 
context. In Ada it is unambiguous.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Ada wikibook help needed (O-O)
  2017-04-23 10:52 ` Dmitry A. Kazakov
@ 2017-04-23 16:09   ` G.B.
  2017-04-23 17:03     ` Dmitry A. Kazakov
  2017-04-24 12:34     ` Jacob Sparre Andersen
  2017-04-24 22:06   ` Randy Brukardt
  1 sibling, 2 replies; 11+ messages in thread
From: G.B. @ 2017-04-23 16:09 UTC (permalink / raw)


On 23.04.17 12:52, Dmitry A. Kazakov wrote:
> On 2017-04-23 12:22, G.B. wrote:
>
>> The page goes to some length to explain static dispatching
>> vs. dynamic dispatching, but fails to introduce "dispatching"
>> first, as a term, or to reference some suitable definition.
>
> It does in the section "Polymorphism, class-wide programming and dynamic dispatching". Dispatching is a mechanism of polymorphic call implementation for the case of dynamic polymorphism.
>
>> Then,
>>
>>   "A conversion to the class-wide type makes [components] visible again."
>>
>> Is "visible" correct?
>
> Why not?

Converting to T'Class does not make any components of T'Class visible
if they are private, at the point in source of that conversion.
In this sense, it is unfortunate that "view" in "view conversion"
might trigger an association with "visibility" in the reader's mind.
Yet, what is meant is that after view conversion, the object can
be seen as of any type in T'Class, whichever type it might be. What
view conversion does not mean is that any of the object so obtained
will have its components be seen. That's a matter of visibility, really,
not types, and is decided on a different axis.


>> Is it correct to say “static call” at all,
>
> Why not?

Because:

> A statically bound call.

... sounds both better and actually different to me: no context is needed
in order to disambiguate. The qualification avoids confusion. It helps
readers when they need to learn picking the right words and it helps
programmers express their intention also for later, when the context
(mechanics of dispatching) has disappeared.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Ada wikibook help needed (O-O)
  2017-04-23 16:09   ` G.B.
@ 2017-04-23 17:03     ` Dmitry A. Kazakov
  2017-04-24  5:13       ` G.B.
  2017-04-24 12:34     ` Jacob Sparre Andersen
  1 sibling, 1 reply; 11+ messages in thread
From: Dmitry A. Kazakov @ 2017-04-23 17:03 UTC (permalink / raw)


On 2017-04-23 18:09, G.B. wrote:
> On 23.04.17 12:52, Dmitry A. Kazakov wrote:
>> On 2017-04-23 12:22, G.B. wrote:
>>
>>> The page goes to some length to explain static dispatching
>>> vs. dynamic dispatching, but fails to introduce "dispatching"
>>> first, as a term, or to reference some suitable definition.
>>
>> It does in the section "Polymorphism, class-wide programming and
>> dynamic dispatching". Dispatching is a mechanism of polymorphic call
>> implementation for the case of dynamic polymorphism.
>>
>>> Then,
>>>
>>>   "A conversion to the class-wide type makes [components] visible
>>> again."
>>>
>>> Is "visible" correct?
>>
>> Why not?
>
> Converting to T'Class does not make any components of T'Class visible
> if they are private, at the point in source of that conversion.
> In this sense, it is unfortunate that "view" in "view conversion"
> might trigger an association with "visibility" in the reader's mind.

Yes, you are right, conversion to T'Class does not add anything it can 
only subtract something.

But, maybe, direct visibility was meant? Say, T is declared in P and S 
is declared in Q:

package P is
    type T is tagged ...;
    procedure Foo (X : T);
end P;

package Q is
    type S is new P.T with ...;
end Q;

If I have "use P" and no "use Q" then conversion to T'Class will make 
Foo applicable in non-prefix notation.

> Yet, what is meant is that after view conversion, the object can
> be seen as of any type in T'Class, whichever type it might be.

No, that requires another conversion. To see X as S from T'Class you 
must convert it to S. T'Class is a substitute for the intersection of 
all types [values of].

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Ada wikibook help needed (O-O)
  2017-04-23 17:03     ` Dmitry A. Kazakov
@ 2017-04-24  5:13       ` G.B.
  2017-04-24  7:55         ` Dmitry A. Kazakov
  0 siblings, 1 reply; 11+ messages in thread
From: G.B. @ 2017-04-24  5:13 UTC (permalink / raw)


On 23.04.17 19:03, Dmitry A. Kazakov wrote:

> Then,
>
>   "A conversion to the class-wide type makes [components] visible
> again."
>
> Is "visible" correct?

> But, maybe, direct visibility was meant?(...)
>
> If I have "use P" and no "use Q" then conversion to T'Class will make Foo applicable in non-prefix notation.
>
>> Yet, what is meant is that after view conversion, the object can
>> be seen as of any type in T'Class, whichever type it might be.
>
> No, that requires another conversion. To see X as S from T'Class you must convert it to S. T'Class is a substitute for the intersection of all types [values of].


Since we are both trying to learn what was meant, I think this proves
my point ;-).



(Even if the "use" based interpretation does uncover a possible meaning
of the Wikibook, I think a reference to use-visibility here will
drive the reader away from the topic: the question being

   "what happens when a primitive operation Op1 calls another
     primitive operation Op2 ?"

(The example given is not conducive to an interpretations that rests
on use-visibility, I think.)


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Ada wikibook help needed (O-O)
  2017-04-24  5:13       ` G.B.
@ 2017-04-24  7:55         ` Dmitry A. Kazakov
  0 siblings, 0 replies; 11+ messages in thread
From: Dmitry A. Kazakov @ 2017-04-24  7:55 UTC (permalink / raw)


On 24/04/2017 07:13, G.B. wrote:

>   "what happens when a primitive operation Op1 calls another
>     primitive operation Op2 ?"

OK, but that is a stupid question since no type is mentioned. Though it 
remains stupid with a type:

- What happens when a primitive operation Op2 of X is called on X?
- The operation Op2 happens! You idiot! (:-))

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Ada wikibook help needed (O-O)
  2017-04-23 16:09   ` G.B.
  2017-04-23 17:03     ` Dmitry A. Kazakov
@ 2017-04-24 12:34     ` Jacob Sparre Andersen
  1 sibling, 0 replies; 11+ messages in thread
From: Jacob Sparre Andersen @ 2017-04-24 12:34 UTC (permalink / raw)


"G.B." <bauhaus@notmyhomepage.invalid> writes:

>> A statically bound call.
>
> ... sounds both better and actually different to me: no context is
> needed in order to disambiguate.

Agreed.

Greetings,

Jacob
-- 
"... but it was, on the other hand, very good at being a slow
 and dim-witted pupil."
"I had no idea they were supposed to be in short supply"

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Ada wikibook help needed (O-O)
  2017-04-23 10:22 Ada wikibook help needed (O-O) G.B.
  2017-04-23 10:52 ` Dmitry A. Kazakov
@ 2017-04-24 22:03 ` Randy Brukardt
  2017-06-30 13:54 ` Norman Worth
  2 siblings, 0 replies; 11+ messages in thread
From: Randy Brukardt @ 2017-04-24 22:03 UTC (permalink / raw)


"G.B." <bauhaus@notmyhomepage.invalid> wrote in message 
news:odhv2v$9vi$1@dont-email.me...
...
>   "A conversion to the class-wide type makes [components] visible again."
>
> Is "visible" correct?

I believe so (without actually reading the entire section). The components 
always exist, after all, but you can't reference them. Visibility is the way 
that's described in Ada, at least for the most part.

> Is it correct to say "static call" at all, other than when waving hands,
> (not helpfully IMHO) in
>
>   "within Op1, the first call to Op2 is therefore also a static call "

No. A "static call" is defined in 4.9. The author meant "statically tagged 
call" as described in 3.9.2 (3-6/2, 14-19), or even more formally, a "call 
with a statically determined controlling tag value". Usually, that's 
informally described as a "statically bound call".

>    "In other OO languages, a method is either dispatching or not.
>     In Ada, a routine is either _available_ for dispatching or not. "

I think this is fine; an operation is either a dispatching operation or it 
isn't. (See 3.9.2(1/2)). If it isn't, then it never dispatches; otherwise, 
whether it dispatches depends on whether the call is statically or 
dynamically bound.

                             Randy.


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Ada wikibook help needed (O-O)
  2017-04-23 10:52 ` Dmitry A. Kazakov
  2017-04-23 16:09   ` G.B.
@ 2017-04-24 22:06   ` Randy Brukardt
  1 sibling, 0 replies; 11+ messages in thread
From: Randy Brukardt @ 2017-04-24 22:06 UTC (permalink / raw)


"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote in message 
news:odi10p$ojq$1@gioia.aioe.org...
> On 2017-04-23 12:22, G.B. wrote:
...
>> Is it correct to say "static call" at all,
>
> Why not? A statically bound call.

Statically bound call is OK, but  "static call" is easily confused with "a 
call on a static function" (as in 4.9). I'd think the latter before the 
former. I definitely suggest avoiding that sort of terminology if one is 
trying to describe Ada using its terminology.

                            Randy.


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Ada wikibook help needed (O-O)
  2017-04-23 10:22 Ada wikibook help needed (O-O) G.B.
  2017-04-23 10:52 ` Dmitry A. Kazakov
  2017-04-24 22:03 ` Randy Brukardt
@ 2017-06-30 13:54 ` Norman Worth
  2017-06-30 15:34   ` AdaMagica
  2 siblings, 1 reply; 11+ messages in thread
From: Norman Worth @ 2017-06-30 13:54 UTC (permalink / raw)


G.B. wrote:
> Hi all,
>
> for a number of years, the Wikibook subsection on O-O in Ada
> seems to have suffered from lack of clarity, according to a number
> of comments still present, a few written a number of years ago.
>
> Some here may say that this state of presentation is caused by
> Ada using type extension and so forth in the first place.
> But still, if the book does place Ada in contrast with C++,
> say, or explains Ada O-O, then it should be possible to
> precisely use Ada vocabulary to make readers profit by adding
> unmistakable carity.
>
> https://en.wikibooks.org/wiki/Ada_Programming/Object_Orientation
>
> If you have a moment, could you kindly substantiate whether or not,
> e.g.,  the following are absolutely and demonstrably correct and well put?
>
>
> The page goes to some length to explain static dispatching
> vs. dynamic dispatching, but fails to introduce "dispatching"
> first, as a term, or to reference some suitable definition.
> Then,
>
>   "A conversion to the class-wide type makes [components] visible again."
>
> Is "visible" correct?
>
>
> Is it correct to say “static call” at all, other than when waving hands,
> (not helpfully IMHO) in
>
>   "within Op1, the first call to Op2 is therefore also a static call "
>
> where
>
>  procedure Op1 (This: Root) is
>  begin
>    ...
>    Op2 (This);               -- not redispatching
>    ...
>  end Op1;
>
> The idea being that “static call” is not really defined in Ada AFAICT,
> other than to mean a call of a static function in a static expression.
> So, not the same thing as discussing O-O, or static binding,
> or dynamic dispatch.
>
>
>    "In other OO languages, a method is either dispatching or not.
>     In Ada, a routine is either _available_ for dispatching or not. "
>
> The wording of LRM N(28) seems to not be in line with the second
> of these  statements.
>
> ...
I agree; this section is very poorly written from top to bottom.  Others 
have commented on Ada language technical problems with the article, but 
the worst problems stem from its English structure.  Most textbooks do a 
far better job.  We need to build the article from simple definitions 
and contexts through simple Ada constructs until we have explained the 
Ada philosophy for OOP and given adequate examples.  It needn't be too 
complicated, but it should be complete.  Here, even the definitions of 
OOP and OO design are unclear and do not follow the historical and 
common definitions. The section should be scrapped and rewritten, rather 
than revised.  I would tackle it, but I don't feel sufficiently 
experienced in Ada OOP to do so.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Ada wikibook help needed (O-O)
  2017-06-30 13:54 ` Norman Worth
@ 2017-06-30 15:34   ` AdaMagica
  0 siblings, 0 replies; 11+ messages in thread
From: AdaMagica @ 2017-06-30 15:34 UTC (permalink / raw)


Am Freitag, 30. Juni 2017 15:54:44 UTC+2 schrieb Norman Worth:
> G.B. wrote:
> > Hi all,
> >
> > for a number of years, the Wikibook subsection on O-O in Ada
> > seems to have suffered from lack of clarity, according to a number
> > of comments still present, a few written a number of years ago.
> >
> > Some here may say that this state of presentation is caused by
> > Ada using type extension and so forth in the first place.
> > But still, if the book does place Ada in contrast with C++,
> > say, or explains Ada O-O, then it should be possible to
> > precisely use Ada vocabulary to make readers profit by adding
> > unmistakable carity.
> >
> > https://en.wikibooks.org/wiki/Ada_Programming/Object_Orientation
> >
> > If you have a moment, could you kindly substantiate whether or not,
> > e.g.,  the following are absolutely and demonstrably correct and well put?
> >
> >
> > The page goes to some length to explain static dispatching
> > vs. dynamic dispatching, but fails to introduce "dispatching"
> > first, as a term, or to reference some suitable definition.
> > Then,
> >
> >   "A conversion to the class-wide type makes [components] visible again."
> >
> > Is "visible" correct?
> >
> >
> > Is it correct to say “static call” at all, other than when waving hands,
> > (not helpfully IMHO) in
> >
> >   "within Op1, the first call to Op2 is therefore also a static call "
> >
> > where
> >
> >  procedure Op1 (This: Root) is
> >  begin
> >    ...
> >    Op2 (This);               -- not redispatching
> >    ...
> >  end Op1;
> >
> > The idea being that “static call” is not really defined in Ada AFAICT,
> > other than to mean a call of a static function in a static expression.
> > So, not the same thing as discussing O-O, or static binding,
> > or dynamic dispatch.
> >
> >
> >    "In other OO languages, a method is either dispatching or not.
> >     In Ada, a routine is either _available_ for dispatching or not. "
> >
> > The wording of LRM N(28) seems to not be in line with the second
> > of these  statements.
> >
> > ...
> I agree; this section is very poorly written from top to bottom.  Others 
> have commented on Ada language technical problems with the article, but 
> the worst problems stem from its English structure.  Most textbooks do a 
> far better job.  We need to build the article from simple definitions 
> and contexts through simple Ada constructs until we have explained the 
> Ada philosophy for OOP and given adequate examples.  It needn't be too 
> complicated, but it should be complete.  Here, even the definitions of 
> OOP and OO design are unclear and do not follow the historical and 
> common definitions. The section should be scrapped and rewritten, rather 
> than revised.  I would tackle it, but I don't feel sufficiently 
> experienced in Ada OOP to do so.

I'm with you, I do not like the page's structure either. I wrote part of this, but I shied away from redoing the page from scratch.
Part of this shiness stems from the fact that I have no idea how to structure the page.

So I encourage you to lay out here the structure you would like. We, the Ada fans, can discuss it and fill the flesh to the bones.

To the definitions of OO and especially OOP: There is no commonly accepted definition, as far as I can see. Every language has its own nomenclature. A class in Ada is very different from a class in Java or C++. C++'s methods are primitive operations in Ada. And why should we follow the historical definitions going back to Simula?

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2017-06-30 15:34 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-23 10:22 Ada wikibook help needed (O-O) G.B.
2017-04-23 10:52 ` Dmitry A. Kazakov
2017-04-23 16:09   ` G.B.
2017-04-23 17:03     ` Dmitry A. Kazakov
2017-04-24  5:13       ` G.B.
2017-04-24  7:55         ` Dmitry A. Kazakov
2017-04-24 12:34     ` Jacob Sparre Andersen
2017-04-24 22:06   ` Randy Brukardt
2017-04-24 22:03 ` Randy Brukardt
2017-06-30 13:54 ` Norman Worth
2017-06-30 15:34   ` AdaMagica

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox