comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Bus error
Date: Sat, 30 Jun 2007 10:44:12 +0200
Date: 2007-06-30T10:43:31+02:00	[thread overview]
Message-ID: <dg9w8bo1x1ve$.riaqkydp46n7.dlg@40tude.net> (raw)
In-Reply-To: wcck5tm6x3s.fsf@shell01.TheWorld.com

On Fri, 29 Jun 2007 21:37:43 -0400, Robert A Duff wrote:

> "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> writes:
>
>>...It creates new objects,
> 
> Heh?  Renaming does not create new objects.

> A function call creates a new object, but that's a
> different story.  And it's a good thing -- that function-result
> object might need to be finalized, which means it has to be
> an object (not just a value).

The language misguiding the programmer here. He should declare an
initialized constant when a function result is "renamed," it is not
renaming, At least it is not just renaming happens here.

If you have

   X1 : String renames Get_Line;
   X2 : String renames Get_Line;
   X3 : String renames Get_Line;

the effect will be X1, X2, X3 all different objects. This should not be
called renaming.

Same is implementation of subprograms through renaming, which also creates
a new object.

But when I do:

   X : Element renames Collection (Key);

I'd like to be certain that X indeed renames a container's element.

> If I ran the circus, literals would "return" objects, too.
> And there would be no syntactic distinction betweem "name"
> and "expression".

Sign me up!

>>... it violates
>> contracts,
> 
> Not sure what you mean there.  I guess the fact that constraints on T
> are ignored, above.  If so, it doesn't violate any contract, so long as
> you understand that "X: Positive renames..." is not a contract requiring
> positive numbers.  ;-)

(:-)) The problem is then, what the meaning has the subtype specification
in renaming?

Nobody would object if renaming were:

   This : renames That;  -- Guess what is the subtype and constraints

Interestingly, but the "constant" (in/out/in out) constraint indeed need
not to and cannot be specified in renaming:

   X : Integer renames Y;

So whatever naive theory we'd invent Ada's renaming conforms to neither.

>>...it introduces names conflicts.
> 
> Yes.  We considered fixing that during Ada 9X.

But not 200X?

> Here's another small complaint about renaming: It's often used as an
> "import", as in:
> 
>     function Blah (...) return ... renames Some.Library.Package.Blah;

Yep, and the diamond diagram:

package A is
   X : T;
end A;

with A;
package B is
   X : T renames A.X;
end B;

with A;
package C is
   X : T renames A.X;
end C;

with B, C; use B, C;
package D is
   -- X is hidden
end D;

> We do not wish to change the name of Blah, just to import it into
> another scope.  But mentioning Blah twice is error-prone in that
> context.  The programmer really wants to say something like
> "import Blah from Some.Library.Package".  Consider:
> 
>     function "+"(...) return ... renames Some_Package."+";
>     function "-"(...) return ... renames Some_Package."+";
> 
> Note cut&paste error on second line.

Yes, there is no mechanism to merge declaration parts of packages. IMO
there should be some way to import things of one package specification into
another without tedious renamings, especially, without renaming things
which cannot be renamed at all, like types. But I don't think that renaming
should be used for that. I would prefer multiple parent packages and
something for flattening nested and separate packages:

package My_IO is
   ...
   with new Ada.Text_IO.Integer_IO (...);
      -- Merge all declarations from this instance with My_Io's public
      -- and private parts

----------------
There are three separate issues too difficult to handle by just one
construct:

1. Renaming of objects
2. Operations on packages specification
3. Delegation

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



  reply	other threads:[~2007-06-30  8:44 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <0367891DA5DA7E408D42A860FA002F44B0CC48@sma2901.cr.eurocopter.corp>
2007-06-29  9:35 ` AW: Bus error Duncan Sands
2007-06-29 12:55   ` Dmitry A. Kazakov
2007-06-29 15:37     ` Markus E Leypold
2007-06-29 15:44     ` Georg Bauhaus
2007-06-29 20:07       ` Dmitry A. Kazakov
2007-06-30  1:37         ` Robert A Duff
2007-06-30  8:44           ` Dmitry A. Kazakov [this message]
2007-06-30 11:52             ` Georg Bauhaus
2007-06-30 13:16               ` Georg Bauhaus
2007-06-30 14:31               ` Dmitry A. Kazakov
2007-06-30 18:07                 ` Georg Bauhaus
2007-06-30 19:31                   ` Robert A Duff
2007-07-01  9:07                   ` Dmitry A. Kazakov
2007-06-30 15:40               ` Robert A Duff
2007-06-30 17:54                 ` Georg Bauhaus
2007-07-02  8:01           ` Jean-Pierre Rosen
2007-07-02 12:00             ` Dmitry A. Kazakov
2007-07-02 12:30               ` Jean-Pierre Rosen
2007-07-02 14:22             ` Robert A Duff
2007-06-30 13:14         ` Georg Bauhaus
2007-06-30 14:31           ` Dmitry A. Kazakov
2007-06-30 15:34             ` Robert A Duff
2007-07-01  8:34               ` Dmitry A. Kazakov
2007-07-01 15:39                 ` Robert A Duff
2007-07-01 19:41                   ` Dmitry A. Kazakov
2007-06-30 15:29           ` Robert A Duff
2007-06-30 17:41             ` Georg Bauhaus
2007-06-30 13:31         ` Markus E Leypold
2007-07-02  0:16           ` Robert A Duff
2007-06-29  9:23 AW: " Grein, Christoph (Fa. ESG)
2007-06-29 10:17 ` Dmitry A. Kazakov
  -- strict thread matches above, loose matches on Subject: below --
2007-06-27 14:23 Maciej Sobczak
2007-06-27 15:45 ` Georg Bauhaus
2007-06-27 17:19   ` Maciej Sobczak
2007-06-28  1:58     ` Robert A Duff
2007-06-28 20:06       ` Maciej Sobczak
2007-06-28 21:19         ` Robert A Duff
2007-06-29  8:05           ` Maciej Sobczak
2007-06-29  9:42             ` Georg Bauhaus
2007-06-29 16:59               ` Adam Beneschan
2007-06-30 12:33                 ` Georg Bauhaus
2007-06-30  2:02             ` Robert A Duff
2007-06-29  8:04         ` Dmitry A. Kazakov
2007-06-27 20:02 ` Anh Vo
2007-06-27 20:48   ` Maciej Sobczak
2007-06-28  2:01     ` Robert A Duff
1990-08-27 23:48 BUS ERROR J o s e D u a r t e ! ! !
1990-08-16 14:52 saharbaugh%roo.dnet
1990-08-13 21:11 J o s e D u a r t e !!!
1990-08-10 12:32 bus error saharbaugh%roo.dnet
1990-08-09 14:50 saharbaugh%roo.dnet
1990-08-10 21:38 ` Chuck Peterson
replies disabled

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