home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / lang / ada / 2517 < prev    next >
Encoding:
Text File  |  1992-09-02  |  1.9 KB  |  67 lines

  1. Newsgroups: comp.lang.ada
  2. Path: sparky!uunet!sun-barr!cs.utexas.edu!torn!cunews!dgbt!netfs!news
  3. From: BERRYMAN@orca.drep.dnd.ca (DON BERRYMAN)
  4. Subject: Variant Record Defaults
  5. Message-ID: <1992Sep2.223807.9217@netfs.dnd.ca>
  6. Sender: news@netfs.dnd.ca (NEWS)
  7. Nntp-Posting-Host: orca.drep.dnd.ca
  8. Organization: Defence Research Establishment Pacific
  9. Date: Wed, 2 Sep 1992 22:38:07 GMT
  10. X-News-Reader: VMS NEWS 1.20
  11. Lines: 54
  12.  
  13.  
  14. Please concider the following code fragment:
  15.  
  16.      package dstring is
  17.          type text (maxlen: positive := 64) is private;
  18.          ---STUFF DELETED--
  19.      private
  20.          type text (maxlen: positive := 64) is
  21.          record
  22.              last: natural := 0;
  23.              data: string (1..maxlen);
  24.          end record;
  25.      end dstring;
  26.  
  27.      with dstring;
  28.      procedure useit is
  29.         type buffer is record
  30.              data: dstring.text;
  31.         end record;
  32.         aaa: buffer;
  33.         bbb: dstring.text;
  34.      begin
  35.         null;
  36.      end useit;
  37.  
  38.  
  39. When compiled on VAX/VMS Ada I get the following:
  40.  
  41.      S2$ ada useit
  42.          3      type buffer is record
  43.      ...........1
  44.      %ADAC-I-CONS_OR_NUM_ERR, (1) CONSTRAINT_ERROR or NUMERIC_ERROR will be raised
  45.              here [LRM 11.1(5-6), F.9.5]
  46.              during evaluation related to record type buffer at line 3
  47.      %ADAC-I-ENDDIAGS, Ada compilation completed with 1 diagnostic
  48.      S2$
  49.  
  50. What appears to be the problem is that BUFFER.DATA is not using the default
  51. for MAXLEN. When I specify it in the record definition the message goes
  52. away. Since I can create the variable, BBB, of type DSTRING.TEXT it does not
  53. seem to be a problem with my definitions. So why does ADA not use the 
  54. default for BUFFER.DATA???  
  55.  
  56. I'm sure the reason is given in an obscure section of the LRM,
  57.  
  58.  
  59. Don Berryman
  60. Defence Research Establishment Pacific
  61. Canadian Forces Base Esquimalt
  62. Victoria, BC, CANADA, V0S-1B0
  63. 604-363-2731    604-363-2856fax
  64. berryman@orca.drep.dnd.ca
  65.  
  66.  
  67.