From: "Jeffrey R. Carter" <spam.jrcarter.not@acm.nospam.org>
Subject: Re: "Ada Gems": Constructor functions
Date: Wed, 05 Sep 2007 22:47:18 GMT
Date: 2007-09-05T22:47:18+00:00 [thread overview]
Message-ID: <WlGDi.86830$Fc.64657@attbi_s21> (raw)
In-Reply-To: <1189015827.384331.17490@k79g2000hse.googlegroups.com>
Tomek Wa�kuski wrote:
>
> with Ada.Strings.Unbounded;
> use Ada.Strings.Unbounded;
>
> package T is
> type Object (<>) is tagged limited private;
>
> function Create_Object (Name : in String) return Object;
> function Construct return Object;
> function Name (This : in Object) return String;
>
> type Object is tagged limited
> record
> Name : Unbounded_String;
> end record;
> end T;
T has a private type (Object) but no private part.
> package body T is
> function Create_Object (Name : in String) return Object is
> return (Name => To_Unbounded_String (Name));
> end Create_Object;
>
> function Construct return Object is
> return Create_Object (Name => "Object without a name!");
> end Construct;
>
> function Name (This : in Object) return String is
> begin
> return To_String (This.Name);
> end Name;
>
> type Object is tagged limited
> record
> Name : Unbounded_String;
> end record;
> end T;
Type Object is repeated here.
> with T;
>
> procedure Test_T is
> Some_Object : constant T.Object := Construct;
> begin
> null;
> end Test_T;
Construct is not directly visible here.
> Is it REALLY a compiler bug? Or am I only dumb? :) Maybe I'm doing
> something, somewhere wrong?
It's really a compiler error. A compiler should be able to handle the
errors in your code without crashing.
FWIW, I got this with another version:
gnatmake -O2 -gnaton -fstack-check test_t.adb
gcc -c -O2 -gnaton -fstack-check test_t.adb
test_t.adb:4:39: "Construct" is not visible
test_t.adb:4:39: non-visible declaration at t.ads:8
t.ads:11:04: declaration of full view must appear in private part
gnatmake: "test_t.adb" compilation error
--
Jeff Carter
"Death awaits you all, with nasty, big, pointy teeth!"
Monty Python & the Holy Grail
20
next prev parent reply other threads:[~2007-09-05 22:47 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-09-05 18:10 "Ada Gems": Constructor functions Tomek Wałkuski
2007-09-05 22:47 ` Jeffrey R. Carter [this message]
[not found] ` <1189064716.528979.201170@19g2000hsx.googlegroups.com>
2007-09-06 7:54 ` Tomek Wa kuski
2007-09-06 13:55 ` Robert A Duff
2007-09-06 14:12 ` Tomek Wa kuski
2007-09-06 0:04 ` Robert A Duff
2007-09-06 16:16 ` anon
2007-09-07 10:38 ` Tomek Wa kuski
2007-09-07 15:17 ` Robert A Duff
2007-09-08 18:20 ` Tomek Wa kuski
2007-09-10 13:46 ` Tomek Wa kuski
2007-09-11 7:51 ` Georg Bauhaus
2007-09-11 10:26 ` Tomek Wa kuski
2007-09-11 21:33 ` Anh Vo
2007-09-12 7:39 ` Tomek Wa kuski
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox