Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Ada > Re: User-define...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 9 of 23 Topic 5595 of 5931
Post > Topic >>

Re: User-defined type attributes

by "Randy Brukardt" <randy@[EMAIL PROTECTED] > Mar 14, 2008 at 10:04 PM

"Dmitry A. Kazakov" <mailbox@[EMAIL PROTECTED]
> wrote in message
news:pqup5kf1u34t$.19kwms4bw12hs.dlg@[EMAIL PROTECTED]
> On Thu, 13 Mar 2008 20:46:41 -0500, Randy Brukardt wrote:
>
> > "Dmitry A. Kazakov" <mailbox@[EMAIL PROTECTED]
> wrote in message
> > news:965suhjl0bxt$.74se2ylyksin.dlg@[EMAIL PROTECTED]
> > ...
> >> Why? The only thing you need is formal generic ADTs. Ada's generics
lack
> >> ADTs, which is the reason why you need to pass operations together
with
the
> >> formal types. There exist formal built-in types like "private", "<>",
> >> "digits <>" etc, but there is no user-defined ones. Add these and all
> >> primitive operations will go with the actual type just per magic. It
would
> >> be IMO a natural step for anybody who wanted generics to evolve in an
> >> Ada-way. (Not for me, as you know, I prefer generics removed from the
> >> language.)
> >
> > Generic formal derived types are the way to bring an ADT into a
generic.
> > After all, they do bring in all of the primitive operations of the
ADT.
> >
> > The only problem is that they can't be used on unrelated types, but
that's
> > not very relevant if you are using tagged types (and you might as well
being
> > doing so if you're defining any sort of composite type).
>
> Right, but this also implies that there is no need to have generics at
all.
> A class-wide object does all what needed:
>
>    generic
>       type S is new T with private;
>    procedure Foo (X : in out S);
>
> can be replaced by:
>
>    procedure Foo (X : in out T'Class);

Not if you need other generic parameters along with the type. And this is
a
way to do mixins, which otherwise can't be done in Ada 95 because type
can't
derive from a class-wide type:

   generic
      type S is new T with private;
   package Foo is
      type New_S is new S with private;
      procedure New_Operation (Op : in out New_S);
   end Foo;

It's a nice way to add persistence, for instance. (Interfaces only allow
you
to add, umm, interfaces, not code.)

                     Randy.
 




 23 Posts in Topic:
User-defined type attributes
Eric Hughes <eric.eh9@  2008-03-12 11:58:29 
Re: User-defined type attributes
"Dmitry A. Kazakov&q  2008-03-12 22:23:43 
Re: User-defined type attributes
Eric Hughes <eric.eh9@  2008-03-13 11:32:23 
Re: User-defined type attributes
"Dmitry A. Kazakov&q  2008-03-13 20:58:15 
Re: User-defined type attributes
"Randy Brukardt"  2008-03-13 20:46:41 
Re: User-defined type attributes
"Randy Brukardt"  2008-03-13 20:46:41 
Re: User-defined type attributes
"Randy Brukardt"  2008-03-13 20:46:41 
Re: User-defined type attributes
"Dmitry A. Kazakov&q  2008-03-14 10:00:46 
Re: User-defined type attributes
"Randy Brukardt"  2008-03-14 22:04:53 
Re: User-defined type attributes
"Dmitry A. Kazakov&q  2008-03-15 10:33:38 
Re: User-defined type attributes
"Randy Brukardt"  2008-03-13 20:46:37 
Re: User-defined type attributes
Eric Hughes <eric.eh9@  2008-03-13 20:55:27 
Re: User-defined type attributes
"Dmitry A. Kazakov&q  2008-03-14 10:01:47 
Re: User-defined type attributes
Eric Hughes <eric.eh9@  2008-03-13 21:41:21 
Re: User-defined type attributes
"Randy Brukardt"  2008-03-14 22:20:19 
Re: User-defined type attributes (replacing genericity)
Eric Hughes <eric.eh9@  2008-03-14 10:51:25 
Re: User-defined type attributes (replacing genericity)
"Dmitry A. Kazakov&q  2008-03-14 19:58:18 
Re: User-defined type attributes (replacing genericity)
"Randy Brukardt"  2008-03-14 23:01:56 
Re: User-defined type attributes
Eric Hughes <eric.eh9@  2008-03-14 11:04:33 
Re: User-defined type attributes (replacing genericity)
Eric Hughes <eric.eh9@  2008-03-14 13:19:47 
Re: User-defined type attributes
Eric Hughes <eric.eh9@  2008-03-16 21:38:37 
Re: User-defined type attributes
"Randy Brukardt"  2008-03-17 16:03:10 
Re: User-defined type attributes
Eric Hughes <eric.eh9@  2008-03-17 14:58:54 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Tue Oct 14 11:19:33 CDT 2008.