Re: [BLACKBOX] ARRAY as CONSTANT - ways to express programs

From: [at]} <CFB>
Date: Tue, 12 Feb 2008 12:06:33 +1030

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

> -----Original Message-----
> From: BlackBox [mailto:BLACKBOX{([at]})nowhere.xy
> Oleg N. Cher
> Sent: Tuesday, 12 February 2008 9:43 AM
> To: BLACKBOX{([at]})nowhere.xy
> Subject: Re: [BLACKBOX] ARRAY as CONSTANT
>
> Language Oberon was scientific and research project, and
> Component Pascal is industrial solution. If Marc Frei &
> Oberon microsystems crew considered that constant arrays
> are superfluous, we must search a way to express the programs
> by accessible facilities of language. And to work out
> the problems now, instead of tomorrow.
>

Keep in mind that 'constant arrays' are not necessarily 1-dimensional arrays
of simple items. If that were the case an array initialisation feature would
probably have already been implemented. In the general case they can be
multi-dimensional arrays of complex data structures. I suspect that might be
the reason why 'constant arrays are superfluous'.

Can you give an example of the sort of data structures that you are trying
to initialise?

Here is an actual example that might have been implemented using a
structured constant facility (if it had existed) that I was working on just
a couple of months ago. It's written in Modula-2 but the syntax is similar
enough to CP to be understandable.

The application is a Motorola MC68K assembler and I was tackling the problem
of initialising the OpCode data. The original code used a data file which I
wanted to eliminate. The OpCode table is a 1-dimensional array with elements
consisting of a reasonably complex record:

  Table68K : ARRAY [FIRST..LAST] OF TableRecord;

where:

  TableRecord = RECORD
    Mnemonic : TOKEN;
    Op : BITSET;
    AddrModeA : ModeA;
    AddrModeB : ModeB;
  END;

where:

  TOKEN = ARRAY [0..TokenSize] OF CHAR;
  ModeA = SET OF ModeTypeA;
  ModeB = SET OF ModeTypeB;


Using a helper procedure to initialise a single record:

  PROCEDURE Add(Mnemonic : TOKEN; Op : BITSET; AddrModeA : ModeA; AddrModeB
: ModeB);
  VAR
    tr: TableRecord;
  BEGIN
    tr.Mnemonic := Mnemonic;
    tr.Op := Op;
    tr.AddrModeA := AddrModeA;
    tr.AddrModeB := AddrModeB;
    INC(index);
    Table68K[index] := tr
  END Add;

The initialisation code then just became a simple series of procedure calls:

  Add("ABCD", {15, 14, 8}, ModeA{Rx911, RegMem3, Ry02}, ModeB{});
  Add("ADD", {15, 14, 12}, ModeA{OpM68D}, ModeB{EA05y});
  Add("ADDA", {15, 14, 12}, ModeA{OpM68A}, ModeB{EA05a});
  Add("ADDI", {10, 9}, ModeA{}, ModeB{Size67,
EA05e, Exten});
  Add("ADDQ", {14, 12}, ModeA{Data911}, ModeB{Size67,
EA05d});
  ...
  ...

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-17280497_-_-
Content-type: application/rtf
Content-transfer-encoding: base64
Content-Disposition: attachment; filename="rtf-body.rtf"
e1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcZnJvbXRleHQgXGRlZmYwe1xmb250dGJsDQp7XGYwXGZz
d2lzcyBBcmlhbDt9DQp7XGYxXGZtb2Rlcm4gQ291cmllciBOZXc7fQ0Ke1xmMlxmbmlsXGZjaGFy
c2V0MiBTeW1ib2w7fQ0Ke1xmM1xmbW9kZXJuXGZjaGFyc2V0MCBDb3VyaWVyIE5ldzt9fQ0Ke1xj
b2xvcnRibFxyZWQwXGdyZWVuMFxibHVlMDtccmVkMFxncmVlbjBcYmx1ZTI1NTt9DQpcdWMxXHBh
cmRccGxhaW5cZGVmdGFiMzYwIFxmMFxmczIwID4gLS0tLS1PcmlnaW5hbCBNZXNzYWdlLS0tLS1c
cGFyDQo+IEZyb206IEJsYWNrQm94IFttYWlsdG86QkxBQ0tCT1hATElTVFMuT0JFUk9OLkNIXSBP
biBCZWhhbGYgT2YgXHBhcg0KPiBPbGVnIE4uIENoZXJccGFyDQo+IFNlbnQ6IFR1ZXNkYXksIDEy
IEZlYnJ1YXJ5IDIwMDggOTo0MyBBTVxwYXINCj4gVG86IEJMQUNLQk9YQExJU1RTLk9CRVJPTi5D
SFxwYXINCj4gU3ViamVjdDogUmU6IFtC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Fx7MTUsIDE0LCA4XH0sICBNb2RlQVx7Ung5MTEsIFJlZ01lbTMsIFJ5MDJcfSwgTW9k
ZUJce1x9KTtccGFyDQogIEFkZCgiQUREIiwgIFx7MTUsIDE0LCAxMlx9LCBNb2RlQVx7T3BNNjhE
XH0sICAgICAgICAgICAgICAgTW9kZUJce0VBMDV5XH0pO1xwYXINCiAgQWRkKCJBRERBIiwgXHsx
NSwgMTQsIDEyXH0sIE1vZGVBXHtPcE02OEFcfSwgICAgICAgICAgICAgICBNb2RlQlx7RUEwNWFc
fSk7XHBhcg0KICBBZGQoIkFEREkiLCBcezEwLCA5XH0sICAgICAgTW9kZUFce1x9LCAgICAgICAg
ICAgICAgICAgICAgIE1vZGVCXHtTaXplNjcsXHBhcg0KRUEwNWUsIEV4dGVuXH0pO1xwYXINCiAg
QWRkKCJBRERRIiwgXHsxNCwgMTJcfSwgICAgIE1vZGVBXHtEYXRhOTExXH0sICAgICAgICAgICAg
ICBNb2RlQlx7U2l6ZTY3LFxwYXINCkVBMDVkXH0pO1xwYXINCiAgLi4uXHBhcg0KICAuLi5ccGFy
DQpccGFyDQpDaHJpcyBCdXJyb3dzXHBhcg0KQ0ZCIFNvZnR3YXJlXHBhcg0KaHR0cDovL3d3dy5j
ZmJzb2Z0d2FyZS5jb20vY3BccGFyDQpccGFyDQpccGFyDQotLS0tXHBhcg0KVG8gdW5zdWJzY3Jp
YmUsIHNlbmQgYSBtZXNzYWdlIHdpdGggYm9keSAiU0lHTk9GRiBCTEFDS0JPWCIgdG8gTElTVFNF
UlZATElTVFMuT0JFUk9OLkNIXHBhcg0KfQ==
----boundary-LibPST-iamunique-17280497_-_---
Received on Tue Feb 12 2008 - 02:36:33 UTC

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