bug-apl
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Alignment of ⎕FIO and ⎕CR


From: Dr . Jürgen Sauermann
Subject: Alignment of ⎕FIO and ⎕CR
Date: Fri, 18 Dec 2020 21:05:49 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0

Hi,

I have streamlined the behaviour of
⎕CR and ⎕FIO with respect to help texts.

Both
⎕CR and ⎕FIO now use the same formats for listing their sub-functions:

⎕FIO ⍬ and ⎕CR ⍬ now both display a brief explanation of what every (sub-) function does.
⎕FIO '' and ⎕CR '' now both show the existing syntax variants for every (sub-) function.

The reasons for the different syntax variants is historic, explained in the following for
⎕FIO.

Early versions of
⎕FIO had only a few sub-functions that were distinguished by
an axis argument of
⎕FIO. For example,

Handle ← ⎕FIO[3] Bs

would fopen a file with filename Bs since axis argument 3 was the subfunction number (that
corresponded to the C/C++ libc function fopen). Shortly after that the number of sub-functions
began to increase from around 10 to currently 60, making the numbering scheme more and
more awkward.

The next step was the APL library 5 FILE_IO which allowed the use of strings instead of
numbers. This library translates function names into function numbers, so instead of the
above function number 3 one could now say:

)COPY 5 FILE_IO
...
Handle ← FIO∆fopen BS

The use of function names instead of function numbers was then adopted by GNU APL
itself, so that one could now, without using
FILE_IO, say:

Handle ← ⎕FIO['fopen'] Bs

Thw final step in this syntax evolution of
⎕FIO was the adoption of the recently
introduced structured variables, which now allows the sub-function of
⎕FIO to
be written like a sub-variable. For example:

Handle ← ⎕FIO.fopen Bs

That seems to be the most elegant syntax so far. Same for
⎕CR, except that the
function number of
⎕CR is the left argument and not an axis. For example:

⎕CR.style_boxed_4 ⊂1 2 3

instead of:

8 ⎕CR ⊂1 2 3

The old formats are still working as before. I should mention, that
the different syntaxes differ slightly in terms of efficiency.

The most efficient syntax (and the one that all others will eventually use), is
 the function number syntax.

Next comes the new sub-function syntax (like
⎕CR.style_boxed_4). The
sub-function is tokenized only once and then reused for every subfunction call.

The slowest is the old syntax because it uses APL strings instead of (faster)
internal strings) for specifying the desired sub-function.


Enjoy,
Jürgen





reply via email to

[Prev in Thread] Current Thread [Next in Thread]