comp.lang.ada
 help / color / mirror / Atom feed
From: blakemor@software.org (Alex Blakemore)
Subject: constraint error question for language lawyers
Date: 8 Nov 90 17:18:32 GMT	[thread overview]
Message-ID: <1802@software.software.org> (raw)

OK, language lawyers of the world.
This one has stumped everyone I've asked locally,  including several 
people who have worked with Ada since there were compilers for it.

Vax Ada 2.1 and two versions of Verdix (5.x and 6.0.3) all behave in the same
(unreasonable) manner - so there must be some obscure rule at work here.
Does anyone
  a. know what that rule might be ?
  b. profess to have a reasonable explanation for its existence.

The Question:
  Why does this procedure raise constraint error?
  It happens on the second assignment to dummy, but
  doesnt happen if dummy.len > 0 and appears to have 
  something to do with the function call "&"

----------------  cut here  -----------------

with text_io;
use text_io;

procedure bozo is
  
  type short is range 0 .. 10;

  type data is array (short range <>) of character;

  type var_text (len : short := 0) is
    record
      text : data (1 .. len);
    end record;

  dummy : var_text; -- unconstrained

  procedure do_nothing (d : data) is 
  begin
    null;
  end do_nothing;

begin

  put_line ("before");
  dummy := (len => 0, text => "");
  put_line ("during");
  dummy := (len  => dummy.len + 1,
            text => dummy.text & 'a');
  put_line ("after");

exception

  when constraint_error =>
    put_line ("constraint_error raised");

end bozo;

---------------- cut here -----------------

Here is the output:

before
during
constraint_error raised

--------------------------------------------------------------------
Alex Blakemore                       CSNET:   blakemore@software.org
Software Productivity Consortium     
2214 Rock Hill Road Herndon, VA 22070 (703) 742-7125

             reply	other threads:[~1990-11-08 17:18 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1990-11-08 17:18 Alex Blakemore [this message]
1990-11-09 14:12 ` constraint error question for language lawyers David Collard
1990-11-10  1:08 ` Charles H. Sampson
1990-11-17 10:12 ` Jean Pierre Rosen
  -- strict thread matches above, loose matches on Subject: below --
1990-11-09 14:36 "Norman H. Cohen"
1990-11-30 16:02 ` James THIELE
replies disabled

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