comp.lang.ada
 help / color / mirror / Atom feed
* Re: Variant Record Defaults
@ 1992-09-22 21:50 pa.dec.com!nntpd2.cxo.dec.com!bonmot!wallace
  0 siblings, 0 replies; 4+ messages in thread
From: pa.dec.com!nntpd2.cxo.dec.com!bonmot!wallace @ 1992-09-22 21:50 UTC (permalink / raw)


BERRYMAN@orca.drep.dnd.ca (DON BERRYMAN) writes:
: 
: Please concider the following code fragment:
: 
:      package dstring is
:          type text (maxlen: positive := 64) is private;
:          ---STUFF DELETED--
:      private
:          type text (maxlen: positive := 64) is
:      	record
:      	    last: natural := 0;
:      	    data: string (1..maxlen);
:      	end record;
:      end dstring;
: 
:      with dstring;
:      procedure useit is
:         type buffer is record
:              data: dstring.text;
:         end record;
:         aaa: buffer;
:         bbb: dstring.text;
:      begin
:         null;
:      end useit;
: 
: 
: When compiled on VAX/VMS Ada I get the following:
: 
:      S2$ ada useit
:          3      type buffer is record
:      ...........1
:      %ADAC-I-CONS_OR_NUM_ERR, (1) CONSTRAINT_ERROR or NUMERIC_ERROR will be r
aised
:              here [LRM 11.1(5-6), F.9.5]
:              during evaluation related to record type buffer at line 3
:      %ADAC-I-ENDDIAGS, Ada compilation completed with 1 diagnostic
:      S2$
: 
: What appears to be the problem is that BUFFER.DATA is not using the default
: for MAXLEN. When I specify it in the record definition the message goes
: away. Since I can create the variable, BBB, of type DSTRING.TEXT it does not
: seem to be a problem with my definitions. So why does ADA not use the 
: default for BUFFER.DATA???  
: 
: I'm sure the reason is given in an obscure section of the LRM,
: 
: 
: Don Berryman
: Defence Research Establishment Pacific
: Canadian Forces Base Esquimalt
: Victoria, BC, CANADA, V0S-1B0
: 604-363-2731    604-363-2856fax
: berryman@orca.drep.dnd.ca
: 
: 

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

* Re: Variant Record Defaults
@ 1992-09-22 21:58 pa.dec.com!nntpd2.cxo.dec.com!bonmot!wallace
  0 siblings, 0 replies; 4+ messages in thread
From: pa.dec.com!nntpd2.cxo.dec.com!bonmot!wallace @ 1992-09-22 21:58 UTC (permalink / raw)


 wallace@bonmot (Richard Wallace) writes:
 : BERRYMAN@orca.drep.dnd.ca (DON BERRYMAN) writes:
 : : 
 : : Please concider the following code fragment:
 : : 
 : :      package dstring is
 : :          type text (maxlen: positive := 64) is private;
 : :          ---STUFF DELETED--
 : :      private
 : :          type text (maxlen: positive := 64) is
 : :      	record
 : :      	    last: natural := 0;
 : :      	    data: string (1..maxlen);
 : :      	end record;
 : :      end dstring;
 : : 
 : :      with dstring;
 : :      procedure useit is
 : :         type buffer is record
 : :              data: dstring.text;
 : :         end record;
 : :         aaa: buffer;
 : :         bbb: dstring.text;
 : :      begin
 : :         null;
 : :      end useit;
 : : 
 : : 
 : : When compiled on VAX/VMS Ada I get the following:
 : : 
 : :      S2$ ada useit
 : :          3      type buffer is record
 : :      ...........1
 : :      %ADAC-I-CONS_OR_NUM_ERR, (1) CONSTRAINT_ERROR or NUMERIC_ERROR will b
e raised
 : :              here [LRM 11.1(5-6), F.9.5]
 : :              during evaluation related to record type buffer at line 3
 : :      %ADAC-I-ENDDIAGS, Ada compilation completed with 1 diagnostic
 : :      S2$
 : : 
 : : What appears to be the problem is that BUFFER.DATA is not using the defaul
t
 : : for MAXLEN. When I specify it in the record definition the message goes
 : : away. Since I can create the variable, BBB, of type DSTRING.TEXT it does n
ot
 : : seem to be a problem with my definitions. So why does ADA not use the 
 : : default for BUFFER.DATA???  
 : : 
 : : I'm sure the reason is given in an obscure section of the LRM,
 : : 
 : : 
 : : Don Berryman
 : : Defence Research Establishment Pacific
 : : Canadian Forces Base Esquimalt
 : : Victoria, BC, CANADA, V0S-1B0
 : : 604-363-2731    604-363-2856fax
 : : berryman@orca.drep.dnd.ca
 : : 
 : : 

Let me try again!

What's going wrong here is the declaration of a record aggregate with
a record aggregate with a discrimanant part.  Very specifically in
LRM 4.3.1(1) it states:

	"If the type of an aggregate is a record type, the
	component names given as choices must denote components
	(including discrimants) fo the record type."

