comp.lang.ada
 help / color / mirror / Atom feed
From: Adam Beneschan <adam@irvine.com>
Subject: Re: Generic operation and prefixed notation
Date: Mon, 14 Jun 2010 18:14:58 -0700 (PDT)
Date: 2010-06-14T18:14:58-07:00	[thread overview]
Message-ID: <6e7f218f-5a4a-4437-8bdb-7000937f01e1@u3g2000prl.googlegroups.com> (raw)
In-Reply-To: op.veax4zezxmjfy8@garhos

On Jun 14, 11:11 am, Yannick Duchêne (Hibou57)
<yannick_duch...@yahoo.fr> wrote:
> Le Mon, 14 Jun 2010 19:47:09 +0200, Marek Janukowicz  
> <ma...@janukowicz.net> a écrit:
>
> Hi Marek,
>
> > Given a simplified example:
>
> >   type Model is tagged record
> >     null
> >   end record;
>
> >   generic
> >     Attr_Name : String;
> >   procedure Get_Attribute( M : Model );
>
> Here, Get_Attribute is not a primitive operation of Model I suppose.
> If it is not a primitive operation of Model, you cannot invok it using the  
> dotted notation.
>
> For a subprogram to be a primitive, it must be declared in the same  
> package as the one which declares the type (here Modem). That is OK here  
> for that. However, it also additionally requires the type is not frozen.  
> Here, when you define a generic using a Model as an argument, I'm pretty  
> sure this makes Model frozen.
>
> Basically, a type is made frozen as soon as some reference to it requires  
> some important stuff are already defined. When you make some kind of  
> reference to a type, it suppose the type is frozen, that is, all these  
> important stuff are already defined.

Actually, I'm not sure that the generic declaration freezes Model.
The problem here is that the generic requires a body, and if you try
to instantiate it before the body is seen, you'd get a Program_Error.
But if you put the body of Get_Attribute before the instantiation
(assuming this isn't in a package spec), then *that* would cause Model
to be frozen.

I can't really tell whether the operation is legal or primitive,
however, or what kind of freezing has taken place, because the code
isn't a complete example.  I don't know whether the declarations are
in a package spec, a package body, the declarative part of a
procedure, or just taken out of context from various parts of the
program.

                            -- Adam



      reply	other threads:[~2010-06-15  1:14 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-14 17:47 Generic operation and prefixed notation Marek Janukowicz
2010-06-14 18:09 ` Dmitry A. Kazakov
2010-06-14 18:11 ` Yannick Duchêne (Hibou57)
2010-06-15  1:14   ` Adam Beneschan [this message]
replies disabled

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