comp.lang.ada
 help / color / mirror / Atom feed
From: "Yannick Duchêne (Hibou57)" <yannick_duchene@yahoo.fr>
Subject: Re: Generic operation and prefixed notation
Date: Mon, 14 Jun 2010 20:11:13 +0200
Date: 2010-06-14T20:11:13+02:00	[thread overview]
Message-ID: <op.veax4zezxmjfy8@garhos> (raw)
In-Reply-To: hv5puu$2dp1$1@adenine.netfront.net

Le Mon, 14 Jun 2010 19:47:09 +0200, Marek Janukowicz  
<marek@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.

Hint (as kind of personal opinion): I prefer to restrict to dotted  
notation to access record fields in implementation, and just use the  
classic subprogram invocation even with tagged. However, this is not  
always handy with inherited operation.

-- 
There is even better than a pragma Assert: a SPARK --# check.
--# check C and WhoKnowWhat and YouKnowWho;
--# assert Ada;
--  i.e. forget about previous premises which leads to conclusion
--  and start with new conclusion as premise.



  parent reply	other threads:[~2010-06-14 18:11 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) [this message]
2010-06-15  1:14   ` Adam Beneschan
replies disabled

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