comp.lang.ada
 help / color / mirror / Atom feed
* library level required or not?
@ 2004-03-01 17:17 Marius Amado Alves
  2004-03-01 23:37 ` Randy Brukardt
  0 siblings, 1 reply; 9+ messages in thread
From: Marius Amado Alves @ 2004-03-01 17:17 UTC (permalink / raw)
  To: comp.lang.ada

Language lawers, please help me.

I have in my notes that an object, of a type declared in package Ada or 
descendants, is not required to be defined at library level, even if the type 
is controlled. (I know I can declare unbounded strings, which are clearly 
controlled, in a 'main' procedure.)

I vaguely recall deriving this rule from the RM, but now I cannot find the 
clause. Is the rule true? By what clause?

Thanks a lot.



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: library level required or not?
  2004-03-01 18:49 ` library level required or not? Marius Amado Alves
@ 2004-03-01 18:41   ` Preben Randhol
  2004-03-01 19:21     ` Marius Amado Alves
  0 siblings, 1 reply; 9+ messages in thread
From: Preben Randhol @ 2004-03-01 18:41 UTC (permalink / raw)


On 2004-03-01, Marius Amado Alves <maa@liacc.up.pt> wrote:
>
> Ok, I found Ada Issue 115, which clarifies that "a language-defined generic 
> package may be instantiated at any nesting depth."
>
> I'm still in the dark regarding unbounded strings though, as 
> Ada.Strings.Unbounded is not generic.

What do you mean?

-- 
"Saving keystrokes is the job of the text editor, not the programming
 language."



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: library level required or not?
       [not found] <200403011717.22528.maa@liacc.up.pt>
@ 2004-03-01 18:49 ` Marius Amado Alves
  2004-03-01 18:41   ` Preben Randhol
  0 siblings, 1 reply; 9+ messages in thread
From: Marius Amado Alves @ 2004-03-01 18:49 UTC (permalink / raw)
  To: comp.lang.ada

Myself:
> I have in my notes that an object, of a type declared in package Ada or
> descendants, is not required to be defined at library level, even if the
> type is controlled. (I know I can declare unbounded strings, which are
> clearly controlled, in a 'main' procedure.)
>
> I vaguely recall deriving this rule from the RM, but now I cannot find the
> clause. Is the rule true? By what clause?

Ok, I found Ada Issue 115, which clarifies that "a language-defined generic 
package may be instantiated at any nesting depth."

I'm still in the dark regarding unbounded strings though, as 
Ada.Strings.Unbounded is not generic.



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: library level required or not?
  2004-03-01 18:41   ` Preben Randhol
@ 2004-03-01 19:21     ` Marius Amado Alves
  2004-03-01 20:17       ` Simon Wright
  0 siblings, 1 reply; 9+ messages in thread
From: Marius Amado Alves @ 2004-03-01 19:21 UTC (permalink / raw)
  To: comp.lang.ada

On Monday 01 March 2004 18:41, Preben Randhol wrote:
> On 2004-03-01, Marius Amado Alves <maa@liacc.up.pt> wrote:
> > Ok, I found Ada Issue 115, which clarifies that "a language-defined
> > generic package may be instantiated at any nesting depth."
> >
> > I'm still in the dark regarding unbounded strings though, as
> > Ada.Strings.Unbounded is not generic.
>
> What do you mean?

If you look at the GNAT sources for example, you'll find that Unbounded_String 
is controlled. And yet you can declare an unbounded string inside a 'main' 
program. Try pulling that out with your own controlled type.




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: library level required or not?
  2004-03-01 19:21     ` Marius Amado Alves
@ 2004-03-01 20:17       ` Simon Wright
  2004-03-01 23:32         ` Marius Amado Alves
  2004-03-02  2:36         ` Robert I. Eachus
  0 siblings, 2 replies; 9+ messages in thread
From: Simon Wright @ 2004-03-01 20:17 UTC (permalink / raw)


Marius Amado Alves <maa@liacc.up.pt> writes:

> On Monday 01 March 2004 18:41, Preben Randhol wrote:
> > On 2004-03-01, Marius Amado Alves <maa@liacc.up.pt> wrote:
> > > Ok, I found Ada Issue 115, which clarifies that "a language-defined
> > > generic package may be instantiated at any nesting depth."
> > >
> > > I'm still in the dark regarding unbounded strings though, as
> > > Ada.Strings.Unbounded is not generic.
> >
> > What do you mean?
> 
> If you look at the GNAT sources for example, you'll find that
> Unbounded_String is controlled. And yet you can declare an unbounded
> string inside a 'main' program. Try pulling that out with your own
> controlled type.

?

There is a difference between instantiating the generic, which amounts
to defining a new type derived from Controlled, and declaring an
instance of a type .. is this 3.9.1(3)?

(I also see (4), "A type extension shall not be declared in a generic
body if the parent type is declared outside that body." I think ISNBAL
-- I shall never be a lawyer)

-- 
Simon Wright                               100% Ada, no bugs.



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: library level required or not?
  2004-03-01 20:17       ` Simon Wright
