Author: lwall
Date: 2009-07-18 18:44:26 +0200 (Sat, 18 Jul 2009)
New Revision: 27605
Modified:
docs/Perl6/Spec/S32-setting-library/Numeric.pod
Log:
[Numeric] kill :Trig tag, always include trig functions.
Replace stupid string args with an enum.
Default to lexical constant $?TRIGBASE.
Modified: docs/Perl6/Spec/S32-setting-library/Numeric.pod
===================================================================
--- docs/Perl6/Spec/S32-setting-library/Numeric.pod 2009-07-18 14:42:37 UTC
(rev 27604)
+++ docs/Perl6/Spec/S32-setting-library/Numeric.pod 2009-07-18 16:44:26 UTC
(rev 27605)
@@ -19,8 +19,8 @@
Created: 19 Mar 2009 extracted from S29-functions.pod
- Last Modified: 19 Feb 2009
- Version: 1
+ Last Modified: 18 Jul 2009
+ Version: 2
The document is a draft.
@@ -228,16 +228,19 @@
=back
-=head2 The :Trig tag
+=head2 Trigonometric functions
-The following are also defined in C<Num> but not exported without a C<:Trig>
-tag. (Which installs their names into C<Num::Trig>, as it happens.)
+The following are also defined in C<Num>. The trig functions
+depend on the current (lexically scoped) trig base:
+ enum TrigBase is export <Radians Degrees Gradians Circles>;
+ constant $?TRIGBASE = Radians;
+
=over 4
=item I<Standard Trig Functions>
- Num multi method func ( Num $x: $base = 'radians' ) is export(:Trig)
+ Num multi method func ( Num $x: TrigBase $base = $?TRIGBASE ) is export
where I<func> is one of:
sin, cos, tan, asin, acos, atan, sec, cosec, cotan, asec, acosec,
@@ -249,20 +252,18 @@
Option C<$base> is used to declare how you measure your angles.
Given the value of an arc representing a single full revolution.
- $base Result
- ---- -------
- /:i ^r/ Radians (2*pi)
- /:i ^d/ Degrees (360)
- /:i ^g/ Gradians (400)
- Num Units of 1 revolution.
+ $base Subdivisions of circle
+ ---- ----------------------
+ Radians 2*pi
+ Degrees 360
+ Gradians 400
+ Circles 1
-Note that module currying can be used within a lexical scope to specify
-a consistent base so you don't have to supply it with every call:
+To change the base within your own lexical scope, it suffices to redefine the
+compiler constant:
- my module Trig ::= Num::Trig.assuming(:base<degrees>);
+ constant $?TRIGBASE = Degrees;
-This overrides the default of "radians".
-
=item atan2
our Num multi method atan2 ( Num $y: Num $x = 1 )
@@ -277,3 +278,5 @@
Please post errors and feedback to perl6-language. If you are making
a general laundry list, please separate messages by topic.
+
+=for vim:set expandtab sw=4: