r29181 - in docs/Perl6/Spec: . S32-setting-library

2009-11-24 Thread pugs-commits
Author: lwall
Date: 2009-11-24 09:38:16 +0100 (Tue, 24 Nov 2009)
New Revision: 29181

Modified:
   docs/Perl6/Spec/S02-bits.pod
   docs/Perl6/Spec/S03-operators.pod
   docs/Perl6/Spec/S04-control.pod
   docs/Perl6/Spec/S06-routines.pod
   docs/Perl6/Spec/S10-packages.pod
   docs/Perl6/Spec/S12-objects.pod
   docs/Perl6/Spec/S17-concurrency.pod
   docs/Perl6/Spec/S32-setting-library/Basics.pod
   docs/Perl6/Spec/S32-setting-library/IO.pod
   docs/Perl6/Spec/S32-setting-library/Str.pod
Log:
clobber undef as a poorly defined noun, use Object or Nil


Modified: docs/Perl6/Spec/S02-bits.pod
===
--- docs/Perl6/Spec/S02-bits.pod2009-11-24 00:29:03 UTC (rev 29180)
+++ docs/Perl6/Spec/S02-bits.pod2009-11-24 08:38:16 UTC (rev 29181)
@@ -13,8 +13,8 @@
 
 Created: 10 Aug 2004
 
-Last Modified: 19 Nov 2009
-Version: 191
+Last Modified: 23 Nov 2009
+Version: 192
 
 This document summarizes Apocalypse 2, which covers small-scale
 lexical items and typological issues.  (These Synopses also contain
@@ -591,18 +591,18 @@
 such as C, C and C objects.  See S04 for more
 about failures (i.e. unthrown exceptions):
 
-my Int $x = undef;# works
+my Int $x = Int;# works
 
 Variables with native types do not support undefinedness: it is an error
 to assign an undefined value to them:
 
-my int $y = undef;# dies
+my int $y = Int;# dies
 
-Conjecture: num might support the autoconversion of undef to NaN, since
-the floating-point form can represent this concept.  Might be better
-to make that conversion optional though, so that the rocket designer
-can decide whether to self-destruct immediately or shortly thereafter.
+Since C can support the value C but not the general concept of
+undefinedness, you can coerce an undefined value like this:
 
+my num = computation() // NaN;
+
 Variables of non-native types start out containing an undefined value
 unless explicitly initialized to a defined value.
 
@@ -1047,14 +1047,18 @@
 
 =head2 Undefined types
 
-These can behave as values or objects of any class, except that
-C always returns false.  One can create them with the
-built-in C and C functions.  (See S04 for how failures
-are handled.)
+Perl 6 does not have a single value representing undefinedness.
+Instead, objects of various types can carry type information while
+nevertheless remaining undefined themselves.  Whether an object is
+defined is determined by whether C<.defined> returns true or not.
+These typed objects typically represent unitialized values.  Failure
+objects are also officially undefined despite carrying exception
+information; these may be created using the C function, or by
+direct construction of an exception object of some sort.  (See S04
+for how failures are handled.)
 
-Nil Empty list viewed as an item
 Object  Uninitialized (derivatives serve as type objects)
-WhateverWildcard (like undef, but subject to do-what-I-mean via MMD)
+WhateverWildcard (like Object, but subject to do-what-I-mean via MMD)
 Failure Failure (lazy exceptions, thrown if not handled properly)
 
 Whenever you declare any kind of type, class, module, or package, you're
@@ -1074,53 +1078,12 @@
 
 Whenever a C value is put into a typed container, it takes
 on the type specified by the container but continues to carry the
-C role.  (The C function merely returns the most
-generic C object.  Use C to return more specific failures.  Use
+C role.  
+Use C to return specific failures.  Use
 C for the most generic non-failure undefined value.  The C
 type is also undefined, but excludes C so that autothreading
-may be dispatched using normal multiple dispatch rules.)
+may be dispatched using normal multiple dispatch rules.
 
-The C type is officially undefined as an item but interpolates
-as a null list into list context, and an empty capture into slice
-context.  A C object may also carry failure information,
-but if so, the object behaves as a failure only in item context.
-Use C when you want to return a hard failure that
-will not evaporate in list context.  Casting to C is one
-way of evaluating an expression and throwing the result away:
-
-@inclist = map { $_ + 1 }, @list || Nil( warn 'Empty @list!' );
-
-@inclist = do for @list || Nil( warn 'Empty @list!' ) {
-$_ + 1;
-}
-
-Or if you want to test whether you got any results back from
-the C or C:
-
-@inclist = do map { $_ + 1 }, @list or Nil( warn 'Empty @list!' );
-
-@inclist = do for @list {
-$_ + 1;
-} or Nil( warn 'Empty @list!' )
-
-Since the construct is in the form of a type cast, the parens are required.
-If that syntax is unappealing or you wish to run multiple statements
-in a block, it happens that the C statement prefix also converts
-any value to C, so the examples above can be expressed
-without parentheses:
-
-@inclist = map { $_ + 1 }, @list || sink warn

r29183 - in docs/Perl6/Spec: . S32-setting-library

2009-11-24 Thread pugs-commits
Author: lwall
Date: 2009-11-24 10:25:36 +0100 (Tue, 24 Nov 2009)
New Revision: 29183

Modified:
   docs/Perl6/Spec/S02-bits.pod
   docs/Perl6/Spec/S04-control.pod
   docs/Perl6/Spec/S05-regex.pod
   docs/Perl6/Spec/S06-routines.pod
   docs/Perl6/Spec/S09-data.pod
   docs/Perl6/Spec/S12-objects.pod
   docs/Perl6/Spec/S32-setting-library/Basics.pod
Log:
tentatively rename Object to U, representing (among other things)
Universal, Undefined, Union, and Uranium :)


