Sort of. A role is a "package" of components available to build classes
from. This allows someone to write a sub or method that works for any kind
of number by using the role instead of having to write the same thing over
and over for every numeric class, or every class representing a non-complex
number, etc. There is similarly a role packaging up various operations
common to all string-like types, called Stringy.

On Mon, Sep 17, 2018 at 12:03 AM ToddAndMargo <toddandma...@zoho.com> wrote:

> On 9/16/18 8:51 PM, Brandon Allbery wrote:
> > You're assuming "Real" means "a float of some kind". It's not; it
> > defines all the operations in common over non-Complex numbers (Int, Rat,
> > Num, etc.). What you are looking for, Perl 6 calls Num.
>
> https://docs.perl6.org/type.html:
>     Real        role    Non-complex number
>
> https://en.wikipedia.org/wiki/Real_number
>
>       In mathematics, a real number is a value of a continuous
>       quantity that can represent a distance along a line. The
>       adjective real in this context was introduced in the 17th
>       century by René Descartes, who distinguished between real
>       and imaginary roots of polynomials. The real numbers
>       include all the rational numbers, such as the integer −5
>       and the fraction 4/3, and all the irrational numbers, such
>       as √2 (1.41421356..., the square root of 2, an irrational
>       algebraic number). Included within the irrationals are
>       the transcendental numbers, such as π (3.14159265...). In
>       addition to measuring distance, real numbers can be used
>       to measure quantities such as time, mass, energy, velocity,
>       and many more.
>
> So Rat is a subset of Real.
>
> And if I want something specific, I have to call out
> a "class", not a "Role".  A "Role" is a superset of "classes".
> And I will get the proper class picked out of the subsets
> when I assign something to the variable.  I will only
> throw an error is I asn something that is not in tne subsets.
>
>      Rat        class Rational number (limited-precision)
>
> Okay, class dismissed.
>
> Thank you.  You guys have been very patient with me.
>
> -T
>


-- 
brandon s allbery kf8nh
allber...@gmail.com

Reply via email to