🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.misc
Article #6109

Re: Dynamic array dimensioning

#6109
From: Ken Johnson
Date: Fri, 06 Jan 1989 11:34
49 lines
1702 bytes
In article <117400002@uxa.cso.uiuc.edu> gsg0384@uxa.cso.uiuc.edu writes:
>
>Hi,
>
>Can someone in the net enlighten me about the following?
>
>1.  What languages support the run-time array sizing in a particular module
>as in FORTRAN 8x ?  Please list.

Do you include the well established trick

foo()
{
	int	*x, *alloc();
	int	n, m;

	...requires an array n by m....

	x = alloc(n*m*sizeof(int));
	bar(x,n,...);
}

bar(a,n,...)
int *a;
int n;
{
	int	i,j;

	...wishes to set element a[i,j]...

	*(a+(i*n)+j) = expr;
}

You will have to do some type conversion in this last expression, I'm
afraid (I can't do it in my head).  It's easier in the now more or less
obsolete language BCPL, which provices a special tool APTOVEC which
makes this way of doing it easier. 

To give the appearance of dynamic dimensioning you could define a macro
to conceal the awkward expression.  This is all that a
dynamic-dimensioning compiler can do anyway. 

-- 
==============================================================================
From:       Ken Johnson
Address:    AI Applications Institute, The University, EDINBURGH, Scotland
Phone:      031-225 4464 ext 212
Email:	    k.johnson@ed.ac.uk
Quotation:  I've had a rotten day at work so far. My best friend didn't come.
Technical Details
Message-ID: <723@aiva.ed.ac.uk>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!attcan!uunet!mcvax!ukc!etive!aiva!ken
References: <117400002@uxa.cso.uiuc.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!attcan!uunet!mcvax!ukc!etive!aiva!ken
From: ken@aiva.ed.ac.uk (Ken Johnson)
Newsgroups: comp.lang.misc
Subject: Re: Dynamic array dimensioning
Message-ID: <723@aiva.ed.ac.uk>
Date: 6 Jan 89 11:34:25 GMT
References: <117400002@uxa.cso.uiuc.edu>
Reply-To: ken@uk.ac.ed.aiva (Ken Johnson,E32 SB x212E)
Organization: Dept. of AI, Univ. of Edinburgh, UK
Lines: 49