Modified: docs/Perl6/Spec/S02-bits.pod
===
--- docs/Perl6/Spec/S02-bits.pod2009-11-24 08:44:27 UTC (rev 29182)
+++ docs/Perl6/Spec/S02-bits.pod2009-11-24 09:25:36 UTC (rev 29183)
@@ -588,7 +588,7 @@
 =item *
 
 Variables with non-native types can always contain I values,
-such as C, C and C objects.  See S04 for more
+such as C, C and C objects.  See S04 for more
 about failures (i.e. unthrown exceptions):
 
 my Int $x = Int;# works
@@ -1057,16 +1057,16 @@
 direct construction of an exception object of some sort.  (See S04
 for how failures are handled.)
 
-Object  Uninitialized (derivatives serve as type objects)
-WhateverWildcard (like Object, but subject to do-what-I-mean via MMD)
+U   Uninitialized (derivatives serve as type objects)
 Failure Failure (lazy exceptions, thrown if not handled properly)
 
 Whenever you declare any kind of type, class, module, or package, you're
 automatically declaring a undefined prototype value with the same name, known
 as the I.  The name itself returns that type object:
 
-Object  Perl 6 object (default block parameter type, either Any or 
junction)
+U   Perl 6 object (default block parameter type, either Any or 
junction)
 Any Perl 6 object (default routine parameter type, excludes 
junction)
+WhateverWildcard (like Any, but subject to do-what-I-mean via MMD)
 Int Any Int object
 Widget  Any Widget object
 
@@ -1080,7 +1080,7 @@
 on the type specified by the container but continues to carry the
 C role.  
 Use C to return specific failures.  Use
-C for the most generic non-failure undefined value.  The C
+C for the most generic non-failure undefined value.  The C
 type is also undefined, but excludes C so that autothreading
 may be dispatched using normal multiple dispatch rules.
 
@@ -1200,7 +1200,7 @@
 value for the C, the element is deleted.  If undeclared,
 the default default for a C is 0 for numeric types, C
 for boolean types, and the null string for string and buffer types.
-A C of a C type defaults to the undefined prototype
+A C of an object type defaults to the undefined prototype
 for that type.  More generally, the default default is whatever defined
 value a C would convert to for that value type.  A C
 of C deletes elements that go to either 0 or the null string.
@@ -1798,7 +1798,7 @@
 Assigning or binding C to any scalar container causes the
 container to throw out any contents and restore itself to an
 uninitialized state (after which it will contain a type object
-appropriate to the declared type of the container, or C
+appropriate to the declared type of the container, or C
 for untyped containers).
 
 Assigning or binding C to any composite container (such as an
@@ -3842,12 +3842,12 @@
 =item *
 
 The definition of C<.Bool> for the most ancestral type (that is, the
-C type) is equivalent to C<.defined>.  Since type objects are
-considered undefined, all type objects (including C itself)
+C type) is equivalent to C<.defined>.  Since type objects are
+considered undefined, all type objects (including C itself)
 are false unless the type overrides the definition of C<.Bool>
 to include undefined values.  Instantiated objects default to true
 unless the class overrides the definition.  Note that if you could
