scalarp and nonscalarp



On 5/1/10, Dieter Kaiser <drdieterkaiser at web.de> wrote:

> The documentation of scalarp says that an expression is assumed to be
> scalar if the expression is composed only out of numbers, constants, or
> variables declared to be scalar. Furthermore, the implementation of
> scalarp is in a way that functions, which have only scalar arguments are
> assumed to have a scalar value too.

Well, the current behavior of scalarp, which derives the scalar
property of a function from its arguments, is really unjustified,
isn't it? There is no necessary connection between the domain
and codomain.

I can't tell if you want to change the behavior of scalarp so that
it does not derive the scalar-ness of the function from its arguments,
but I am certainly in favor of that. (I would suggest some mechanism
to declare the domain and codomain, or to declare that a function
maps one subset of the domain into a subset of the codomain with
specified properties, e.g. maps integers to integers, or perhaps more
more bluntly just declare that a function has a scalar-preservation
property. But at any rate such properties would affect scalarp only
for functions with appropriate declarations. Built-in operators would
have such declarations as appropriate.)

> 1.
> Functions not declared to be nonscalar have a scalar value, if the
> arguments are scalar.
>
> 2.
> Subscripted symbols not declared to be scalar are assumed to represent a
> nonscalar expression.

I dunno. These both seem wrong to me.

In (1) in the absence of a declaration which describes the action
of the function somehow, it doesn't seem justifiable to take the
arguments into account.

Subscripted symbols seem problematic. With a declaration like
declare(a, nonscalar), does that imply that a[whatever] is nonscalar?
Often enough we'd like to attach a subscript to a nonscalar variable
to indicate a component of the variable. How can we distinguish
between the nonscalar variable itself and its scalar components?

As a separate issue, we'll probably want to make some default
assumption about scalar versus nonscalar, but it seems like that
assumption should be the same for functions as for subscripted
expressions.

Sorry if this doesn't make much sense.

best

Robert Dodier