> < ^ Date: Wed, 06 Oct 1999 08:58:48 +0200 (CEST)
> < ^ From: Thomas Breuer <Thomas.Breuer@Math.RWTH-Aachen.DE >
< ^ Subject: Re: functions

Dear GAP Forum,

Miklos Maroti wrote

I have two questions about GAP 4. First, is there a way to call a function
of known (but only at runtime) arity with a list of arguments? So given
FUNC and ARGS, where ARGS is a list, and FUNC is a function which expects
Length(ARGS) arguments. How to make the call?

There is the function `CallFuncList' that takes a function <fun>
and the list `[ <arg1>, <arg2>, ... ]' of arguments,
and executes `<fun>( <arg1>, <arg2>, ... )'.
If <fun> returns a value then this is the value
of the `CallFuncList' call.

(`CallFuncList' is currently not documented.
A description will be added in the next version of GAP,
thanks for the hint.
By the way:
There is also the undocumented function `NARGS_FUNC' that can be used
to determine the number of arguments expected by a function.)

My second question is probably philosophical. Which one is better?
Creating a representation derived from AttributeStoringRep and have some
fixed records, or simply use the AttributeStoringRep with Attributes?

My answer is a clear ``it depends''.

An attribute or, more general, an operation applicable to an object <obj>
expresses part of the functionality that is available for <obj>.
A representation of an object <obj> expresses the way how the object <obj>
is stored internally, independent of the functionality for <obj>.
(A typical example is that of different possibilities to represent
lists; the length is clearly part of the functionality,
whereas the data needed to encode a sparse matrix or block matrix
need be accessible only to the few low level functions that implement
the element access etc. of such matrices.)

A pragmatic rule derived from this distinction could be the following.
If one designs new kinds of objects and needs to store various data
to represent them,
the question is mainly whether the data is of general interest and
therefore access to it is regarded as part of the functionality
or whether the data should be hidden from the user.
In the former case one should use attributes,
and in the latter case one should use representations.

Thomas Breuer

> < [top]