comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Idiom for a class and an object in Ada
Date: Thu, 21 Oct 2004 16:11:57 +0200
Date: 2004-10-21T16:11:57+02:00	[thread overview]
Message-ID: <4dhfe3d87kxr$.1hmxrp8e7rf2y.dlg@40tude.net> (raw)
In-Reply-To: u1xfsutnu.fsf@earthlink.net

On Thu, 21 Oct 2004 12:45:09 GMT, Matthew Heaney wrote:

> "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> writes:
> 
>> On Thu, 21 Oct 2004 01:46:39 GMT, Matthew Heaney wrote:
>> 
>>> I don't understand this comment.  How else do you dynamically create
>>> instances of T?
>> 
>> Why should they be created dynamically (heap)? Heap vs. stack is a
>> matter of object's scope. It should have little or no impact on the
>> design of the type. If it has then probably because of language
>> deficiency, as in C++, or, yes, in Ada where there was no way to
>> initialize limited objects. That will be corrected soon, I hope.
> 
> My point was that there is *no* difference between Ada95 and C++ here.
> My reasons for writing the code as I did (that is, writing a factory
> function that returns a pointer) had nothing to do with language.

I see it different:

1. Why there should be a factory function?
2. Why that should return a pointer?

The reasons for 1 could be:

1.a. There are construction parameters [not the case]
1.b. The result is polymorphic [not the case]
1.c. The language does not provide default object construction [not the
case]
1.d. Renaming/aliasing, abstracting from variables [might be, but what's
the gain?]

The reasons for 2 could be:

2.a. The scope of the objects is dynamic and "new" does not fit [not the
case]
2.b. The language has problems with construction on the stack. [might well
be, if objects are limited]

If we consider all that we will see that it is rather a language problem,
that forces us to use pointers.

>> For Marin's case the objects are not dynamic. So if read-only objects
>> would suffice, one can just use functions returning limited objects:
> 
> Finally, someone else sees the light...

But if that is the case, then constants would do the trick. You need no
function for that. Initialization is an independent issue. Function
returning object is *not* a constructor, it could simulate one, but what
for if the language supports construction?

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



  reply	other threads:[~2004-10-21 14:11 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-10-18 11:47 Idiom for a class and an object in Ada Marin David Condic
2004-10-18 12:14 ` Martin Krischik
2004-10-18 19:40   ` Matthew Heaney
2004-10-19 12:59   ` Marin David Condic
2004-10-19 14:46     ` Martin Dowie
2004-10-19 15:55       ` Matthew Heaney
2004-10-19 18:31         ` Martin Dowie
2004-10-19 15:52     ` Matthew Heaney
2004-10-18 12:26 ` Marius Amado Alves
2004-10-19  2:09   ` Jeffrey Carter
2004-10-19  3:28     ` Matthew Heaney
2004-10-19 12:53       ` Marin David Condic
2004-10-19 14:44         ` Matthew Heaney
2004-10-19 15:01           ` Dmitry A. Kazakov
2004-10-19 15:40             ` Matthew Heaney
2004-10-20  7:58               ` Dmitry A. Kazakov
2004-10-20 12:31                 ` Marin David Condic
2004-10-20 13:53                   ` Dmitry A. Kazakov
2004-10-20 15:23                   ` Matthew Heaney
2004-10-21 12:24                     ` Marin David Condic
2004-10-21 17:15                       ` Matthew Heaney
2004-10-20  5:39         ` Simon Wright
2004-10-20  7:24           ` Matthew Heaney
2004-10-20  8:39             ` Dmitry A. Kazakov
2004-10-21  1:36             ` Jeffrey Carter
2004-10-21  1:46               ` Matthew Heaney
2004-10-21  7:51                 ` Dmitry A. Kazakov
2004-10-21 12:45                   ` Matthew Heaney
2004-10-21 14:11                     ` Dmitry A. Kazakov [this message]
2004-10-22  1:04                 ` Jeffrey Carter
2004-10-22  1:36                   ` Matthew Heaney
2004-10-21 19:31               ` Kevin Cline
2004-10-21 22:02                 ` Matthew Heaney
2004-10-22  0:10                   ` Matthew Heaney
2004-10-21  8:25             ` Martin Dowie
2004-10-20 17:04           ` Matthew Heaney
2004-10-20 19:37             ` Simon Wright
2004-10-20 20:04               ` Matthew Heaney
2004-10-22  5:37                 ` Simon Wright
2004-10-20  1:10       ` Jeffrey Carter
2004-10-20  7:04         ` Matthew Heaney
2004-10-20 12:42           ` Marin David Condic
2004-10-20 12:55             ` Matthew Heaney
2004-10-20 15:27             ` Matthew Heaney
2004-10-21  1:36               ` Matthew Heaney
2004-10-19 12:38   ` Marin David Condic
2004-10-18 16:59 ` Matthew Heaney
2004-10-18 18:02 ` Martin Dowie
2004-10-19 13:06   ` Marin David Condic
2004-10-19 14:51     ` Martin Dowie
2004-10-20 16:20 ` Michael Paus
2004-10-20 17:15   ` Matthew Heaney
2004-10-20 17:55     ` Michael Paus
2004-10-21 12:33   ` Marin David Condic
  -- strict thread matches above, loose matches on Subject: below --
2004-10-21 13:59 Stephen Leake
replies disabled

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