-instantiate an C it would be considered defined, and thus true.
+instantiate a C it would be considered defined, and thus true.
 (It is not clear that this is allowed, however.)
 
 =item *

Modified: docs/Perl6/Spec/S04-control.pod
===
--- docs/Perl6/Spec/S04-control.pod 2009-11-24 08:44:27 UTC (rev 29182)
+++ docs/Perl6/Spec/S04-control.pod 2009-11-24 09:25:36 UTC (rev 29183)
@@ -1119,7 +1119,7 @@
 any container whose type allows the C role to be mixed in.)
 The C<.handled> method returns C on failures that have not
 been handled.  It returns C for handled exceptions and for
-all non-C objects. (That is, it is an C method,
+all non-C objects. (That is, it is a C method,
 not a C method.  Only C objects need to store the
 actual status however; other types just return C.)
 
@@ -1533,7 +1533,7 @@
 and not care about whether the function is being called in item or list
 context.  To return an explicit scalar undef, you can always say
 
-return Object;
+return U;
 
 Then in list context, you're returning a list of length 1, which

r29186 - in docs/Perl6/Spec: . S32-setting-library

2009-11-24 Thread pugs-commits
Author: lwall
Date: 2009-11-24 18:50:52 +0100 (Tue, 24 Nov 2009)
New Revision: 29186

Modified:
   docs/Perl6/Spec/S02-bits.pod
   docs/Perl6/Spec/S04-control.pod
   docs/Perl6/Spec/S05-regex.pod
   docs/Perl6/Spec/S06-routines.pod
   docs/Perl6/Spec/S09-data.pod
   docs/Perl6/Spec/S12-objects.pod
   docs/Perl6/Spec/S32-setting-library/Basics.pod
Log:
much less tentatively go with the Mu suggestion from TheDamian++


Modified: docs/Perl6/Spec/S02-bits.pod
===
--- docs/Perl6/Spec/S02-bits.pod2009-11-24 12:37:18 UTC (rev 29185)
+++ docs/Perl6/Spec/S02-bits.pod2009-11-24 17:50:52 UTC (rev 29186)
@@ -588,7 +588,7 @@
 =item *
 
 Variables with non-native types can always contain I values,
-such as C, C and C objects.  See S04 for more
+such as C, C and C objects.  See S04 for more
 about failures (i.e. unthrown exceptions):
 
 my Int $x = Int;# works
@@ -1045,26 +1045,49 @@
 type based on 32-bit integers produces valid UTF-32 in the native
 endianness.)
 
+=head2 The C type
+
+Among other things, C is named after the eastern concept of
+"Mu" or 無 (see L, especially the
+"Mu_(negative)" entry), so in Perl 6 it stands in for Perl 5's
+concept of "undef" when that is used as a noun.  However, C is also
+the "nothing" from which everything else is derived via the undefined
+type objects, so it stands in for the concept of "Object" as used in
+languages like Java.  Or think of it as a "micro" or µ-object that
+is the the basis for all other objects, something atomic like a Muon.
+Or if acronyms make you happy, there are a variety to pick from:
+
+Most Universal
+More Undefined
+Modern Undef
+Master Union
+Meta Ur
+Mega Up
+...
+
+Or just think of it as a sound a cow makes, which simultaneously
+means everything and nothing.
+
 =head2 Undefined types
 
 Perl 6 does not have a single value representing undefinedness.
 Instead, objects of various types can carry type information while
 nevertheless remaining undefined themselves.  Whether an object is
 defined is determined by whether C<.defined> returns true or not.
-These typed objects typically represent unitialized values.  Failure
+These typed objects typically represent uninitialized values.  Failure
 objects are also officially undefined despite carrying exception
 information; these may be created using the C function, or by
 direct construction of an exception object of some sort.  (See S04
 for how failures are handled.)
 
