home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / ada / 3294 < prev    next >
Encoding:
Text File  |  1992-11-17  |  1.9 KB  |  52 lines

  1. Newsgroups: comp.lang.ada
  2. Path: sparky!uunet!charon.amdahl.com!pacbell.com!ames!network.ucsd.edu!news!nosc!dale.cts.com!jhb
  3. From: jhb@dale.cts.com (John Bollenbacher)
  4. Subject: null arrays
  5. Message-ID: <BxvtCA.LM1@dale.cts.com>
  6. Sender: news@dale.cts.com (USENET News Account)
  7. Organization: Titan Linkabit Corporation
  8. X-Newsreader: Tin 1.1 PL5
  9. Date: Tue, 17 Nov 1992 22:33:46 GMT
  10. Lines: 40
  11.  
  12. Can somebody shed some light on the symptoms of the following program.  In 
  13. short, under circumstances I cannot completely understand, when assigning
  14. the contents of a null array to the field of a variant record, I get a 
  15. constraint error.  As the example shows, I can sometimes assign from a null
  16. array, but not always.
  17.  
  18. I know it looks strange in this form.  It arose in a procedure whose job it
  19. was to remove the last element from such an object.  For what it's worth,
  20. I am using Alsys v4.4 DOS386 compiler.  Any insights would be appreciated.
  21.  
  22. -------------------cut here-----------------------------------------------
  23. procedure TEST is
  24.  
  25.   subtype T is NATURAL range 0 .. 10;
  26.  
  27.   type ARR is array (T range <>) of BOOLEAN;
  28.   
  29.   type A(N : T := 0) is record 
  30.     DATA : ARR(1..N);
  31.   end record;  
  32.   I : INTEGER;
  33.   O : A := (3, (TRUE, FALSE, TRUE));
  34.   
  35.   N1 : constant ARR := O.DATA(1..0) & O.DATA(1..0);
  36.   N2 : constant ARR := O.DATA(1..0) & O.DATA(3..2);
  37. begin
  38.   I := N1'LENGTH; -- I = 0 
  39.   I := N2'LENGTH; -- I = 0
  40.   O := (0, N1);   -- does not raise constraint
  41.   O := (0, N2);   -- raises constraint
  42. end TEST; 
  43.  
  44.  
  45. --
  46. -----------------------------------------------------------------------------
  47. - John Bollenbacher                                        jhb@dale.cts.com -
  48. - Titan Linkabit Corp.                                       (619) 552-9963 -
  49. - 3033 Sience Park Rd.                                                      -
  50. - San Diego, Ca. 92121                                                      -
  51. -----------------------------------------------------------------------------
  52.