This the second declaration is an object of the record type and not
an aggregate of the record type as is the first one.

Hope this helps!

Richard Wallace
Digital Equipment Corporation
301 Rockrimmon Blvd. South
CXO2-1/7A
Colorado Springs, CO 80919-2398
(719)548-2792
<wallace@cookie.enet.dec.com>

	"The opinions expressed are my own, Unlce Ken or Uncle Bob
	 may, or may not, agree with me.

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

* Re: Variant Record Defaults
@ 1992-09-23 20:13 cis.ohio-state.edu!zaphod.mps.ohio-state.edu!usc!rpi!psinntp!psinntp!vitr
  0 siblings, 0 replies; 4+ messages in thread
From: cis.ohio-state.edu!zaphod.mps.ohio-state.edu!usc!rpi!psinntp!psinntp!vitr @ 1992-09-23 20:13 UTC (permalink / raw)


In article <1992Sep22.215834.11990@nntpd2.cxo.dec.com> wallace@bonmot (Richard
Wallace) writes:
> wallace@bonmot (Richard Wallace) writes:
> : BERRYMAN@orca.drep.dnd.ca (DON BERRYMAN) writes:
> : : 
> : : Please concider the following code fragment:
> : : 
> : :      package dstring is
> : :          type text (maxlen: positive := 64) is private;
> : :          ---STUFF DELETED--
> : :      private
> : :          type text (maxlen: positive := 64) is
> : :      	record
> : :      	    last: natural := 0;
> : :      	    data: string (1..maxlen);
> : :      	end record;
> : :      end dstring;
> : : 
> : :      with dstring;
> : :      procedure useit is
> : :         type buffer is record
> : :              data: dstring.text;
> : :         end record;
> : :         aaa: buffer;
> : :         bbb: dstring.text;
> : :      begin
> : :         null;
> : :      end useit;
> : : 
> : : 
> : : When compiled on VAX/VMS Ada I get the following:
> : : 
> : :      S2$ ada useit
> : :          3      type buffer is record
> : :      ...........1
> : :      %ADAC-I-CONS_OR_NUM_ERR, (1) CONSTRAINT_ERROR or NUMERIC_ERROR will
be raised
> : :              here [LRM 11.1(5-6), F.9.5]
> : :              during evaluation related to record type buffer at line 3
> : :      %ADAC-I-ENDDIAGS, Ada compilation completed with 1 diagnostic
> : :      S2$
> : : 
> : : What appears to be the problem is that BUFFER.DATA is not using the
default
> : : for MAXLEN. When I specify it in the record definition the message goes
> : : away. Since I can create the variable, BBB, of type DSTRING.TEXT it does
not
> : : seem to be a problem with my definitions. So why does ADA not use the 
> : : default for BUFFER.DATA???  
> : : 
> : : I'm sure the reason is given in an obscure section of the LRM,
> : : 
> : : 
> : : Don Berryman
> : : Defence Research Establishment Pacific
> : : Canadian Forces Base Esquimalt
> : : Victoria, BC, CANADA, V0S-1B0
> : : 604-363-2731    604-363-2856fax
> : : berryman@orca.drep.dnd.ca
> : : 
> : : 
>
>Let me try again!
>
>What's going wrong here is the declaration of a record aggregate with
>a record aggregate with a discrimanant part.  Very specifically in
>LRM 4.3.1(1) it states:
>
>	"If the type of an aggregate is a record type, the
>	component names given as choices must denote components
>	(including discrimants) fo the record type."
>
>This the second declaration is an object of the record type and not
>an aggregate of the record type as is the first one.
>
>Hope this helps!
>
>Richard Wallace
>Digital Equipment Corporation
>301 Rockrimmon Blvd. South
>CXO2-1/7A
>Colorado Springs, CO 80919-2398
>(719)548-2792
><wallace@cookie.enet.dec.com>
>
>	"The opinions expressed are my own, Unlce Ken or Uncle Bob
>	 may, or may not, agree with me.
>

In simple terms -- the problem is that when defining a record type whose
discriminant type is POSITIVE, an implementation is allowed to reserve
sufficient space for POSITIVE'LAST characters (which on the VAX is a lot of
characters!) You may get STORAGE_ERROR, or, in the case of the VAX,
NUMERIC_ERROR, since POSITIVE'LAST + POSITIVE'SIZE (for the discriminant
itself) is a value greater than INTEGER'LAST. 

A solution would be to create a subtype of POSITIVE and use that as the
discriminant's type.

         __________________________________________________________________
        / Michael J. Mangieri                 Internet: mmangieri@vitro.com
__     /  Vitro Corporation                      Voice:      (301) 231-3016
  \   /   MX-SP 4-2311                             FAX:      (301) 231-1233
   \ /    14000 Georgia Ave.              
    *     Silver Spring, MD 20906-2972    

         "Everything should be made as simple as possible, but not simpler."
                                                       - A. Einstein

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

* Variant Record Defaults
@ 1992-09-24 23:04 deccrl!news.crl.dec.com!pa.dec.com!jrdzzz.jrd.dec.com!e2big.mko.dec.com!n
  0 siblings, 0 replies; 4+ messages in thread