-U   Uninitialized (derivatives serve as type objects)
+Mu  Most Undefined
 Failure Failure (lazy exceptions, thrown if not handled properly)
 
 Whenever you declare any kind of type, class, module, or package, you're
 automatically declaring a undefined prototype value with the same name, known
 as the I.  The name itself returns that type object:
 
-U   Perl 6 object (default block parameter type, either Any or 
junction)
+Mu  Perl 6 object (default block parameter type, either Any or 
junction)
 Any Perl 6 object (default routine parameter type, excludes 
junction)
 WhateverWildcard (like Any, but subject to do-what-I-mean via MMD)
 Int Any Int object
@@ -1078,11 +1101,12 @@
 
 Whenever a C value is put into a typed container, it takes
 on the type specified by the container but continues to carry the
-C role.  
-Use C to return specific failures.  Use
-C for the most generic non-failure undefined value.  The C
-type is also undefined, but excludes C so that autothreading
-may be dispatched using normal multiple dispatch rules.
+C role.  Use C to return specific failures.  Use C
+for the most generic non-failure undefined value.  The C type,
+derived from C, is also undefined, but excludes C so
+that autothreading may be dispatched using normal multiple dispatch
+rules.  The C type is derived from C but nothing else
+is derived from it.
 
 =head2 Immutable types
 
@@ -1798,7 +1822,7 @@
 Assigning or binding C to any scalar container causes the
 container to throw out any contents and restore itself to an
 uninitialized state (after which it will contain a type object
-appropriate to the declared type of the container, or C
+appropriate to the declared type of the container, or C
 for untyped containers).
 
 Assigning or binding C to any composite container (such as an
@@ -3842,12 +3866,12 @@
 =item *
 
 The definition of C<.Bool> for the most ancestral type (that is, the
-C type) is equivalent to C<.defined>.  Since type objects are
-considered undefined, all type objects (including C itself)
+C type) is equivalent to C<.defined>.  Since type objects are
+considered undefined, all type objects (including C itself)
 are false unless the type overrides the definition of C<.Bool>
 to include undefined values.  Instantiated objects default to true
 unless the class overrides the definition.  Note that if you 

r29187 - docs/Perl6/Spec

2009-11-24 Thread pugs-commits
Author: lwall
Date: 2009-11-24 21:31:37 +0100 (Tue, 24 Nov 2009)
New Revision: 29187

Modified:
   docs/Perl6/Spec/S04-control.pod
Log:
[S04] clarifications suggested by TheDamian++


Modified: docs/Perl6/Spec/S04-control.pod
===
--- docs/Perl6/Spec/S04-control.pod 2009-11-24 17:50:52 UTC (rev 29186)
+++ docs/Perl6/Spec/S04-control.pod 2009-11-24 20:31:37 UTC (rev 29187)
@@ -13,8 +13,8 @@
 
 Created: 19 Aug 2004
 
-Last Modified: 19 Nov 2009
-Version: 89
+Last Modified: 24 Nov 2009
+Version: 90
 
 This document summarizes Apocalypse 4, which covers the block and
 statement syntax of Perl.
@@ -196,11 +196,21 @@
 
 =head1 The Relationship of Blocks and Statements
 
-The return value of a block is the value of its final statement.
-(This is subtly different from Perl 5's behavior, which was to return
+In the absence of explicit control flow terminating the block early,
+the return value of a block is the value of its final statement.
+This is defined as the textually last statement of its top-level
+list of statements; any statements embedded within those top-level
+statements are in their own lower-level list of statements and,
+while they may be a final statement in their subscope, they're not
+considered the final statement of the outer block in question.
+
+This is subtly different from Perl 5's behavior, which was to return
 the value of the last expression evaluated, even if that expression
-was just a conditional.)  If there are no statements in the block,
-the result is C.
+was just a conditional.  Unlike in Perl 5, if a final statement in
+Perl 6 is a conditional that does not execute any of its branches, it
+doesn't matter what the value of the condional is, the value of that
+conditional statement is always C.  If there are no statements
+in the block at all, the result is also C.
 
 =head1 Statement-ending blocks
 
@@ -919,6 +929,10 @@
 
 doit() if $_ ~~ 42;
 
+This is particularly useful for list comprehensions:
+
+@lucky = ($_ when /7/ for 1..100);
+
 =head1 Exception handlers
 X
 
@@ -1243,9 +1257,13 @@
 
 sets the variable to 0 at C time, since that is when the "my"
 declaration is actually executed.  Only argumentless phasers may
