Re: [BLACKBOX] ARRAY as CONSTANT

From: [at]} <CFB>
Date: Mon, 11 Feb 2008 23:46:26 +1030

----boundary-LibPST-iamunique-2121067501_-_-
Content-type: text/plain

> -----Original Message-----
> From: BlackBox [mailto:BLACKBOX{([at]})nowhere.xy
> Oleg N. Cher
> Sent: Monday, 11 February 2008 7:28 PM
> To: BLACKBOX{([at]})nowhere.xy
> Subject: [BLACKBOX] ARRAY as CONSTANT
>
> With this experiments, I understand, that Oberon-2 and
> BlackBox can not works with big arrays, initialized in
> compile-time. And it's strange.

AFAIK, Wirth has never incorporated this feature in the design of any of his
languages (including Pascal, and Modula-2). It wasn't that he didn't
consider it - I can perhaps look up some references if you are interested in
the reasoning behind his decisions.

Although I have found the Delphi approach useful (particularly with just a
few disjoint values) - I rarely use it. I haven't found alternative
approaches to be a major problem.

> Of course, I can initial array in run-time, but it is
> a very big manual work and inefficient large module code.
>

With large arrays it also becomes a maintenance nightmare if you wrote it
the Delphi way. as you soon lose track of which element has which value:

CONST
   a: ARRAY [0..10000] OF INTEGER = (27, 63, 0, 42, 1176, 2, 23, (* 9991
more values *), 342, 678, 175);

Of course, if the sequence of values followed the simple pattern in your
original example it would easily be coded as:

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

There would be some runtime overhead (a few milliseconds perhaps) but
nothing to worry about. If, alternatively, the data was compiled into the
exe you would have to account for the time to read from the disk and load
into memory anyway. My guess is that would be slower.

> Please, help me,
> must be a better method.
>

How many elements do you have?

Is there any pattern to the sequence of elements? If so, if you can devise
an algorithm that clearly exposes the pattern (as above) that will make the
code easier to understand, verify and maintain.

If it is a large number of disjoint values can you read them in from a file?

Regards,
Chris Burrows
CFB Software
http://www.cfbsoftware.com/cp


----
To unsubscribe, send a message with body "SIGNOFF BLACKBOX" to LISTSERV{([at]})nowhere.xy----boundary-LibPST-iamunique-2121067501_-_-
Content-type: application/rtf
Content-transfer-encoding: base64
Content-Disposition: attachment; filename="rtf-body.rtf"
e1xydGYxXGFuc2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Vhc2llciB0byB1bmRlcnN0YW5k
LCB2ZXJpZnkgYW5kIG1haW50YWluLlxwYXINClxwYXINCklmIGl0IGlzIGEgbGFyZ2UgbnVtYmVy
IG9mIGRpc2pvaW50IHZhbHVlcyBjYW4geW91IHJlYWQgdGhlbSBpbiBmcm9tIGEgZmlsZT9ccGFy
DQpccGFyDQpSZWdhcmRzLFxwYXINCkNocmlzIEJ1cnJvd3NccGFyDQpDRkIgU29mdHdhcmVccGFy
DQpodHRwOi8vd3d3LmNmYnNvZnR3YXJlLmNvbS9jcFxwYXINClxwYXINClxwYXINCi0tLS1ccGFy
DQpUbyB1bnN1YnNjcmliZSwgc2VuZCBhIG1lc3NhZ2Ugd2l0aCBib2R5ICJTSUdOT0ZGIEJMQUNL
Qk9YIiB0byBMSVNUU0VSVkBMSVNUUy5PQkVST04uQ0hcfX0AZ2RH
----boundary-LibPST-iamunique-2121067501_-_---
Received on Mon Feb 11 2008 - 14:16:26 UTC

This archive was generated by hypermail 2.3.0 : Thu Sep 26 2013 - 06:31:04 UTC