@ 2004-03-01 23:32         ` Marius Amado Alves
  2004-03-02  2:36         ` Robert I. Eachus
  1 sibling, 0 replies; 9+ messages in thread
From: Marius Amado Alves @ 2004-03-01 23:32 UTC (permalink / raw)
  To: comp.lang.ada

> > If you look at the GNAT sources for example, you'll find that
> > Unbounded_String is controlled. And yet you can declare an unbounded
> > string inside a 'main' program. Try pulling that out with your own
> > controlled type.
>
> ?
>
> There is a difference between instantiating the generic, which amounts
> to defining a new type derived from Controlled, and declaring an
> instance of a type

You're right, I mixed things up... a bit.

> .. is this 3.9.1(3)?

I think so, that it is that clause that ultimately obliges controlled objects 
to be defined at library level. So what's the deal with Unbounded_String? 
(ISNBAL too, obvioulsy.)




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: library level required or not?
  2004-03-01 17:17 Marius Amado Alves
@ 2004-03-01 23:37 ` Randy Brukardt
  2004-03-02  0:21   ` Marius Amado Alves
  0 siblings, 1 reply; 9+ messages in thread
From: Randy Brukardt @ 2004-03-01 23:37 UTC (permalink / raw)


"Marius Amado Alves" <maa@liacc.up.pt> wrote in message
news:mailman.48.1078160769.327.comp.lang.ada@ada-france.org...
> Language lawers, please help me.
>
> I have in my notes that an object, of a type declared in package Ada or
> descendants, is not required to be defined at library level, even if the
type
> is controlled. (I know I can declare unbounded strings, which are clearly
> controlled, in a 'main' procedure.)
>
> I vaguely recall deriving this rule from the RM, but now I cannot find the
> clause. Is the rule true? By what clause?

*Types* derived from Controlled have to be at library-level. *Objects* have
no such restrictions. I can't point at a rule that says that, for the simple
reason that there isn't any. In the absense of a specific rule, of course,
there is no restriction, and that's the case here.

                         Randy.







^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: library level required or not?
  2004-03-01 23:37 ` Randy Brukardt
@ 2004-03-02  0:21   ` Marius Amado Alves
  0 siblings, 0 replies; 9+ messages in thread
From: Marius Amado Alves @ 2004-03-02  0:21 UTC (permalink / raw)
  To: comp.lang.ada

> *Types* derived from Controlled have to be at library-level. *Objects* have
> no such restrictions.

Yes. My mind is much clearer now. Thanks.



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: library level required or not?
  2004-03-01 20:17       ` Simon Wright
  2004-03-01 23:32         ` Marius Amado Alves
@ 2004-03-02  2:36         ` Robert I. Eachus
  1 sibling, 0 replies; 9+ messages in thread
From: Robert I. Eachus @ 2004-03-02  2:36 UTC (permalink / raw)


Simon Wright wrote:

> (I also see (4), "A type extension shall not be declared in a generic
> body if the parent type is declared outside that body." I think ISNBAL
> -- I shall never be a lawyer)

This rule seems very mysterious, but it is actually a simple rule! 
Well, simple compared to the alternative.  There are many weird things 
that you could do if this rule wasn't there.  Rather than have a dozen 
exceptions to other rules, this one rule takes care of all of them.

If you really need a type extension in a generic body, you can put the 
extension declaration in the private part of the package specification. 
  This way (necessary) checks can be made at the point of any 
instantiation.  If they succeed, fine.  If not the instantiation is 
illegal.  But the Ada model doesn't allow rejecting an instantiation 
because of declarations in the body of the generic.

Extending a type declared in the generic body itself can never cause a 
problem because the legality of those declarations can't depend on the 
characteristics of a generic formal parameter.

-- 
                                           Robert I. Eachus

"The only thing necessary for the triumph of evil is for good men to do 
nothing." --Edmund Burke




^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2004-03-02  2:36 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <200403011717.22528.maa@liacc.up.pt>
2004-03-01 18:49 ` library level required or not? Marius Amado Alves
2004-03-01 18:41   ` Preben Randhol
2004-03-01 19:21     ` Marius Amado Alves
2004-03-01 20:17       ` Simon Wright
2004-03-01 23:32         ` Marius Amado Alves
2004-03-02  2:36         ` Robert I. Eachus
2004-03-01 17:17 Marius Amado Alves
2004-03-01 23:37 ` Randy Brukardt
2004-03-02  0:21   ` Marius Amado Alves

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