-use the statement form.  This means that C and C
+use the statement form.  This means that C and C
 always require a block, since they take an argument that sets C<$_>
-to the current topic.
+to the current topic, so that the innards are able to behave
+as a switch statement.  (If bare statements were allowed, the
+temporary binding of C<$_> would leak out past the end of the C
+or C, with unpredictable and quite possibly dire consequences.
+Exception handlers are supposed to reduce uncertainty, not increase it.)
 
 Code that is generated at run time can still fire off C
 and C phasers, though of course those phasers can't do things that



r29188 - docs/Perl6/Spec

2009-11-24 Thread pugs-commits
Author: masak
Date: 2009-11-25 01:11:23 +0100 (Wed, 25 Nov 2009)
New Revision: 29188

Modified:
   docs/Perl6/Spec/S12-objects.pod
Log:
changed .accessor to .has-accessor on attribute descriptors

Modified: docs/Perl6/Spec/S12-objects.pod
===
--- docs/Perl6/Spec/S12-objects.pod 2009-11-24 20:31:37 UTC (rev 29187)
+++ docs/Perl6/Spec/S12-objects.pod 2009-11-25 00:11:23 UTC (rev 29188)
@@ -13,8 +13,8 @@
 
 Created: 27 Oct 2004
 
-Last Modified: 28 Oct 2009
-Version: 91
+Last Modified: 25 Nov 2009
+Version: 92
 
 =head1 Overview
 
@@ -2027,7 +2027,7 @@
 scope
 rw
 private
-accessor
+has-accessor
 build
 readonly
 



r29192 - docs/Perl6/Spec/S32-setting-library

2009-11-24 Thread pugs-commits
Author: lwall
Date: 2009-11-25 03:23:06 +0100 (Wed, 25 Nov 2009)
New Revision: 29192

Modified:
   docs/Perl6/Spec/S32-setting-library/Basics.pod
Log:
[S32/Basics] add a .notdef convenience method for ease of writing *.notdef 
matchers


Modified: docs/Perl6/Spec/S32-setting-library/Basics.pod
===
--- docs/Perl6/Spec/S32-setting-library/Basics.pod  2009-11-25 02:22:14 UTC 
(rev 29191)
+++ docs/Perl6/Spec/S32-setting-library/Basics.pod  2009-11-25 02:23:06 UTC 
(rev 29192)
@@ -30,14 +30,17 @@
 
 =head1 Roles
 
-=head2 Object
+=head2 Mu
 
-The following are defined in the C role:
+The following are defined in the C role:
 
- role Object {
+ role Mu {
  our Bool multi method defined ($self:) is export {...}
  our Bool multi method defined ($self: ::role ) is export {...}
 
+ our Bool multi method notdef ($self:) is export {...}
+ our Bool multi method notdef ($self: ::role ) is export {...}
+
  our multi method undefine( $self: ) is export {...}
 
  method not() {...}
@@ -104,7 +107,7 @@
 
 The following are defined in the C role:
 
- role Any does Object does Pattern {
+ role Any does Mu does Pattern {
  our Bool multi sub eqv (Ordering @by, $a, $b) {...}
  our Bool multi sub eqv (Ordering $by = &infix:, $a, $b) {...}
 
@@ -117,8 +120,8 @@
  our Callable multi method can ($self:, Str $method) {...}
  our Bool multi method does ($self:, $type) {...}
  our Bool multi method isa  ($self:, $type) {...}
- our Str  multi method perl ( Object $o: ) is export {...}
- our  multi method warn ( Object $o: ) is export {...}
+ our Str  multi method perl ( Mu $o: ) is export {...}
+ our  multi method warn ( Mu $o: ) is export {...}
  }
 
 =over
@@ -182,14 +185,14 @@
 
 =item perl
 
- our Str multi method perl ( Object $o: ) is export
+ our Str multi method perl ( Mu $o: ) is export
 
 Returns a perlish representation of the object, so that calling C
 on the returned string reproduces the object as accurately as possible.
 
 =item warn
 
- our multi method warn ( Object $o: ) is export
+ our multi method warn ( Mu $o: ) is export
 
 Throws a resumable warning exception, which is considered a control
 exception, and hence is invisible to most normal exception handlers.