From: Alan Jump <alan.jump@gmail.com>
Subject: Re: Generics vs. O-O?
Date: Fri, 2 Aug 2013 08:36:14 -0700 (PDT)
Date: 2013-08-02T08:36:14-07:00 [thread overview]
Message-ID: <d474202c-4cee-49ef-9f93-9bf9ee6a89a6@googlegroups.com> (raw)
In-Reply-To: <8bef1dc4-547b-478e-b81a-09077212f821@googlegroups.com>
On Friday, August 2, 2013 8:08:38 AM UTC-7, Shark8 wrote:
> > Yet another language design
> > problem that there is no simple way to declare such singleton types in Ada.
> Really?
> In Ada 2012 I can say the following:
> package Test is
> Type K is Private;
> J : Integer := 12;
> private
> use type System.address;
> type K is new integer with TYPE_INVARIANT => K'Address = J'Address;
> end test;
>
> Type K sure looks like a singleton to me.
This is going off on a bit of a tangent, but as a new student of the language, I think a case could be made that many stand-alone packages or procedures in Ada are singletons, simply because of Ada's inherent strong typing. After all, what's a singleton? By definition, to be a singleton pattern, two criteria must be met: one and only one instance with a global point of access, and initialization on first use. (Source: http://sourcemaking.com/design_patterns/singleton)
With that said, and again being a new student of the language, I find myself in favor of generic use, simply from a standpoint of code reuse. A well-designed algorithm that finds itself applied several times within a given procedure, which varies only in parameter types, should only have to be coded once.
Just my 2p worth...save up the change for a pack of monitor wipes or something.
- -
73 de N5ILN
Alan
next prev parent reply other threads:[~2013-08-02 15:36 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-01 14:45 Generics vs. O-O? Eryndlia Mavourneen
2013-08-01 19:24 ` Dmitry A. Kazakov
2013-08-01 19:52 ` Eryndlia Mavourneen
2013-08-01 20:14 ` sbelmont700
2013-08-01 23:35 ` Yannick Duchêne (Hibou57)
2013-08-01 20:10 ` optikos
2013-08-01 20:26 ` Dmitry A. Kazakov
2013-08-01 20:35 ` Jeffrey Carter
2013-08-01 21:22 ` Bill Findlay
2013-08-01 23:38 ` Yannick Duchêne (Hibou57)
2013-08-01 22:20 ` Georg Bauhaus
2013-08-02 8:11 ` Dmitry A. Kazakov
2013-08-02 9:50 ` Georg Bauhaus
2013-08-02 14:09 ` Dmitry A. Kazakov
2013-08-02 15:08 ` Shark8
2013-08-02 15:36 ` Alan Jump [this message]
2013-08-02 17:00 ` Jeffrey Carter
2013-08-02 17:51 ` Dmitry A. Kazakov
2013-08-02 18:06 ` Alan Jump
2013-08-02 19:08 ` Dmitry A. Kazakov
2013-08-02 16:15 ` Dmitry A. Kazakov
2013-08-03 0:04 ` Yannick Duchêne (Hibou57)
2013-08-03 7:35 ` Georg Bauhaus
2013-08-03 8:57 ` Dmitry A. Kazakov
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox