• Variable parameters and code readability

    From August Karlstrom@21:1/5 to August Karlstrom on Mon Jul 30 17:20:40 2018
    On 2017-08-20 22:59, August Karlstrom wrote:
    On 2017-08-20 06:04, cfbsoftware@gmail.com wrote:
    P.S. Using pointers for all the matrices also has the advantage in
    that you can write generic code that handles 2-D arrays of any size

    It's too bad this cannot be done in standard Oberon. Of course you can
    use open (one-dimensional) arrays and calculate element indices manually
    but then you also need to pass the number of columns for each matrix.

    I was wrong here; Oberon actually does support open arrays of any dimension.

    -- August

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From cfbsoftware@gmail.com@21:1/5 to August Karlstrom on Tue Jul 31 04:33:57 2018
    On Tuesday, July 31, 2018 at 12:50:41 AM UTC+9:30, August Karlstrom wrote:
    On 2017-08-20 22:59, August Karlstrom wrote:

    It's too bad this cannot be done in standard Oberon. Of course you can
    use open (one-dimensional) arrays and calculate element indices manually but then you also need to pass the number of columns for each matrix.

    I was wrong here; Oberon actually does support open arrays of any dimension.


    My first reaction was to disagree but I now see that you are right. The syntax does allow e.g. for a three-dimensional open array parameter:

    PROCEDURE P(VAR a: ARRAY OF ARRAY OF ARRAY OF INTEGER);

    My next question then was how would you know the length of each dimension but I suppose (?) it is just:

    Dimension 0: LEN(a)
    Dimension 1: LEN(a[0]);
    Dimension 2: LEN(a[0, 0] or LEN(a[0][0])

    Do you know of any current Oberon compilers that support open arrays that are not restricted to 1 dimension?

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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From August Karlstrom@21:1/5 to cfbsoftware@gmail.com on Tue Jul 31 14:29:57 2018
    On 2018-07-31 13:33, cfbsoftware@gmail.com wrote:
    My first reaction was to disagree but I now see that you are right.

    I also overlooked this fact despite having studied the Oberon grammar
    many times.

    The syntax does allow e.g. for a three-dimensional open array parameter:

    PROCEDURE P(VAR a: ARRAY OF ARRAY OF ARRAY OF INTEGER);

    Already with two dimensions the verbosity is excessive, though. The
    alternative would have been to use a place holder like _ or * for the
    lengths:

    a: ARRAY _ OF INTEGER
    A: ARRAY _, _ OF INTEGER

    However, I can understand Niklaus Wirth's decision not to complicate
    things for such a marginal case.

    My next question then was how would you know the length of each dimension but I suppose (?) it is just:

    Dimension 0: LEN(a)
    Dimension 1: LEN(a[0]);
    Dimension 2: LEN(a[0, 0] or LEN(a[0][0])

    Indeed.

    Do you know of any current Oberon compilers that support open arrays that are not restricted to 1 dimension?

    Yes, OBNC:

    http://miasap.se/obnc/


    -- August

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)