From: deccrl!news.crl.dec.com!pa.dec.com!jrdzzz.jrd.dec.com!e2big.mko.dec.com!n @ 1992-09-24 23:04 UTC (permalink / raw)


mmangieri@vitro.com (M. J. Mangieri) writes:
: In article <1992Sep22.215834.11990@nntpd2.cxo.dec.com> wallace@bonmot (Richar
d
: Wallace) writes:
: > wallace@bonmot (Richard Wallace) writes:
: > : BERRYMAN@orca.drep.dnd.ca (DON BERRYMAN) writes:
: > : : 
: > : : Please concider the following code fragment:
: > : : 
: > : :      package dstring is
: > : :          type text (maxlen: positive := 64) is private;
: > : :          ---STUFF DELETED--
: > : :      private
: > : :          type text (maxlen: positive := 64) is
: > : :      	record
: > : :      	    last: natural := 0;
: > : :      	    data: string (1..maxlen);
: > : :      	end record;
: > : :      end dstring;
: > : : 
: > : :      with dstring;
: > : :      procedure useit is
: > : :         type buffer is record
: > : :              data: dstring.text;
: > : :         end record;
: > : :         aaa: buffer;
: > : :         bbb: dstring.text;
: > : :      begin
: > : :         null;
: > : :      end useit;
: > : : 
: > : : 
: > : : When compiled on VAX/VMS Ada I get the following:
: > : : 
: > : :      S2$ ada useit
: > : :          3      type buffer is record
: > : :      ...........1
: > : :      %ADAC-I-CONS_OR_NUM_ERR, (1) CONSTRAINT_ERROR or NUMERIC_ERROR wil
l
: be raised
: > : :              here [LRM 11.1(5-6), F.9.5]
: > : :              during evaluation related to record type buffer at line 3
: > : :      %ADAC-I-ENDDIAGS, Ada compilation completed with 1 diagnostic
: > : :      S2$
: > : : 
: > : : What appears to be the problem is that BUFFER.DATA is not using the
: default
: > : : for MAXLEN. When I specify it in the record definition the message goes
: > : : away. Since I can create the variable, BBB, of type DSTRING.TEXT it doe
s
: not
: > : : seem to be a problem with my definitions. So why does ADA not use the 
: > : : default for BUFFER.DATA???  
: > : : 
: > : : I'm sure the reason is given in an obscure section of the LRM,
: > : : 
: > : : 
: > : : Don Berryman
: > : : Defence Research Establishment Pacific
: > : : Canadian Forces Base Esquimalt
: > : : Victoria, BC, CANADA, V0S-1B0
: > : : 604-363-2731    604-363-2856fax
: > : : berryman@orca.drep.dnd.ca
: > : : 
: > : : 

.. my answer deleted ...

: In simple terms -- the problem is that when defining a record type whose
: discriminant type is POSITIVE, an implementation is allowed to reserve
: sufficient space for POSITIVE'LAST characters (which on the VAX is a lot of
: characters!) You may get STORAGE_ERROR, or, in the case of the VAX,
: NUMERIC_ERROR, since POSITIVE'LAST + POSITIVE'SIZE (for the discriminant
: itself) is a value greater than INTEGER'LAST. 
: 
: A solution would be to create a subtype of POSITIVE and use that as the
: discriminant's type.
: 
:          __________________________________________________________________
:         / Michael J. Mangieri                 Internet: mmangieri@vitro.com
: __     /  Vitro Corporation                      Voice:      (301) 231-3016
:   \   /   MX-SP 4-2311                             FAX:      (301) 231-1233
:    \ /    14000 Georgia Ave.              
:     *     Silver Spring, MD 20906-2972    
: 
:          "Everything should be made as simple as possible, but not simpler."
:                                                        - A. Einstein
: 
: 

I concur Michael's findings.

With the subtype of POSITIVE the the discrimanent on dstring.text does not
generate a compile warning or runtime error.  The runtime error is 
CONSTRAINT_ERROR with VAX Ada on VAX/VMS if the original program above is run.

Richard Wallace
Digital Equipment Corporation
301 Rockrimmon Blvd. South
CXO2-1/7A
Colorado Springs, CO 80919-2398
(719)548-2792
<wallace@cookie.enet.dec.com>

	"The opinions expressed are my own, Uncle Ken or Uncle Bob
	 may, or may not, agree with me."

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

end of thread, other threads:[~1992-09-24 23:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1992-09-24 23:04 Variant Record Defaults deccrl!news.crl.dec.com!pa.dec.com!jrdzzz.jrd.dec.com!e2big.mko.dec.com!n
  -- strict thread matches above, loose matches on Subject: below --
1992-09-23 20:13 cis.ohio-state.edu!zaphod.mps.ohio-state.edu!usc!rpi!psinntp!psinntp!vitr
1992-09-22 21:58 pa.dec.com!nntpd2.cxo.dec.com!bonmot!wallace
1992-09-22 21:50 pa.dec.com!nntpd2.cxo.dec.com!bonmot!wallace

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