* What's class? @ 1999-02-23 0:00 Rouault 1999-02-23 0:00 ` David Botton ` (2 more replies) 0 siblings, 3 replies; 10+ messages in thread From: Rouault @ 1999-02-23 0:00 UTC (permalink / raw) What's class in Ada95? I should be intersted in hearing more about Class. Thanks. -- signature.all ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: What's class? 1999-02-23 0:00 What's class? Rouault @ 1999-02-23 0:00 ` David Botton 1999-02-24 0:00 ` Matthew Heaney 1999-02-25 0:00 ` Gyeongmoon Ryu 2 siblings, 0 replies; 10+ messages in thread From: David Botton @ 1999-02-23 0:00 UTC (permalink / raw) To: Rouault Take a look at OO programming in Ada on the Lovelace tutorial at: http://adahome.com/Tutorials/Lovelace/lesson7.htm and in particular section 7.3 on Polymorphism in Ada http://adahome.com/Tutorials/Lovelace/s7s3.htm other resource on learning Ada can be found at: http://www.botton.com/ada/learn David Botton Rouault wrote: > > What's class in Ada95? > > I should be intersted in hearing > more about Class. > > Thanks. > > -- signature.all ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: What's class? 1999-02-23 0:00 What's class? Rouault 1999-02-23 0:00 ` David Botton @ 1999-02-24 0:00 ` Matthew Heaney 1999-02-23 0:00 ` bill 1999-02-25 0:00 ` Gyeongmoon Ryu 2 siblings, 1 reply; 10+ messages in thread From: Matthew Heaney @ 1999-02-24 0:00 UTC (permalink / raw) Rouault <rouault@yahoo.com> writes: > What's class in Ada95? > > I should be intersted in hearing > more about Class. A "class" in Ada denotes a family of types. For tagged types, the type T'Class denotes the type T and all its descendents. So if I have this hierarchy: type T is tagged private; type U is new T with private; type W is new U with private; type V is new T with private; An object of "class-wide" type T'Class can be any of the "specific" types T, U, V, or W. An object of class-wide type U'Class can be any of the specific types U or W. This distinction is nice, because it allows you to see explicitly when you have a specific type (T), or a type and any of its descents (T'Class). It makes it obvious that procedures like: procedure Print (Stack : in Stack_Type'Class); are intended to work for Stack_Type and any type that derives from Stack_Type. Print is not a primitive operation of type Stack_Type, and therefore doesn't get inherited during derivations from Stack_Type. There is one and only one Print operation, and it works for any kind of stack (that is, those that derive from stack, i.e. in Stack_Type'Class). But if I see this: function Is_Full (Stack : in Bounded_Stack) return Boolean; then I know that Is_Full is only intended to take an object of (specific) type Bounded_Stack. A stack that derives from Bounded_Stack would indeed inherit operation Is_Full. T'Class is a "class-wide" type, which denotes a family of "specific" types: type T, and any type that derives from T. ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: What's class? 1999-02-24 0:00 ` Matthew Heaney @ 1999-02-23 0:00 ` bill 1999-02-24 0:00 ` Jean-Pierre Rosen ` (2 more replies) 0 siblings, 3 replies; 10+ messages in thread From: bill @ 1999-02-23 0:00 UTC (permalink / raw) In article <m3k8x8fovj.fsf@mheaney.ni.net>, Matthew says... > >But if I see this: > > function Is_Full (Stack : in Bounded_Stack) return Boolean; > >then I know that Is_Full is only intended to take an object of >(specific) type Bounded_Stack. A stack that derives from Bounded_Stack >would indeed inherit operation Is_Full. > Since any type that extends a parent type, also inherits its operations, then in this case, writing function is_full( stack: in bounded_stack'class) and function is_full( stack: in bounded_stack) make no difference! correct? Bill. ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: What's class? 1999-02-23 0:00 ` bill @ 1999-02-24 0:00 ` Jean-Pierre Rosen 1999-02-24 0:00 ` Ed Falis 1999-02-25 0:00 ` Matthew Heaney 2 siblings, 0 replies; 10+ messages in thread From: Jean-Pierre Rosen @ 1999-02-24 0:00 UTC (permalink / raw) bill a �crit dans le message <7avvpf$pfl@drn.newsguy.com>... >Since any type that extends a parent type, also inherits its operations, >then in this case, writing > > function is_full( stack: in bounded_stack'class) >and > function is_full( stack: in bounded_stack) > > >make no difference! > >correct? There is a huge difference between a class-wide operation and an inherited operation. An inheritede operation conceptually is part of the definition of the type, and can be redefined by any descendant. In a sense, the original operation serves as a "default value" for descendants that don't care to redefine it. OTOH, a class wide operation operates conceptually on the full class; it is not part of the type definition, it is not inherited, and in cannot be redefined. The nice thing with inherited operations is that you can redefine them if you whish; the nice things with class-wide opertions is that you are certain that nobody redefined the operation behind your back to make it do something else. Given your constraints, choose the appropriate one... --------------------------------------------------------- J-P. Rosen (Rosen.Adalog@wanadoo.fr) Visit Adalog's web site at http://perso.wanadoo.fr/adalog ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: What's class? 1999-02-23 0:00 ` bill 1999-02-24 0:00 ` Jean-Pierre Rosen @ 1999-02-24 0:00 ` Ed Falis 1999-02-25 0:00 ` dennison 1999-02-25 0:00 ` Matthew Heaney 2 siblings, 1 reply; 10+ messages in thread From: Ed Falis @ 1999-02-24 0:00 UTC (permalink / raw) On 23 Feb 1999 20:39:11 -0800, bill <bill@newsguy.com> wrote: > > Since any type that extends a parent type, also inherits its operations, > then in this case, writing > > function is_full( stack: in bounded_stack'class) > and > function is_full( stack: in bounded_stack) > > > make no difference! > > correct? > > Bill. The difference is if you plan to allow a change to the representation or implementation of bounded_stack in its descendants, and expect to implement the "stack full" operation in terms of one or more alternate representations in the is_full function. The classwide operation could in many cases be implemented in terms of other dispatching operations specific to the descendants. Or, if you intend the descendants to provide their own implementations of the function in all cases, use the specific argument and declare the function as abstract. - Ed ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: What's class? 1999-02-24 0:00 ` Ed Falis @ 1999-02-25 0:00 ` dennison 0 siblings, 0 replies; 10+ messages in thread From: dennison @ 1999-02-25 0:00 UTC (permalink / raw) In article <1103_919865565@DZOG-CHEN>, falis@ma.aonix.com (Ed Falis) wrote: > On 23 Feb 1999 20:39:11 -0800, bill <bill@newsguy.com> wrote: > > > > > Since any type that extends a parent type, also inherits its operations, > > then in this case, writing > > > > function is_full( stack: in bounded_stack'class) > > and > > function is_full( stack: in bounded_stack) > > > > > > make no difference! > > > > correct? > > The difference is if you plan to allow a change to the representation or > implementation of bounded_stack in its descendants, and expect to implement > the "stack full" operation in terms of one or more alternate representations > in the is_full function. There's also the minor difference that a user of a type extended from bounded_stack will have to with bounded_stack's package as well as the new type's package to get at the first definition. The second definition they get straight from the new type's package. Also, the first function can be written in any package at all (assuming you don't need special visibility to write its body, while the second has to be written in bounded_stack's package spec to be inherited. T.E.D. -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: What's class? 1999-02-23 0:00 ` bill 1999-02-24 0:00 ` Jean-Pierre Rosen 1999-02-24 0:00 ` Ed Falis @ 1999-02-25 0:00 ` Matthew Heaney 2 siblings, 0 replies; 10+ messages in thread From: Matthew Heaney @ 1999-02-25 0:00 UTC (permalink / raw) bill <bill@newsguy.com> writes: > Since any type that extends a parent type, also inherits its operations, > then in this case, writing > > function is_full( stack: in bounded_stack'class) > and > function is_full( stack: in bounded_stack) > > > make no difference! > > correct? Not quite. That would only be true if the derived type didn't override the Is_Full operation. The purpose in making it primitive (instead of class-wide) is to allow the derived type to override the operation. A class-wide operation is not override-able. There's also a name-space issue. Primitive operations of the derived type are implicitly declared at the point of derivation. However, a class-wide operation isn't inherited, and so does not exist where the (derived) type is (unless of course the derivation is in the same package as the class-wide operation). In your example above, you wouldn't get an Is_Full operation at the same place as the (derived) type, and you'd have to go back to the original package in which the Is_Full operation is declared, in order to use it. In the pattern community, class-wide operations are called "template methods." You can read all about the finer points of template method patterns in Ada95 by reading the Template Method post in the June 98 patterns archive at the ACM. <http://www.acm.org/archives/patterns.html> ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: What's class? 1999-02-23 0:00 What's class? Rouault 1999-02-23 0:00 ` David Botton 1999-02-24 0:00 ` Matthew Heaney @ 1999-02-25 0:00 ` Gyeongmoon Ryu 1999-02-24 0:00 ` Matthew Heaney 2 siblings, 1 reply; 10+ messages in thread From: Gyeongmoon Ryu @ 1999-02-25 0:00 UTC (permalink / raw) .......... I don't see things the same way... for the following reasons: A class is an implementation of an Types ( (such as tagged, record, subprogram...) It specifies a data structure and the permissible operational methods that apply to each of its objects) ) In the Ada, object types are implemented as PACKAGE. -- IF package = C++(class) -- FALSE or exception -- IF package = OOP(class) -- TRUE ? I don no.. :( -- Gyeongmoon Ryu. -- Please forgive me for my poor English. -- Email @abstract. ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: What's class? 1999-02-25 0:00 ` Gyeongmoon Ryu @ 1999-02-24 0:00 ` Matthew Heaney 0 siblings, 0 replies; 10+ messages in thread From: Matthew Heaney @ 1999-02-24 0:00 UTC (permalink / raw) "Gyeongmoon Ryu" <rkm579@mail.hitel.net> writes: > .......... > > I don't see things the same way... for the following reasons: > > A class is an implementation of an Types ( (such as tagged, record, > subprogram...) It specifies a data structure and the permissible > operational methods that apply to each of its objects) ) > > In the Ada, object types are implemented as PACKAGE. > > -- IF package = C++(class) -- FALSE or exception > -- IF package = OOP(class) -- TRUE ? I don no.. :( This is wrong. The term "class" in Ada has a very specific meaning, different from its use in other languages. It was the Ada-meaning of the term that the original poster was interested in. It is also untrue that, in Ada, a type is implemented as a package. In Ada, a type is implemented as a ... type! ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~1999-02-25 0:00 UTC | newest] Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 1999-02-23 0:00 What's class? Rouault 1999-02-23 0:00 ` David Botton 1999-02-24 0:00 ` Matthew Heaney 1999-02-23 0:00 ` bill 1999-02-24 0:00 ` Jean-Pierre Rosen 1999-02-24 0:00 ` Ed Falis 1999-02-25 0:00 ` dennison 1999-02-25 0:00 ` Matthew Heaney 1999-02-25 0:00 ` Gyeongmoon Ryu 1999-02-24 0:00 ` Matthew Heaney
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox