Browse Prior Art Database

APL2 Calling C Routines that use Reference Parameters

IP.com Disclosure Number: IPCOM000109017D
Original Publication Date: 1992-Jul-01
Included in the Prior Art Database: 2005-Mar-23
Document File: 2 page(s) / 68K

Publishing Venue

IBM

Related People

Beaty, KA: AUTHOR [+2]

Abstract

APL2* and C differ from one another in many respects, one of which is the way their function parameters are used. In APL2, all data is passed by value, whereas it is possible in C to pass data either by value or by reference. APL2 can use C functions by defining them as external functions, but to do so in the general case one must also be able to handle the case where reference parameters are being used, as the C routines called are often pre-defined and cannot easily be changed. This article deals with how this can be done.

This text was extracted from an ASCII text file.
This is the abbreviated version, containing approximately 52% of the total text.

APL2 Calling C Routines that use Reference Parameters

       APL2* and C differ from one another in many respects, one
of which is the way their function parameters are used.  In APL2, all
data is passed by value, whereas it is possible in C  to pass data
either by value or by reference.  APL2 can use C functions by
defining them as external functions, but to do so in the general case
one must also be able to handle the case where reference parameters
are being used, as the C routines called are often pre-defined and
cannot easily be changed. This article deals with how this can be
done.

      Another aspect to take into account is the values that APL2
passes to the C environment.  The values are not necessarily copies,
but may sometimes be shared between multiple programs.  This works
fine for output-only parameters, i.e., parameters that will not be
updated by the called routine, but does not work at all if an update
may occur.

      To solve the above two problems, create a temporary buffer
large enough to hold the function argument list as well as any data
that may be modified.  Then store the updatable items in the buffer,
starting from the front of the buffer.  After this, store the
argument list values in the tail end of the buffer.  One or more
items in the argument list will typically refer back to data stored
in the first part of the buffer.  These can now be updated at will,
as they are copies of the originals.  Lastly, call the intended
function, passing along the argument list as parameters to the
function.  After the call has completed and the values passed back to
APL2, free the entire...