[Oberon] Question concerning Arrays
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
> 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; A := 1; A := 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
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
initMatrix, matrix1, matrix2: SomeMatrix;
matrix1 := initMatrix;
More information about the Oberon