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

Re: Proposed numeric type hierarchy



On Wednesday, October 23, 2002, at 11:30  AM, Neel Krishnaswami wrote:

> James Knight writes:
>>
>> On Monday, October 21, 2002, at 08:28  AM, Neel Krishnaswami wrote:
>>>> ;; I hope this is the right use of the term 'scalar'
>>>> (dc <scalar> (<any>))
>>>
>>> Unfortunately, it's not. Scalars are real values, which means that
>>> complex isn't an appropriate subclass for them.
>>
>> I was hoping the important piece of meaning was "not vector". What's
>> a better term?
>
> I don't think there is one. "Scalar" is a really crummy word, because
> it's usually defined as a real value, but everyone uses it to also
> mean "not a vector". So you have definitions like: a scalar field is a
> function R^n -> R, which leaves you out of luck with complex numbers.

In terms of linear algebra, a scalar is an element of the field that 
the vector space is defined over. Thus, any element of any field can be 
considered a scalar. This maps most closely to the meaning we want for 
a programming language, since the type is specifying the set of 
allowable operations. A field defines the addition and multiplication 
operations, which work the way we expect them to work (associative, 
distributive, etc.). I think it would be fair to allow <scalar> to have 
any field as a subclass, if we look at it from this perspective.

All sources I can find online and in books I have seem to be split as 
to whether you should count complex numbers as scalars. Some 
concentrate on the aspect that it must be a "directionless magnitude", 
and some that it is a real number, while others claim that it is just 
an element of a field.

Is there any reason why we don't just call the class <number> or <num>?