[Oberon] Question concerning Arrays

Chris Burrows chris at cfbsoftware.com
Wed Apr 4 02:06:00 MEST 2007


> -----Original Message-----
> From: oberon-bounces at lists.inf.ethz.ch 
> [mailto:oberon-bounces at lists.inf.ethz.ch] On Behalf Of August 
> Karlstrom
> Sent: Wednesday, 4 April 2007 4:44 AM
> To: ETH Oberon and related systems
> Subject: Re: [Oberon] Question concerning Arrays
> 
> Brantley Coile skrev:
> >> A[0] := 0; A[1] := 1; A[2] := 2;
> >> In this respect, I think maybe the minimalist approach of 
> Oberon went 
> >> to far.
> > 
> > That's a matter of taste.  As someone who survived PL/1, 
> I'll take Oberon as it is.
> > 
> > 	Brantley Coile
> 
> I agree. I'd be hard pressed to suggest any changes to the 
> meticulous design of Oberon-2. The verbosity that the lack of 
> array literals leads to is a bit frustrating though.
> 

I can imagine some instances where it might be an issue but I haven't
personally found it to be a problem in practice. In many cases the values of
an array need to be read from an external source (file, registry etc.)
anyway so the actual code to populate the array is usually a simple loop
rather than a long series of assignment statements. 

Actually, if your particular example had only a few more elements it would
make more sense to write it as:

  FOR i := 0 TO LEN(A) - 1 DO A[i] := i END;

I'd even argue that it might be better to code it that way even for just 3
elements. If there really is some sort of pattern to the values of the
array, then the code construct that best illustrates the pattern should be
chosen.

Another related point often overlooked by programmers with a non-Pascal
background is that an entire array can be assigned in a single assignment.
At the expense of some memory efficiency, this often leads to better
performance e.g. 

VAR
  initMatrix, matrix1, matrix2: SomeMatrix;

...
...
  LoadMatrix(initMatrix);
...
...
  matrix1 := initMatrix;
...
etc.


--
Chris Burrows
CFB Software
http://www.cfbsoftware.com/gpcp


More information about the Oberon mailing list