comp.lang.ada
 help / color / mirror / Atom feed
* problem with constrained arrays in descritiate records w/ GNAT305
@ 1996-10-21  0:00 James Conley
  0 siblings, 0 replies; only message in thread
From: James Conley @ 1996-10-21  0:00 UTC (permalink / raw)



I sure hope that someone around here can help me out.  I am writing a
program for my Ada Data Structures class where I have to implement a
Polynomial package and I'm using GNAT for MSDOS 305s under win95 and
every time I try this program it crashes upon compilation. The version
below will work & compile but if I remove ANY of the commented lines
in the main procedure (even the ones right after the begin statement
that duplicate lines further down) it will crash upon compilation with
the statement not enought memory for compiler - I don't understand why
I cannot print the ary'first twice without breaking my memory!!!!???
Does anyone here understand what I am doing wrong or if mabey this
compiler has a bug in it?  If you have any idea what I am doing wrong
please let me know via email as I dont read this group but once a
week.  Thanks!
james
jconley@mindspring.com

with text_io; use text_io;
procedure prob is
type real is new float;
package my_real_io is new float_io(real);
package my_int_io is new integer_io(integer);
use my_real_io;
use my_int_io;
type sign_type is (neg,pos);
subtype index is integer range 0..100;
type monomial_type is
	record
		constant_factor:real;
		power:integer;
		sign:sign_type:=pos;
	end record;

type monomial_ary is array (index range <>) of monomial_type;

type polynomial (num:index:=0) is 
  record
    Ary:monomial_ary (0..num);
  end record;


-- writes a polynomial to std_out
procedure put(poly_in:in polynomial) is
begin
	put("hello, about to write a polynomial");
	for i in poly_in.ary'range loop
		if poly_in.ary(i).sign=pos then
			put("+");
		else put("-");
		end if;
		put(poly_in.ary(i).constant_factor);
		if poly_in.ary(i).power=0 then
			null;
		elsif poly_in.ary(i).power=1 then
			put("x");
		else put("x^"); put(poly_in.ary(i).power);
		end if;
	end loop;
end put;

test_poly:polynomial(num=>2);

begin --prob/main
--put("first is");
--put(test_poly.ary'first);   -- this will crash if uncommented!!!???
--new_line;
--test_poly.ary(1):=(3.0,3,neg);          all these
--test_poly.ary(0).power:=3;           lines cause it to crash!?
--test_poly.ary(0).constant_factor:=3.0;
--test_poly.ary(1).sign:=pos;
--test_poly.ary(1).power:=2;
--test_poly.ary(1).constant_factor:=2.0;
--test_poly.ary(2).sign:=neg;
--test_poly.ary(2).power:=1;
--test_poly.ary(2).constant_factor:=1.0;
put("hello world");
new_line;
put ("first=");
put(test_poly.ary'first);
new_line;
put ("last=");
put(test_poly.ary'last);
new_line;
--test_poly.ary(0):=2;
--test_poly.ary(0).constant_factor:=2.0;
put("hello");
new_line;
end prob;





^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1996-10-21  0:00 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-10-21  0:00 problem with constrained arrays in descritiate records w/ GNAT305 James Conley

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