comp.lang.ada
 help / color / mirror / Atom feed
From: bobduff@world.std.com (Robert A Duff)
Subject: Re: rep clause in generics
Date: 1997/03/14
Date: 1997-03-14T00:00:00+00:00	[thread overview]
Message-ID: <E71L14.5Mp@world.std.com> (raw)
In-Reply-To: 01bc3057$61a78db0$81946482@vkpc131


In article <01bc3057$61a78db0$81946482@vkpc131>,
Jonas Nygren <ehsjony@ehs.ericsson.se> wrote:
>The compiler complained with:
>
>   gen_buffers.ads:9:39: static integer expression required here
>
>I thought that Element_Type'Size was a static integer expression. Am I or
>the compiler in error?

You are in error.  S'Size is static only if S is a static scalar
subtype.  Element_Size is neither scalar nor static.  (Generic formal
subtypes are never static.)  See 4.9.

It's sad that you can't do this, I admit.  But allowing it would be
complicated -- generic contract model problems rear their ugly heads.
(As a compiler writer, I find it annoying that 'Size is *ever* static --
it messes up one's compiler design.  You'd like to say 'Size is a
machine-dependent thing, and relegate it to the back end, or some such
late, machine-dependent, phase.  Unfortunately, its value is needed
during overload resolution: e.g.,

    P(Some_Array'First(S'Size mod 2));

Which P is called depends on the static value of S'Size!

)

- Bob




  parent reply	other threads:[~1997-03-14  0:00 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-03-14  0:00 rep clause in generics Jonas Nygren
1997-03-14  0:00 ` Stephen Leake
1997-03-15  0:00   ` Robert Dewar
1997-03-20  0:00   ` Aaro Koskinen
1997-03-14  0:00 ` Robert A Duff [this message]
1997-03-15  0:00   ` Robert Dewar
1997-03-14  0:00 ` Robert Dewar
1997-03-20  0:00   ` Nick Roberts
replies disabled

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