Darren Duncan wrote:
> 2.  There doesn't seem to be a role for "complex" as there is for "integer"
> or "rational" or "real" or "numeric".  So, if the boxed Perl complex number
> is called "Complex" and the machine native one is called "complex" or
> "complex128" or whatever, what would one name the role that is common to all
> of these?

I'm definitely in favor of there being a Complex role - not just for
the reasons given above, but also to have a common role that applies
to a complex number regardless of the coordinate system that's being
used to store the value (e.g. cartesian vs. polar).  Both should be
able to provide you with the real, imaginary, magnitude, and direction
components; but classes based off of the cartesian model should be
able to do the former two directly and calculate the latter two, and
vice versa.  A single role that's agnostic about the coordinate system
would allow us to use any of these in a function call.  For that
purpose, I think that the common, underlying role should be called
"Complex".

> Following the above pattern, you'd think that "Complex" would be best used
> as th role name and so something else is needed for the type, either as some
> abbreviation, or alternately with additions.
>
> Conceivably one could have a complex type defined in terms of any
> combination of the various real or rational or integer types, such as
> "NumComplex" or "RatComplex" (and "FatRatComplex") and "IntComplex" etc.

For practical purposes, I think that the component types for Complex
should be standardized as Real - that is, the Complex role should
assume that the components do the Real role.  As I indicate above, I
think that a more significant distinction should be the coordinate
system: cartesian complex numbers are essentially optimized for use
with addition and subtraction; polar complex numbers are a more
efficient choice for multiplication and division; raising a number to
a complex exponent works most efficiently if the exponent is cartesian
and the result is polar, and vice versa for logs.  And so on.

> For the integer version, my understanding is that number theory already
> provides a suitable term, "Gaussian integer", which is a complex number
> whose real and imaginary parts are both integers.
>
> So I suggest using "Gaussian" as the name option for an "IntComplex".
>
> Or maybe better yet for completion sake, make "Gaussian" a role and
> something like "Gaus" the type or something.

Hmm... true enough.  I'd rather have Gaussian be to Complex as
Integral is to Real: a separate role, not necessarily related in any
sort of role composition sense, but serving a similar purpose.  Note
that Gaussian would not have separate cartesian and polar forms; by
definition, it operates off of a cartesian coordinate system.  While a
polar version could exist in theory, it doesn't in practice; and even
if it did, it wouldn't be interchangeable with the cartesian version,
the way that they are when the components are Real.

OTOH, Gaussian definitely has analogs comparable to the differences
between Integral vs. Real, in that Gaussian and Integral have the
concept of factors and everything that goes with them (e.g., primes,
gcf, lcm, remainders, etc.)  Perhaps we need a role to encapsulate
that notion, much like we have one that encapsulates the notion of
order (e.g., before/after).  Or would that turn out to be unnecessary
clutter, seeing as how we only have two examples of roles that would
compose it (Integral and Gaussian), one of which is a highly technical
fringe case?

> Alternately, while we would still need a Complex-specific role, we could
> possibly avoid a need to explicitly declare some of the composing types if
> Complex is parameterizable, as AFAIK Rational et al are parameterizable.

I'm fine with Complex being parameterizable, as long as Real is the
default parameter.

> 3.  I notice that some roles that are longer forms of type names look like
> nouns, while others look like adjectives.  I suppose that adjectives are
> what you're going after, and the ones that look like nouns such as "Boolean"
> and "Rational" and "Real" are also adjectives.  On the other hand, lots of
> roles are surely just nouns, such as "Failure" and "Routine".
>
> So a question I have is, given the context, is "Integral" the best name for
> that role, or would "Integer" be better?

>From a layman's view of things, I keep on finding myself wanting to
say "Integer" rather than "Integral".  That said, it's not that hard
to retrain myself; and I do see some benefit to the notion that role
names are adjectives while class names are nouns, as long as it's
applied consistently to the standard roles.  That said, see below.

Still: when I first saw "Integral", the first thing that came to mind
was "a calculus operation", not "whole numbers".

> 4.  If "Integral" is better called "Integer", or regardless ...
>
> Would "Numeric" be better called "Number"?  Would there by any objection to
> renaming it such?  What are advantages of the former over the latter?
>
> Basically, same idea, if we're going more for nouns or adjectives role
> names.

IMHO, we should be going for nouns for role names.  Adjectives should
be reserved for use with a role's parameters - that is, a named
parameter in a role's signature is an adjective, just like a named
parameter in a routine's signature is an adverb.

-- 
Jonathan "Dataweaver" Lang

Reply via email to