comp.lang.ada
 help / color / mirror / Atom feed
* Ada 2005+ interface example
@ 2013-01-27 14:08 gautier_niouzes
  2013-01-27 16:54 ` Dmitry A. Kazakov
  0 siblings, 1 reply; 4+ messages in thread
From: gautier_niouzes @ 2013-01-27 14:08 UTC (permalink / raw)


Hello,
Does someone have an example of Ada 2005 interface type ?
Just to see how it works in practice.
TIA
_________________________ 
Gautier's Ada programming 
http://sf.net/users/gdemont/



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

* Re: Ada 2005+ interface example
  2013-01-27 14:08 Ada 2005+ interface example gautier_niouzes
@ 2013-01-27 16:54 ` Dmitry A. Kazakov
  2013-01-28 17:27   ` Gautier write-only
  0 siblings, 1 reply; 4+ messages in thread
From: Dmitry A. Kazakov @ 2013-01-27 16:54 UTC (permalink / raw)


On Sun, 27 Jan 2013 06:08:31 -0800 (PST), gautier_niouzes@hotmail.com
wrote:

> Does someone have an example of Ada 2005 interface type ?

You might find interfaces actively used in the AICWL, e.g.

http://www.dmitry-kazakov.de/ada/aicwl.htm#2.5

A layer of the widget usually implements several interfaces. For example:

type Elliptic_Scale_Layer (<>) is
   new Abstract_Bordered_Layer
   and Scalable_Layer
   and Widened_Layer with private;

> Just to see how it works in practice.

It works just fine, except the cases when full MI is required. Then it
becomes quite messy because the only way to provide implementations is
through generics.

Another case for interfaces in Ada 2005 is smart pointers. I don't know how
well the newly introduced by Ada 2012 dereferencing works. But in Ada 2005
you would use an interface to describe both the target type and the
controlled pointer.

   type Thing is limited interface;
   ... -- operations on thing

   type Handle is ... and Thing ...;
   ... -- implements operations by delegation to the target
private
   type Implementation is ... and Thing ...;
   ... -- implements operations

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



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

* Re: Ada 2005+ interface example
  2013-01-27 16:54 ` Dmitry A. Kazakov
@ 2013-01-28 17:27   ` Gautier write-only
  2013-01-28 22:02     ` John B. Matthews
  0 siblings, 1 reply; 4+ messages in thread
From: Gautier write-only @ 2013-01-28 17:27 UTC (permalink / raw)


Thanks a lot, I'll have a look.
Perhaps it would be useful that I explain why I would eventually use
interfaces.
I am reviving a "toy compiler" of the late 80's, SmallAda, which was
in Turbo Pascal and a Mac Pascal too, now translated in Ada and
working.
I would like to turn the low level machine code emission into a
"generic" form.
As I see it, it would be around a stream, with many methods, all
abstract for the root type, which would be implemented as code
emission for target processors (real or virtual).
And perhaps interfaces would be useful there (it is rather an
intuition).
Cheers
Gautier



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

* Re: Ada 2005+ interface example
  2013-01-28 17:27   ` Gautier write-only
@ 2013-01-28 22:02     ` John B. Matthews
  0 siblings, 0 replies; 4+ messages in thread
From: John B. Matthews @ 2013-01-28 22:02 UTC (permalink / raw)


In article 
<ea40e94d-2121-4cac-bd24-64e51fbb302c@l13g2000yqe.googlegroups.com>,
 Gautier write-only <gautier_niouzes@hotmail.com> wrote:

> Thanks a lot, I'll have a look. Perhaps it would be useful that I 
> explain why I would eventually use interfaces. I am reviving a "toy 
> compiler" of the late 80's, SmallAda, which was in Turbo Pascal and a 
> Mac Pascal too, now translated in Ada and working. I would like to 
> turn the low level machine code emission into a "generic" form.
> As I see it, it would be around a stream, with many methods, all 
> abstract for the root type, which would be implemented as code 
> emission for target processors (real or virtual). And perhaps 
> interfaces would be useful there (it is rather an intuition).

I often return to the Rationale for Ada 2005, 2.4 Interfaces:

<http://www.adaic.org/resources/add_content/standards/05rat/html/Rat-2-4.html>

-- 
John B. Matthews
trashgod at gmail dot com
<http://sites.google.com/site/drjohnbmatthews>



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

end of thread, other threads:[~2013-01-28 22:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-27 14:08 Ada 2005+ interface example gautier_niouzes
2013-01-27 16:54 ` Dmitry A. Kazakov
2013-01-28 17:27   ` Gautier write-only
2013-01-28 22:02     ` John B. Matthews

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