Ashley Winters wrote:

For documentary purposes, can we make that $radians?

multi sub cos (Num +$degrees) returns Num {
   return cos :radians($degrees * PI  / 180);
}

my Num $x = cos :degrees(270);

I have changed the trig functions it to have an optional "base" argument. (I'm option to new names for this term.)

The problem I see with your proposal is that both versions have the same MMD long name, which only looks at required parameters. We'd have to have something like:

multi sub cos (Num ?$radians = $CALLER:_, Num +$degrees, Num +$gradians) returns Num

And then internally dispatch on what is defined and undefined.


Personally I like

   multi sub cos (Num ?$x = $CALLER::_, Num|Str +$base) returns Num

better. You can do:

   our &cos<> := &cos<>.assuming:base('degrees');

to make cosine "degrees only" for your current package.


-- Rod Adams

Reply via email to