Can I edit the list of the blogs I've read?
Perl web-programming
Hello Guest
  
  • Login
• Register…
• Start blog
  • Who, Where, When
• What is interesting here?
• Duels
  • Polls
• Avatars
• Interests
  • Cities and Countries
• Random blog
• Users search
  • Search
• Games
• Tests
• QAIX
  • Сообщества
• Talxy Chat
• Horoscope
• Online
 
Register!

QAIX > Perl web-programmingGo to page: « previous | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | next »

  Top users: 
  Recent blog posts: 
  They have birthday today: 
  Forums:   
  Discuss: 
  Recent forum topics: 
  Recent forum comments:
  Модератор:
Tuesday, 24 February 2009
r25506 - in docs/Perl6/Spec: . S32-setting-library Guest 03:16:09
 Author: wayland
Date: 2009-02-24 01:16:08 +0100 (Tue, 24 Feb 2009)
New Revision: 25506

Modified:
docs/Perl6/Spec/S14­-roles-and-parametri­c-types.pod
docs/Perl6/Spec/S32­-setting-library/IO.­pod
Log:
IO.pod: Updated reference to Temporal.pod
S14: Gave credits properly


Modified: docs/Perl6/Spec/S14­-roles-and-parametri­c-types.pod
===================­====================­====================­========
--- docs/Perl6/Spec/S14­-roles-and-parametri­c-types.pod 2009-02-23 23:59:53 UTC (rev 25505)
+++ docs/Perl6/Spec/S14­-roles-and-parametri­c-types.pod 2009-02-24 00:16:08 UTC (rev 25506)
@@ -2,15 +2,14 @@

=head1 TITLE

-Synopsis 12: Roles and Parametric Types
+Synopsis 14: Roles and Parametric Types [DRAFT]

-=head1 AUTHOR
-
-Larry Wall <larry@wall.org>
-
=head1 VERSION

- Maintainer: Larry Wall <larry@wall.org>
+ Author: Larry Wall <larry@wall.org>
+ Maintainer: Larry Wall <larry@wall.org>
+ Contributions: Tim Nelson <wayland@wayland.id­.au>
+ Jonathan Worthington <jnthn@jnthn.net>
Date: 24 Feb 2009, extracted from S12-objects.pod
Last Modified: 24 Feb 2009
Number: 14

Modified: docs/Perl6/Spec/S32­-setting-library/IO.­pod
===================­====================­====================­========
--- docs/Perl6/Spec/S32­-setting-library/IO.­pod 2009-02-23 23:59:53 UTC (rev 25505)
+++ docs/Perl6/Spec/S32­-setting-library/IO.­pod 2009-02-24 00:16:08 UTC (rev 25506)
@@ -536,7 +536,7 @@
}

The %times has keys that can be eg. ctime, Modification, and Access (and maybe others on
-other operating systems), and the values are all DateTime objects.
+other operating systems), and the values are all Temporal::Instant objects.

When .path() is implemented, it should return the path that this was opened with.


Add comment
r25503 - docs/Perl6/Spec Guest 02:33:42
 Author: wayland
Date: 2009-02-24 00:33:42 +0100 (Tue, 24 Feb 2009)
New Revision: 25503

Added:
docs/Perl6/Spec/S14­-roles-and-parametri­c-types.pod
Modified:
docs/Perl6/Spec/S12­-objects.pod
docs/Perl6/Spec/S29­-functions.pod
Log:
S29: s/Container.pod/Con­tainers.pod/
S14/S12: Extracted S14 from S12, added Jonathan's blog entry, a bit from S02, and a bit
from the spectests


Modified: docs/Perl6/Spec/S12­-objects.pod
===================­====================­====================­========
--- docs/Perl6/Spec/S12­-objects.pod 2009-02-23 21:06:52 UTC (rev 25502)
+++ docs/Perl6/Spec/S12­-objects.pod 2009-02-23 23:33:42 UTC (rev 25503)
@@ -1105,378 +1105,6 @@
A C<proto> declaration may not occur after a C<multi> declaration in the
same scope.

-=head1 Roles
-
-Classes are primarily in charge of object management, and only
-secondarily in charge of software reuse. In Perl6, roles take over
-the job of managing software reuse. Depending on how you care to look
-at it, a role is like a partial class, or an interface with default
-implementation, or a set of generic methods and their associated data,
-or a class closed at compile time.
-
-Roles may be composed into a class at compile time, in which case
-you get automatic detection of conflicting methods. A role may also
-be mixed into a class or object at run time to produce an anonymous
-derived class with extra capabilities, but in this case conflicting
-methods are overridden by the new role silently. In either case,
-a class is necessary for instantiation--a role may not be directly
-instantiated.
-
-A role is declared like a class, but with a C<role> keyword:
-
- role Pet {
- method feed ($food) {
- $food.open_can;
- $food.put_in_bowl;
- self.eat($food);
- }
- }
-
-A role may not inherit from a class, but may be composed of other
-roles. However, this "crony" composition is not evaluated until
-class composition time. This means that if two roles bring in the
-same crony, there's no conflict--it's just as if the class pulled in
-the crony role itself and the respective roles didn't. A role may
-never conflict with itself regardless of its method of incorporation.
-A role that brings in two conflicting crony roles I<may> resolve them
-as if it were a class. This solution is accepted by the class unless
-the class supplies its own solution. If two different roles resolve
-the same crony conflict two different ways, those roles are themselves
-in conflict and must be resolved by a "more derived" role or the class.
-
-A role doesn't know its own type until it is composed into a class.
-Any mention of its main type (such as C<::?CLASS>) is generic, as is
-any reference to C<self> or the type of the invocant. You can use
-a role name as a type, but only for constraints, not for declaring
-actual objects. (However, if you use a role as if it were a class,
-an anonymous class is generated that composes the role, which provides
-a way to force a role to test its crony composition for infelicities.)
-
-A role's main type is generic by default, but you can also parameterize
-other types explicitly using type parameters:
-
- role Pet[::Petfood = TableScraps] {
- method feed (Petfood $food) {...}
- }
-
-(Note that in this case you must not use ::Petfood in the inner declaration,
-or it would rebind the type to type of the actual food parameter.)
-
-If a role merely declares methods without defining them, it degenerates
-to an interface:
-
- role Pet {
- method feed ($food) {...}
- method groom () {...}
- method scratch (:$where) {...}
- }
-
-Note that, while these methods must become available at class
-composition time, they might be supplied by any of: another role,
-the class itself, or some superclass. We know the methods that are
-coming from the other roles or the class, but we don't necessarily know
-the complete set of methods supplied by our super classes if they are
-open or rely on wildcard delegation. However, the class composer is
-allowed to assume that only currently declared superclass methods or
-non-wildcard methods are going to be available. A stub can always
-be installed somewhere to "supply" a missing method's declaration.
-
-Roles may have attributes:
-
- role Pet {
- has $.collar = Collar.new(Tag.new)­;
- method id () { return $.collar.tag }
- method lose_collar () { undefine $.collar }
- }
-
-If you want to parameterize the initial value of a role attribute,
-be sure to put a double semicolon if you don't want the parameter to
-be considered part of the long name:
-
- role Pet[::ID;; $tag] {
- has ID $.collar .= new($tag);
- }
-
-Within a role the C<has> declarator always indicates the declaration
-from the viewpoint of the class. Therefore a private attribute declared
-using C<has> is private to the class, not to the role. You may wish to declare an attribute
-that is hidden even from the class; a completely private role
-attribute may be declared like this:
-
- my $!spleen;
-
-The name of such a private attribute is always considered lexically scoped.
-If a role declares private lexical items, those items are private to
-the role due to the nature of lexical scoping. Accessors to such
-items may be exported to the class, but this is not the default.
-In particular, a role may say
-
- trusts ::?Class;
-
-to allow C<self!attr()> access to the role's C<$!attr> variables with the
-class or from other roles composed into the class. Conflicts between
-private accessors are also caught at composition time, but of course
-need not consider super classes, since no-one outside the current
-class (or a trusted class) can call a private accessor at all.
-(Private accessors are never virtual, and must be package qualified
-if called from a trusted scope other than our own. That is, it's
-either C<self!attr()> or C<$obj!TrustsMe::at­tr().>)
-
-A role may also distinguish a shared method
-
- has method foo ...
- method foo ... # same
-
-from a nonshared private method:
-
- my method !foo ...
- my method foo ... # same, but &foo is aliased to &!foo
-
-Generally you'd just use a lexically scoped sub, though.
-
- my sub foo ...
-
-[Conjectural: To put a private sub into the class, say
-
- our sub !foo ...
-
-]
-
-A role can abstract the decision to delegate:
-
- role Pet {
- has $groomer handles <bathe groom trim> = hire_groomer();
- }
-
-Note that this puts the three methods into the class as well as
-C<$groomer>. In contrast, "C<my $!groomer>" would only put the
-three methods; the attribute itself is private to the role.
-
-A role is allowed to declare an additional inheritance for its class when
-that is considered an implementation detail:
-
- role Pet {
- is Friend;
- }
-
-A class incorporates a role with the verb "does", like this:
-
- class Dog is Mammal does Pet does Sentry {...}
-
-or equivalently, within the body of the class closure:
-
- class Dog {
- is Mammal;
- does Pet;
- does Sentry;
- ...
- }
-
-There is no ordering dependency among the roles.
-
-A class's explicit method definition hides any role definition of
-the same name. A role method in turn hides any methods inherited
-from other classes.
-
-If there are no method name conflicts between roles (or with the
-class), then each role's methods can be installed in the class. If,
-however, two roles try to introduce a method of the same name the
-composition of the class fails. (Two C<has> attributes of the same
-name, whether public or private, are simply merged into one slot,
-provided the types are the same; otherwise, the composition fails.
-Role-private attributes are not merged, and from the viewpoint of
-the composition, don't even exist, except to allocate a slot for each
-such attribute.)
-
-There are several ways to solve method conflicts. The first is simply to
-write a class method that overrides the conflicting role methods, perhaps
-figuring out which role method to call.
-
-Alternately, if the role's methods are declared C<multi>, they can be
-disambiguated based on their long name. If the roles forget to declare
-them as multi, you can force a multi on the roles' methods by installing
-a proto stub in the class being constructed:
-
- proto method shake {...}
-
-(This declaration need not precede the C<does> clause textually, since
-roles are not actually composed until the end of the class definition,
-at which point we know which roles are to be composed together
-in a single logical operation, as well as how the class intends to
-override the roles.)
-
-The proto method will be called if the multi fails:
-
- proto method shake { warn "They couldn't decide" }
-
-Run-time mixins are done with C<does> and C<but>. The C<does> binary
-operator is a mutator that derives a new anonymous class (if necessary)
-and binds the object to it:
-
- $fido does Sentry
-
-The C<does> infix operator is non-associative, so this is a syntax error:
-
- $fido does Sentry does Tricks does TailChasing does Scratch;
-
-You can, however, say
-
- $fido does Sentry;
- $fido does Tricks;
- $fido does TailChasing;
- $fido does Scratch;
-
-And since it returns the left side, you can also say:
-
- ((($fido does Sentry) does Tricks) does TailChasing) does Scratch;
-
-Unlike the compile-time role composition, each of these layers on a new
-mixin with a new level of inheritance, creating a new anonymous class
-for dear old Fido, so that a C<.chase> method from C<TailChasing> hides a
-C<.chase> method from C<Sentry>.
-
-You can also mixin a precomposed set of roles:
-
- $fido does (Sentry, Tricks, TailChasing, Scratch);
-
-This will level the playing field for collisions among the new
-set of roles, and guarantees the creation of no more than one more
-anonymous class. Such a role still can't conflict with itself, but it
-can hide its previous methods in the parent class, and the calculation
-of what conflicts is done again for the set of roles being mixed in.
-If you can't do compile-time composition, we strongly recommend this
-approach for run-time mixins since it approximates a compile-time
-composition at least for the new roles involved.
-
-A role applied with C<does> may be parameterized with an initializer
-in parentheses, but only if the role supplies exactly one attribute
-to the mixin class:
-
- $fido does Wag($tail);
- $line does taint($istainted);
-
-The supplied initializer will be coerced to type of the attribute.
-Note that this initializer is in addition to any parametric type
-supplied in square brackets, which is considered part of the actual
-type name:
-
- $myobj does Array[:of(Int)](@initial)
-
-The C<but> operator creates a copy and works on that. It also knows
-how to generalize a particular enumerated value to its role. So
-
- 0 but True
-
-is short for something like:
-
- 0 but Bool::True
-
-A property is defined by a role like this:
-
- role SomeRole {
- has SomeType $.prop is rw = 1;
- }
-
-You can declare a property with
-
- my int property answer;
-
-and that declares a role whose name is the same as the accessor:
-
- my role answer {
- has int $.answer is rw;
- }
-
-Then you can say
-
- $a = 0 but answer(42)
-
-Note that the parenthesized form is I<not> a subroutine or method call.
-It's just special initializing syntax for roles that contain a single
-property. The above really means something like:
-
- $a = ($anonymous = 0) does answer(42);
-
-which really means:
-
- (($anonymous = 0) does answer).answer = 42;
- $a = $anonymous;
-
-Which is why there's a C<but> operator.
-
-=head1 Traits
-
-Traits are just properties (roles) applied to declared items like
-containers or classes. It's the declaration of the item itself that
-makes traits seem more permanent than ordinary properties. In addition
-to adding the property, a trait can also have side effects.
-
-Traits are generally applied with the "is" keyword, though not always.
-To define a trait handler for an "is xxx" trait, define one or
-more multisubs into a property role like this:
-
- role xxx {
- has Int $.xxx;
- multi trait_auxiliary:is(­xxx $trait, Class $container; $arg?) {...}
- multi trait_auxiliary:is(­xxx $trait, Any $container; $arg?) {...}
- }
-
-Then it can function as a trait. A well-behaved trait handler will say
-
- $container does xxx($arg);
-
-somewhere inside to set the metadata on the container correctly.
-Since a class can function as a role when it comes to parameter type
-matching, you can also say:
-
- class MyBase {
- multi trait_auxiliary:is(­MyBase $base, Class $class; $arg?) {...}
- multi trait_auxiliary:is(­MyBase $tied, Any $container; $arg?) {...}
- }
-
-These capture control if C<MyBase> wants to capture control of how it gets
-used by any class or container. But usually you can just let it call
-the generic defaults:
-
- multi trait_auxiliary:is(­Class $base, Class $class; $arg?) {...}
-
-which adds C<$base> to the "isa" list of C<$class>, or
-
- multi trait_auxiliary:is(­Class $tied, Any $container; $arg?) {...}
-
-which sets the "tie" type of the container to the implementation type
-in C<$tied>.
-
-Most traits are introduced by use of a "helping verb", which could
-be something like "C<is>", or "C<will>", or "C<can>", or "C<might>",
-or "C<should>", or "C<does>". We call these helping verbs "trait
-auxiliaries". Here's "C<will>", which (being syntactic sugar) merely
-delegates to back to "is":
-
- multi sub trait_auxiliary:wil­l($trait, $container; &arg) {
- trait_auxiliary:is(­$trait, $container, &arg);
- }
-
-Other traits are applied with a single word, and we call one of those a
-"trait verb". For instance, the "C<as>" trait
-is defined something like this:
-
- role as {
- has ReturnType $.as;
- multi sub trait_verb:as($cont­ainer; ReturnType $arg) {
- $container does as($arg);
- }
- ...
- }
-
-Unlike compile-time roles, which all flatten out in the same class,
-compile-time traits are applied one at a time, like mixin roles.
-You can, in fact, apply a trait to a container at run time, but
-if you do, it's just an ordinary mixin role. You have to call the
-appropriate C<trait_auxiliary:i­s()> routine yourself if you want it to
-do any extra shenanigans. The compiler won't call it for you at run
-time like it would at compile time.
-
=head1 Delegation

Delegation lets you pretend that some other object's methods are your own.

Added: docs/Perl6/Spec/S14­-roles-and-parametri­c-types.pod
===================­====================­====================­========
--- docs/Perl6/Spec/S14­-roles-and-parametri­c-types.pod (rev 0)
+++ docs/Perl6/Spec/S14­-roles-and-parametri­c-types.pod 2009-02-23 23:33:42 UTC (rev 25503)
@@ -0,0 +1,490 @@
+=encoding utf8
+
+=head1 TITLE
+
+Synopsis 12: Roles and Parametric Types
+
+=head1 AUTHOR
+
+Larry Wall <larry@wall.org>
+
+=head1 VERSION
+
+ Maintainer: Larry Wall <larry@wall.org>
+ Date: 24 Feb 2009, extracted from S12-objects.pod
+ Last Modified: 24 Feb 2009
+ Number: 14
+ Version: 1
+
+=head1 Overview
+
+This synopsis summarizes Apocalypse 14, which discusses roles and parametric types.
+
+=head1 Roles
+
+Classes are primarily in charge of object management, and only
+secondarily in charge of software reuse. In Perl6, roles take over
+the job of managing software reuse. Depending on how you care to look
+at it, a role is like a partial class, or an interface with default
+implementation, or a set of generic methods and their associated data,
+or a class closed at compile time.
+
+Roles may be composed into a class at compile time, in which case
+you get automatic detection of conflicting methods. A role may also
+be mixed into a class or object at run time to produce an anonymous
+derived class with extra capabilities, but in this case conflicting
+methods are overridden by the new role silently. In either case,
+a class is necessary for instantiation--a role may not be directly
+instantiated.
+
+A role is declared like a class, but with a C<role> keyword:
+
+ role Pet {
+ method feed ($food) {
+ $food.open_can;
+ $food.put_in_bowl;
+ self.eat($food);
+ }
+ }
+
+A role may not inherit from a class, but may be composed of other
+roles. However, this "crony" composition is not evaluated until
+class composition time. This means that if two roles bring in the
+same crony, there's no conflict--it's just as if the class pulled in
+the crony role itself and the respective roles didn't. A role may
+never conflict with itself regardless of its method of incorporation.
+A role that brings in two conflicting crony roles I<may> resolve them
+as if it were a class. This solution is accepted by the class unless
+the class supplies its own solution. If two different roles resolve
+the same crony conflict two different ways, those roles are themselves
+in conflict and must be resolved by a "more derived" role or the class.
+
+A role doesn't know its own type until it is composed into a class.
+Any mention of its main type (such as C<::?CLASS>) is generic, as is
+any reference to C<self> or the type of the invocant. You can use
+a role name as a type, but only for constraints, not for declaring
+actual objects. (However, if you use a role as if it were a class,
+an anonymous class is generated that composes the role, which provides
+a way to force a role to test its crony composition for infelicities.)
+
+A role's main type is generic by default, but you can also parameterize
+other types explicitly using type parameters:
+
+ role Pet[::Petfood = TableScraps] {
+ method feed (Petfood $food) {...}
+ }
+
+(Note that in this case you must not use ::Petfood in the inner declaration,
+or it would rebind the type to type of the actual food parameter.)
+
+If a role merely declares methods without defining them, it degenerates
+to an interface:
+
+ role Pet {
+ method feed ($food) {...}
+ method groom () {...}
+ method scratch (:$where) {...}
+ }
+
+Note that, while these methods must become available at class
+composition time, they might be supplied by any of: another role,
+the class itself, or some superclass. We know the methods that are
+coming from the other roles or the class, but we don't necessarily know
+the complete set of methods supplied by our super classes if they are
+open or rely on wildcard delegation. However, the class composer is
+allowed to assume that only currently declared superclass methods or
+non-wildcard methods are going to be available. A stub can always
+be installed somewhere to "supply" a missing method's declaration.
+
+Roles may have attributes:
+
+ role Pet {
+ has $.collar = Collar.new(Tag.new)­;
+ method id () { return $.collar.tag }
+ method lose_collar () { undefine $.collar }
+ }
+
+If you want to parameterize the initial value of a role attribute,
+be sure to put a double semicolon if you don't want the parameter to
+be considered part of the long name:
+
+ role Pet[::ID;; $tag] {
+ has ID $.collar .= new($tag);
+ }
+
+Within a role the C<has> declarator always indicates the declaration
+from the viewpoint of the class. Therefore a private attribute declared
+using C<has> is private to the class, not to the role. You may wish to declare an attribute
+that is hidden even from the class; a completely private role
+attribute may be declared like this:
+
+ my $!spleen;
+
+The name of such a private attribute is always considered lexically scoped.
+If a role declares private lexical items, those items are private to
+the role due to the nature of lexical scoping. Accessors to such
+items may be exported to the class, but this is not the default.
+In particular, a role may say
+
+ trusts ::?Class;
+
+to allow C<self!attr()> access to the role's C<$!attr> variables with the
+class or from other roles composed into the class. Conflicts between
+private accessors are also caught at composition time, but of course
+need not consider super classes, since no-one outside the current
+class (or a trusted class) can call a private accessor at all.
+(Private accessors are never virtual, and must be package qualified
+if called from a trusted scope other than our own. That is, it's
+either C<self!attr()> or C<$obj!TrustsMe::at­tr().>)
+
+A role may also distinguish a shared method
+
+ has method foo ...
+ method foo ... # same
+
+from a nonshared private method:
+
+ my method !foo ...
+ my method foo ... # same, but &foo is aliased to &!foo
+
+Generally you'd just use a lexically scoped sub, though.
+
+ my sub foo ...
+
+[Conjectural: To put a private sub into the class, say
+
+ our sub !foo ...
+
+]
+
+A role can abstract the decision to delegate:
+
+ role Pet {
+ has $groomer handles <bathe groom trim> = hire_groomer();
+ }
+
+Note that this puts the three methods into the class as well as
+C<$groomer>. In contrast, "C<my $!groomer>" would only put the
+three methods; the attribute itself is private to the role.
+
+A role is allowed to declare an additional inheritance for its class when
+that is considered an implementation detail:
+
+ role Pet {
+ is Friend;
+ }
+
+A class incorporates a role with the verb "does", like this:
+
+ class Dog is Mammal does Pet does Sentry {...}
+
+or equivalently, within the body of the class closure:
+
+ class Dog {
+ is Mammal;
+ does Pet;
+ does Sentry;
+ ...
+ }
+
+There is no ordering dependency among the roles.
+
+A class's explicit method definition hides any role definition of
+the same name. A role method in turn hides any methods inherited
+from other classes.
+
+If there are no method name conflicts between roles (or with the
+class), then each role's methods can be installed in the class. If,
+however, two roles try to introduce a method of the same name the
+composition of the class fails. (Two C<has> attributes of the same
+name, whether public or private, are simply merged into one slot,
+provided the types are the same; otherwise, the composition fails.
+Role-private attributes are not merged, and from the viewpoint of
+the composition, don't even exist, except to allocate a slot for each
+such attribute.)
+
+There are several ways to solve method conflicts. The first is simply to
+write a class method that overrides the conflicting role methods, perhaps
+figuring out which role method to call.
+
+Alternately, if the role's methods are declared C<multi>, they can be
+disambiguated based on their long name. If the roles forget to declare
+them as multi, you can force a multi on the roles' methods by installing
+a proto stub in the class being constructed:
+
+ proto method shake {...}
+
+(This declaration need not precede the C<does> clause textually, since
+roles are not actually composed until the end of the class definition,
+at which point we know which roles are to be composed together
+in a single logical operation, as well as how the class intends to
+override the roles.)
+
+The proto method will be called if the multi fails:
+
+ proto method shake { warn "They couldn't decide" }
+
+Run-time mixins are done with C<does> and C<but>. The C<does> binary
+operator is a mutator that derives a new anonymous class (if necessary)
+and binds the object to it:
+
+ $fido does Sentry
+
+The C<does> infix operator is non-associative, so this is a syntax error:
+
+ $fido does Sentry does Tricks does TailChasing does Scratch;
+
+You can, however, say
+
+ $fido does Sentry;
+ $fido does Tricks;
+ $fido does TailChasing;
+ $fido does Scratch;
+
+And since it returns the left side, you can also say:
+
+ ((($fido does Sentry) does Tricks) does TailChasing) does Scratch;
+
+Unlike the compile-time role composition, each of these layers on a new
+mixin with a new level of inheritance, creating a new anonymous class
+for dear old Fido, so that a C<.chase> method from C<TailChasing> hides a
+C<.chase> method from C<Sentry>.
+
+You can also mixin a precomposed set of roles:
+
+ $fido does (Sentry, Tricks, TailChasing, Scratch);
+
+This will level the playing field for collisions among the new
+set of roles, and guarantees the creation of no more than one more
+anonymous class. Such a role still can't conflict with itself, but it
+can hide its previous methods in the parent class, and the calculation
+of what conflicts is done again for the set of roles being mixed in.
+If you can't do compile-time composition, we strongly recommend this
+approach for run-time mixins since it approximates a compile-time
+composition at least for the new roles involved.
+
+A role applied with C<does> may be parameterized with an initializer
+in parentheses, but only if the role supplies exactly one attribute
+to the mixin class:
+
+ $fido does Wag($tail);
+ $line does taint($istainted);
+
+The supplied initializer will be coerced to type of the attribute.
+Note that this initializer is in addition to any parametric type
+supplied in square brackets, which is considered part of the actual
+type name:
+
+ $myobj does Array[:of(Int)](@initial)
+
+The C<but> operator creates a copy and works on that. It also knows
+how to generalize a particular enumerated value to its role. So
+
+ 0 but True
+
+is short for something like:
+
+ 0 but Bool::True
+
+A property is defined by a role like this:
+
+ role SomeRole {
+ has SomeType $.prop is rw = 1;
+ }
+
+You can declare a property with
+
+ my int property answer;
+
+and that declares a role whose name is the same as the accessor:
+
+ my role answer {
+ has int $.answer is rw;
+ }
+
+Then you can say
+
+ $a = 0 but answer(42)
+
+Note that the parenthesized form is I<not> a subroutine or method call.
+It's just special initializing syntax for roles that contain a single
+property. The above really means something like:
+
+ $a = ($anonymous = 0) does answer(42);
+
+which really means:
+
+ (($anonymous = 0) does answer).answer = 42;
+ $a = $anonymous;
+
+Which is why there's a C<but> operator.
+
+=head1 Traits
+
+Traits are just properties (roles) applied to declared items like
+containers or classes. It's the declaration of the item itself that
+makes traits seem more permanent than ordinary properties. In addition
+to adding the property, a trait can also have side effects.
+
+Traits are generally applied with the "is" keyword, though not always.
+To define a trait handler for an "is xxx" trait, define one or
+more multisubs into a property role like this:
+
+ role xxx {
+ has Int $.xxx;
+ multi trait_auxiliary:is(­xxx $trait, Class $container; $arg?) {...}
+ multi trait_auxiliary:is(­xxx $trait, Any $container; $arg?) {...}
+ }
+
+Then it can function as a trait. A well-behaved trait handler will say
+
+ $container does xxx($arg);
+
+somewhere inside to set the metadata on the container correctly.
+Since a class can function as a role when it comes to parameter type
+matching, you can also say:
+
+ class MyBase {
+ multi trait_auxiliary:is(­MyBase $base, Class $class; $arg?) {...}
+ multi trait_auxiliary:is(­MyBase $tied, Any $container; $arg?) {...}
+ }
+
+These capture control if C<MyBase> wants to capture control of how it gets
+used by any class or container. But usually you can just let it call
+the generic defaults:
+
+ multi trait_auxiliary:is(­Class $base, Class $class; $arg?) {...}
+
+which adds C<$base> to the "isa" list of C<$class>, or
+
+ multi trait_auxiliary:is(­Class $tied, Any $container; $arg?) {...}
+
+which sets the "tie" type of the container to the implementation type
+in C<$tied>.
+
+Most traits are introduced by use of a "helping verb", which could
+be something like "C<is>", or "C<will>", or "C<can>", or "C<might>",
+or "C<should>", or "C<does>". We call these helping verbs "trait
+auxiliaries". Here's "C<will>", which (being syntactic sugar) merely
+delegates to back to "is":
+
+ multi sub trait_auxiliary:wil­l($trait, $container; &arg) {
+ trait_auxiliary:is(­$trait, $container, &arg);
+ }
+
+Other traits are applied with a single word, and we call one of those a
+"trait verb". For instance, the "C<as>" trait
+is defined something like this:
+
+ role as {
+ has ReturnType $.as;
+ multi sub trait_verb:as($cont­ainer; ReturnType $arg) {
+ $container does as($arg);
+ }
+ ...
+ }
+
+Unlike compile-time roles, which all flatten out in the same class,
+compile-time traits are applied one at a time, like mixin roles.
+You can, in fact, apply a trait to a container at run time, but
+if you do, it's just an ordinary mixin role. You have to call the
+appropriate C<trait_auxiliary:i­s()> routine yourself if you want it to
+do any extra shenanigans. The compiler won't call it for you at run
+time like it would at compile time.
+
+=head1 Parametric Types
+
+Types can take parameters. Parametric types are named using square brackets, so:
+
+ my Hash of Array of Recipe %book;
+
+actually means:
+
+ my Hash[of => Array[of => Recipe]] %book;
+
+=head2 Parametric Roles
+
+In Perl 6, roles can also take parameters. Roles exist to enable greater re-use of code
+than we could get through having plain old classes, and by allowing them to be
+parameterized we open the door to even more re-use. Taking a simple example, imagine we
+wanted to factor out a "greet" method into a role, which takes somebody's name and greets
+them. We want to parameterize it on the greeting.
+
+role Greet[Str $greeting] {
+ method greet() { say "$greeting!"; }
+}
+class EnglishMan does Greet["Hello"] { }
+class Slovak does Greet["Ahoj"] { }
+class Lolcat does Greet["OH HAI"] { }
+EnglishMan.new.gre­et(); # Hello
+Slovak.new.greet()­; # Ahoj
+Lolcat.new.greet()­; # OH HAI
+
+Similarly, we could do a role for requests.
+
+role Request[Str $statement] {
+ method request($object) { say "$statement $object?"; }
+}
+class EnglishMan does Request["Please can I have a"] { }
+class Slovak does Request["Prosim si"] { }
+class Lolcat does Request["I CAN HAZ"] { }
+EnglishMan.new.req­uest("yorkshire pudding");
+Slovak.new.request­("borovicka");
+Lolcat.new.request­("CHEEZEBURGER");
+
+Sadly, the Slovak output sucks here. Borovicka is the nominative form of the word, and we
+need to decline it into the accusative case. But some languages don't care about that, and
+we don't want to have to make them all supply a transform. Thankfully, you can write many
+roles with the same short name, and a different signature, and multi-dispatch will pick
+the right one for you. So we write something to produce the accusative case in Slovak and
+pass it in. Here's the new code.
+
+role Request[Str $statement] {
+ method request($object) { say "$statement $object?"; }
+}
+role Request[Str $statement, &transform] {
+ method request($object) {
+ say "$statement " ~ transform($object) ~ "?";
+ }
+}
+module Language::Slovak {
+ sub accusative($nom) {
+ # ...and before some smartass points it out, I know
+ # I'm missing some of the masculine animate declension...
+ return $nom.subst(/a$/, 'u');
+ }
+}
+class EnglishMan does Request["Please can I have a"] { }
+class Slovak does Request["Prosim si", &Language::Slovak::accusative] { }
+class Lolcat does Request["I CAN HAZ"] { }
+EnglishMan.new.req­uest("yorkshire pudding");
+Slovak.new.request­("borovicka");
+Lolcat.new.request­("CHEEZEBURGER");
+
+Which means we can now properly order our borovicka in Slovakia, which is awesome. Until
+you do it in a loop and find the Headache['very bad'] role got mixed into yourself
+overnight, anyway...
+
+Role attributes can also be used to initialise attributes:
+
+ role AttrParams[$a, $b] {
+ has $.x = $a;
+ has $.y = $b;
+ }
+
+...and to constrain types.
+
+ role TypeParams[::T] {
+ method x(T $x) { return "got a " ~ T ~ " it was $x" }
+ }
+
+ class IntShower does TypeParams[Int] { } # Shows Ints
+ class StrShower does TypeParams[Str] { } # Shows Strs
+
+ print IntShower.new.x(42)­; # Prints 'got a Int it was 42'
+ print StrShower.new.x("OH­ HAI"); # Prints 'got a Str it was OH HAI'
+ print IntShower.new.x("OH­ HAI"); # Dies
+
+
+
+=for vim:set expandtab sw=4:

Modified: docs/Perl6/Spec/S29­-functions.pod
===================­====================­====================­========
--- docs/Perl6/Spec/S29­-functions.pod 2009-02-23 21:06:52 UTC (rev 25502)
+++ docs/Perl6/Spec/S29­-functions.pod 2009-02-23 23:33:42 UTC (rev 25503)
@@ -684,67 +684,67 @@

=over

-=item all -- see S32-setting-library­/Container.pod
+=item all -- see S32-setting-library­/Containers.pod

-=item any -- see S32-setting-library­/Container.pod
+=item any -- see S32-setting-library­/Containers.pod

-=item cat -- see S32-setting-library­/Container.pod
+=item cat -- see S32-setting-library­/Containers.pod

-=item classify -- see S32-setting-library­/Container.pod
+=item classify -- see S32-setting-library­/Containers.pod

=item defined -- see S32-setting-library­/Scalars.pod

-=item grep -- see S32-setting-library­/Container.pod
+=item grep -- see S32-setting-library­/Containers.pod

-=item first -- see S32-setting-library­/Container.pod
+=item first -- see S32-setting-library­/Containers.pod

-=item keys -- see S32-setting-library­/Container.pod
+=item keys -- see S32-setting-library­/Containers.pod

-=item kv -- see S32-setting-library­/Container.pod
+=item kv -- see S32-setting-library­/Containers.pod

-=item join -- see S32-setting-library­/Container.pod
+=item join -- see S32-setting-library­/Containers.pod

-=item map -- see S32-setting-library­/Container.pod
+=item map -- see S32-setting-library­/Containers.pod

-=item max -- see S32-setting-library­/Container.pod
+=item max -- see S32-setting-library­/Containers.pod

-=item min -- see S32-setting-library­/Container.pod
+=item min -- see S32-setting-library­/Containers.pod

-=item none -- see S32-setting-library­/Container.pod
+=item none -- see S32-setting-library­/Containers.pod

-=item one -- see S32-setting-library­/Container.pod
+=item one -- see S32-setting-library­/Containers.pod

-=item pairs -- see S32-setting-library­/Container.pod
+=item pairs -- see S32-setting-library­/Containers.pod

=item print -- see S32-setting-library­/IO.pod

=item printf -- see S32-setting-library­/IO.pod

-=item roundrobin -- see S32-setting-library­/Container.pod
+=item roundrobin -- see S32-setting-library­/Containers.pod

-=item pick -- see S32-setting-library­/Container.pod
+=item pick -- see S32-setting-library­/Containers.pod

-=item reduce -- see S32-setting-library­/Container.pod
+=item reduce -- see S32-setting-library­/Containers.pod

-=item reverse -- see S32-setting-library­/Container.pod
+=item reverse -- see S32-setting-library­/Containers.pod

=item say -- see S32-setting-library­/IO.pod

-=item shape -- see S32-setting-library­/Container.pod
+=item shape -- see S32-setting-library­/Containers.pod

-=item sort -- see S32-setting-library­/Container.pod
+=item sort -- see S32-setting-library­/Containers.pod

-=item srand -- see S32-setting-library­/Container.pod
+=item srand -- see S32-setting-library­/Numeric.pod

=item undefine -- see S32-setting-library­/Scalar.pod

=item uri -- see S32-setting-library­/IO.pod

-=item values -- see S32-setting-library­/Container.pod
+=item values -- see S32-setting-library­/Containers.pod

=item warn -- see S32-setting-library­/Any.pod

-=item zip -- see S32-setting-library­/Container.pod
+=item zip -- see S32-setting-library­/Containers.pod

=back


Add comment
Monday, 23 February 2009
r25501 - docs/Perl6/Spec/S32­-setting-library Guest 22:28:24
 Author: bacek
Date: 2009-02-23 21:21:32 +0100 (Mon, 23 Feb 2009)
New Revision: 25501

Modified:
docs/Perl6/Spec/S32­-setting-library/Con­tainers.pod
Log:
[spec] Fix typo in map example.

Modified: docs/Perl6/Spec/S32­-setting-library/Con­tainers.pod
===================­====================­====================­========
--- docs/Perl6/Spec/S32­-setting-library/Con­tainers.pod 2009-02-23 17:49:28 UTC (rev 25500)
+++ docs/Perl6/Spec/S32­-setting-library/Con­tainers.pod 2009-02-23 20:21:32 UTC (rev 25501)
@@ -371,7 +371,7 @@

Here is an example of its use:

- @addresses = map { %addresses_by_name<­$_> }, @names;
+ @addresses = map { %addresses_by_name{­$_} }, @names;

Here we take an array of names, and look each name up in
C<%addresses_by_nam­e> in order to build the corresponding

Add comment
r25500 - docs/Perl6/Spec/S32­-setting-library Guest 20:49:28
 Author: autarch
Date: 2009-02-23 18:49:28 +0100 (Mon, 23 Feb 2009)
New Revision: 25500

Modified:
docs/Perl6/Spec/S32­-setting-library/Tem­poral.pod
Log:
Some fixes to make this valid Perl 6 (returns is out, our RETTYPE is in)

Also some other formatting fixlets


Modified: docs/Perl6/Spec/S32­-setting-library/Tem­poral.pod
===================­====================­====================­========
--- docs/Perl6/Spec/S32­-setting-library/Tem­poral.pod 2009-02-23 09:32:46 UTC (rev 25499)
+++ docs/Perl6/Spec/S32­-setting-library/Tem­poral.pod 2009-02-23 17:49:28 UTC (rev 25500)
@@ -78,15 +78,16 @@

# This can be cached internally, but it's a calculated value,
# not an attribute.
- method day-of-week () returns DayOfWeek;
+ our DayOfWeek method day-of-week ();

# These always return the long English names
- method month-name () returns Str; # "January"
- method day-name () returns Str; # "Tuesday"
+ our Str method month-name () ; # "January"
+ our Str method day-name (); # "Tuesday"

# returns the date formatted in ISO8601 style - 2008-01-25
- method iso8601 () returns Str
- { [ self.year, self.month, self.date ].join('-') };
+ our Str method iso8601 () {
+ [ self.year, self.month, self.date ].join('-');
+ }

method Str { self.iso8601 };

@@ -117,7 +118,7 @@
has Minute $.minute = 0;
has Second $.second = 0;

- method iso8601 () returns Str
+ our Str method iso8601 ()
{ [ self.hour, self.minute, self.second ].join(':') }

method Str { self.iso8601() };
@@ -143,7 +144,7 @@
# The ISO8601 standard does not allow for offsets with
# sub-minute resolutions. In real-world practice, this is not
# an issue.
- method iso8601 returns Str {
+ our Str method iso8601 {
my $hours = self.offset.abs / 3600;
my $minutes = self.offset.abs % 3600;

@@ -171,14 +172,15 @@
has Temporal::Time $!time handles <hour minute second fractional-second>;­
has Temporal::TimeZone:­:Observance $!timezone handles <offset isdst>;

- method iso8601 () returns Str
- { self.date.is8601 ~ 'T' ~ self.time.iso8601 ~ self.timezone.iso86­01 }
+ our Str method iso8601 () {
+ self.date.is8601 ~ 'T' ~ self.time.iso8601 ~ self.timezone.iso86­01;
+ }

method Str { self.iso8601 }

# This involves a whole bunch of code - see Perl 5's
# Time::Local
- method epoch returns Num { ... }
+ our Num method epoch { ... }

method Int { self.epoch.truncate­ }


Add comment
possible bug in DBI with DBD::Oracle Karl Forner 17:00:58
 I'm experiencing a very strange problem : in short, I could not reconnect
to a DB using DBI once I successfully connected then failed (with bad
password for example), IN THAT ORDER.

I made a script reproducing the bug:
=================
#!/usr/bin/env perl
use strict;
use warnings;
use DBI;

my $dsn = 'dbi:Oracle:sid=TIT­I;host=xxx.yyy.zzz.c­om;port=1521';
my $user = 'toto';
my $password = $user;
my $options = { AutoCommit => 0 };
my @goodinfo = ($dsn, $user, $password, $options);
my @badinfo = ($dsn, $user, '', $options);

test(@goodinfo);
test(@badinfo);
test(@goodinfo);
test(@goodinfo);

sub test {
my $dbh;
eval { $dbh = DBI->connect(@_) };
warn "$@\n" if $@;
print $dbh ? "Ok" : "NOK";
print "\n";
}

========

so I expect to get "OK NOK OK OK".
But on one computer I get "OK NOK NOK NOK", and on another I get the
expected stuff (using the same database)

But if I do
test(@badinfo);
test(@goodinfo);
test(@goodinfo);

I get "NOK OK OK" on both !!!!!!!

Is this a bug ??

Thanks
Karl Forner

P.S

Here are the configs :

working computer:
arch: ia64
OS: Suse ES 9
perl -v : v5.8.6
DBI: 1.607
DBD::Oracle: 1.16

buggy computer:
arch: i686
OS : ubuntu 8.04
perl -v : v5.8.8
DBI: 1.601
DBD::Oracle: 1.22
comment 8 answers | Add comment
Email Purge Duplicates Guest 12:41:45
 I have a routine that is intended to purge duplicates from a list of
emails. It's currently not working. I've spent some time trying to
make it work, but to no avail. Below is the code. If you have any
suggestions, they would be appreciated. I remember seeing something
like...
foreach $email(@emails)@ema­ils2)){
which is probably what I want.
sub purge
{
open (LIST, "$list") or error("$list purge email ");
while (my $line = <LIST>) {
@emails = split(/\r?\n|\r/, $line);
$emails2 = @emails;
}
close (LIST);

foreach $email(@emails){
if($email ne $email2){
$newemail .="$email\n";
}
}

open (LIST, ">>$list") or error("$list purge email2");
flock(LIST, LOCK_EX);
print LIST $newemail;
close (LIST);
&success("$list has been purged of duplicates");
}

comment 1 answer | Add comment
Two questions; one about adding roles to classes, the other about trees. Timothy S. Nelson 11:54:07
 Adding roles to classes question:

Another question for everyone - is there some way I can extend a class
in such a way that it implements another role? For example, say I have a
class Class::A that implements role Role::A, and I want it to also implement
Role::B (and I provide an implementation), is there any way I can make it so
that *every* instance of Class::A implements Role::B, while doing this from a
module that doesn't contain Role::B?

To put the same question slightly differently, would it be possible to
say "use B_Rollers" (asssuming B_Rollers contains Role::B), and have Role::B
attached to Class::A (which is defined elsewhere, eg. in the
S32-setting-library­?)

Trees question:
I have a question for ruoso in light of the following IRC exchange:

<ruoso> what I had in mind is an old project (2007) of a tree-transforming
language
actually, at first a tree-matching language
<masak> that sounds very interesting... for a CPAN module.
<ruoso> yes... sure... but I was wondering if a Tree role wouldn't be a
fundamental piece for that to be possible
but I've already realised it isn't

My related question is, when you say you've "realised it isn't", what
did you mean? I'm presuming you realised some alternative way of doing
things, and I'm keen to know what that is.

Thanks all,

:)­


-------------------­--------------------­--------------------­----------
| Name: Tim Nelson | Because the Creator is, |
| E-mail: wayland@wayland.id.­au | I am |
-------------------­--------------------­--------------------­----------

----BEGIN GEEK CODE BLOCK----
Version 3.12
GCS d+++ s+: a- C++$ U+++$ P+++$ L+++ E- W+ N+ w--- V-
PE(+) Y+>++ PGP->+++ R(+) !tv b++ DI++++ D G+ e++>++++ h! y-
-----END GEEK CODE BLOCK-----

comment 3 answer | Add comment
r25496 - docs/Perl6/Spec/S32­-setting-library Guest 11:52:44
 Author: wayland
Date: 2009-02-23 09:52:44 +0100 (Mon, 23 Feb 2009)
New Revision: 25496

Modified:
docs/Perl6/Spec/S32­-setting-library/IO.­pod
Log:
Fixed a few things based on advice from chrisdolan++


Modified: docs/Perl6/Spec/S32­-setting-library/IO.­pod
===================­====================­====================­========
--- docs/Perl6/Spec/S32­-setting-library/IO.­pod 2009-02-23 08:42:50 UTC (rev 25495)
+++ docs/Perl6/Spec/S32­-setting-library/IO.­pod 2009-02-23 08:52:44 UTC (rev 25496)
@@ -100,7 +100,7 @@
role IO::Readable {
has $.isReadable;

- method Int read($buf is rw, Int $length)
+ method Int read($buf is rw, Int $bytes)
}

When the $.isReadable is set, it tries to change the readability of the filehandle. This
@@ -109,9 +109,9 @@

=over

-=item method Int read($buf is rw, Int $length)
+=item method Int read($buf is rw, Int $bytes)

-Tries to read $length bytes and store in $buf. The contents of $buf
+Tries to read $bytes bytes and store in $buf. The contents of $buf
are replaced and the actual number of bytes read is returned. A return
of 0 means end of file. It might return unthrown failures, to be
specified by each IO implementation.
@@ -130,7 +130,7 @@
role IO::Writeable {
has $.isWriteable;

- method Int write($buf, Int $length)
+ method Int write($buf, Int $bytes)
}

When the $.isWriteable is set, it tries to change the writeability of the filehandle.
@@ -139,9 +139,9 @@

=over

-=item method Int write($buf, Int $length)
+=item method Int write($buf, Int $bytes)

-Tries to write $length bytes of $buf. The actual number of bytes
+Tries to write $bytes bytes of $buf. The actual number of bytes
written is returned. It might return unthrown failures, to be
specified by each IO implementation.

@@ -158,6 +158,9 @@

=item method Bool eoi()

+EOI = End Of Input -- equivalent to End Of File, but applies to other kinds of sockets as
+well.
+
Returns true if it's the end of the input (ie. end of file or whatever), returns false if
not, returns undef if we can't say for certain.

@@ -196,6 +199,15 @@

=over

+=item new()
+
+ method IO::Streamable new(
+ Bool :$­NoOpen,
+ );
+
+Unless the NoOpen option is passed, an open will be done on the IO object when it is
+created.
+
=item method Bool blocking() is rw

This allows the user to control wether this object should do a
@@ -260,9 +272,9 @@
$.input_record_sepa­rator it consumes the record separator, but returns
undef. If $.input_escape is set, it should pay attention to that.

-=item method Str getc(Int $length? = 1)
+=item method Str getc(Int $char? = 1)

-Reads the next $length character in the set $.encoding according to
+Reads the next $char character in the set $.encoding according to
the $.locale, or the undefined value at end of file, or if there was
an error (in the latter case C<$!> is set).

@@ -451,11 +463,14 @@
:$­fd
Bool :$­NoOpen,
:$­Writeable,
+ :$­Readable
);

The FSNode, Filename and fd options are mutually exclusive. If "use portable" is in
effect, the Filename option throws an error; use an FSNode instead.

+NoOpen is passed to IO::Streamable.new(­)
+
Examples:

# Read -- throws errors with 'use portable'
@@ -789,7 +804,7 @@
Bool :$­NoOpen
);

-The creation of the object will also open the connection, unless NoOpen is specified.
+The NoOpen option is passed to IO::Streamable.new(­)

=item open

@@ -799,11 +814,11 @@

It's intended for the case where the creation of the object didn't do one.

-=item method Int read($buf is rw, Int $length)
+=item method Int read($buf is rw, Int $bytes)

Does a recv().

-=item method Int write($buf, Int $length)
+=item method Int write($buf, Int $bytes)

Does a send().


Add comment
Sigils in Classes after initial "has" Peter Schwenn 11:45:50
 If a class attribute declaration has a . or ! twigil, e.g. has @!items, do
all the ensuing references to @items in the class's methods have to include
the twigil or can the variable be written thereafter simply @items without
the twigil?
Thank you, Peter Schwenn
comment 1 answer | Add comment
r25495 - docs/Perl6/Spec Guest 11:42:51
 Author: wayland
Date: 2009-02-23 09:42:50 +0100 (Mon, 23 Feb 2009)
New Revision: 25495

Modified:
docs/Perl6/Spec/S16­-io.pod
docs/Perl6/Spec/S28­-special-variables.p­od
Log:
More S28 updates, including turning things into references to elsewhere, and better
documenting the standard/default IO handles.


Modified: docs/Perl6/Spec/S16­-io.pod
===================­====================­====================­========
--- docs/Perl6/Spec/S16­-io.pod 2009-02-23 08:31:29 UTC (rev 25494)
+++ docs/Perl6/Spec/S16­-io.pod 2009-02-23 08:42:50 UTC (rev 25495)
@@ -28,8 +28,9 @@

In Perl 6, there are the I<standard> handles, and the I<default> handles.

-The I<standard> ones are our old familiar friends (with new names). Standard input is
-C<$*IN>, standard output is C<$*OUT>, and standard error is C<$*ERR>.
+The I<standard> ones are our old familiar friends (with new names). Standard input
+changed from STDIN to C<$*IN>, standard output changed from STDOUT to C<$*OUT>, and
+standard error changed from STDERR to C<$*ERR>.

However, the I<default> ones replace the single handle set by the Perl 5 select() call
with with three new variables.

Modified: docs/Perl6/Spec/S28­-special-variables.p­od
===================­====================­====================­========
--- docs/Perl6/Spec/S28­-special-variables.p­od 2009-02-23 08:31:29 UTC (rev 25494)
+++ docs/Perl6/Spec/S28­-special-variables.p­od 2009-02-23 08:42:50 UTC (rev 25495)
@@ -1,4 +1,4 @@
-=head1 NAME
+=head1 Name

[DRAFT] Synopsis 28 - Special Variables [DRAFT]

@@ -11,7 +11,7 @@
Last Modified: 23 Feb 2009
Version: 1

-=head1 INTRODUCTION
+=head1 Introduction

This document serves as a collection point
for what is known about special variables
@@ -26,7 +26,7 @@
Most/All variables of the form $*SOMETHING should also work in the form
$SOMETHING (without the '*') unless masked by "my $SOMETHING".

-=head1 DESCRIPTION
+=head1 Overview

=head2 Secondary Sigils (also known as "twigils"):

@@ -42,7 +42,7 @@

=head2 Named variables (see S02):

- $/ # match object from last rule
+ $/ # match object from last rule (see S05)
$0 # first captured value from match: $/.[0]
@*ARGS # command-line arguments
&?BLOCK # current block (itself, see S06)
@@ -59,14 +59,14 @@
$*DEFERR # Default error file handle (see S16)
$*EGID # effective group id
%*ENV # system environment
- $*ERR # standard error handle (but you likely want $*DEFERR)
+ $*ERR # standard error handle (see S16)
$*EUID # effective user id
$*EXECUTABLE_NAME # executable name
$?FILE # current file
$?GRAMMAR # current grammar
@?GRAMMAR # current grammars
$*GID # group id
- $*IN # standard input handle (but you likely want $*DEFIN)
+ $*IN # standard input handle (see S16)
$?LABEL # label of current block
@?LABEL # labels of current blocks
$?LINE # current line
@@ -76,7 +76,7 @@
$*OS # operating system running under
$?OSVER # operating system version compiled for
$*OSVER # operating system version running under
- $*OUT # standard output handle (but you likely want $*DEFOUT)
+ $*OUT # standard output handle (see S16)
$?PACKAGE # current package (as object)
@?PACKAGE # current packages
$?PACKAGENAME # name of current package (see S10)
@@ -100,79 +100,22 @@
"ENV" is probably to overloaded to mean the hash of environment variables
(which would be found under $*ENV.environment or some-such).

+=head1 Special Variables

-XXX Everything below this line is older than everything above it. XXX
+This section only lists variables that don't have a "See S16" or suchlike next to them in
+the overview above.

-=head1 NAME
+XXX Some of the information here is either old, or needs to be moved elsewhere. XXX

- [DRAFT] Synopsis 28 - Special Variables [DRAFT]
-
-=head1 OUTLINE
-
- DRAFT NOTES
- INTRODUCTION
- SPECIAL VARIABLES
- PERL 6 / PERL 5 COMPARISON
- HISTORY
- SOURCES
-
-=head1 DRAFT NOTES
-
-As of 2007-03-13:
-
-There is a more recent document at docs/Perl6/Overview­/Variable.pod
-which contains the bare bones of the next
-iteration of work on special variables in Perl 6.
-
-While the list there appears to be more complete, there remains information
-here that may still be of help in roughing in more details there.
-
-=head1 SPECIAL VARIABLES
-
=over 8

-=item $*IN
-
-=item $*OUT
-
-=item $*ERR
-
-Predefined filehandles for STDIN, STDOUT, and STDERR.
-
-=over 4
-
-=item p5:
-
-Replace STDIN, STDOUT, and STDERR.
-
-=back
-
-=back
-
-=over 8
-
-=item $_
-
-The default input and pattern-searching space.
-Same as in Perl 5 but lexically scoped
-
-=over 4
-
-=item p5:
-
-$_ but more lexically aware.
-
-=back
-
-=back
-
-=over 8
-
=item $a, $b, $c ...

Parameters of the current closure (block
or subroutine) by position in the invocation.

+XXX This needs to go under "Closures". XXX
+
=over 4

=item p5:
@@ -185,24 +128,6 @@

=over 8

-=item $/
-
-Object containing the results of the last regular expression match.
-All match result info found in the contained data structure.
-This is available as the current state of the match in progress.
-
-=over 4
-
-=item p5:
-
-No direct parallel.
-
-=back
-
-=back
-
-=over 8
-
=item $0,$1,$2...

Objects containing information on any subpatterns
@@ -383,13 +308,13 @@

Perl 5 Perl 6 Comment
----------- ----------- -------------------­----
- STDIN $*IN
+ STDIN $*IN See S16

- STDOUT $*OUT
+ STDOUT $*OUT See S16

- STDERR $*ERR
+ STDERR $*ERR See S16

- $_ $_
+ $_ $_ More lexically aware

$_[1],$_[2].. $^a,$^b..

@@ -578,13 +503,16 @@
&*ON_PARSEERROR
- $^S $EXCEPTIONS_BEING_C­AUGHT

-=head1 HISTORY

- 2007-03-13 dvergin Reference to docs/Perl6/Overview­/Variable.pod
- 2005-04-11 dvergin Filling in more pieces
- 2005-04-10 dvergin Roughed in main table
- 2005-04-02 anonpugster Placeholder file containing Larry's email
+XXX Everything below this line is older than everything above it. XXX

+=head1 OUTLINE
+
+ SPECIAL VARIABLES
+ PERL 6 / PERL 5 COMPARISON
+ HISTORY
+ SOURCES
+
=head1 SOURCES

At its present stage of development this file

Add comment
$*DEFOUT vs. $*OUT Chris Dolan 08:22:21
 Smack me down if this has already been discussed to death, please...

S16 (and now S28) say that $*DEFOUT, $*DEFIN and $*DEFERR are what
most programs should use instead of $*OUT, $*IN and $*ERR. That
seems anti-huffman to me, and I'll bet many programmers will use
$*OUT when they should be using $*DEFOUT because the former is
shorter and more obvious.

Perhaps instead the default handles should be $*OUT, $*IN and $*ERR
while the standard handles should be $*STDOUT, $*STDIN and $*STDERR?

Chris

comment 1 answer | Add comment
Temporal changes (was: Re: r25445 - docs/Perl6/Spec/S32­-setting-library) Timothy S. Nelson 07:01:15
 On Thu, 19 Feb 2009, pugs-commits@feathe­r.perl6.nl wrote:

Author: autarch
Date: 2009-02-19 19:14:48 +0100 (Thu, 19 Feb 2009)
New Revision: 25445
Modified:
docs/Perl6/Spec/S32­-setting-library/Tem­poral.pod
Log:
This is a very drastic revision (hopefully this won't turn into a revert war ;)

I hope not. My plan is to argue about them on the mailing list, and
hope that we'll come to some reasonable consensus :)­.

I'd also like to say a mea culpa -- I had a commit ready to go before
I asked Dave/autarch to make the appropriate changes, but I forgot to commit
it :)­. So some of the stupid things are things I should've done myself.

I've noticed that a number of my objections were scattered various
places throughout my reply, so I'm taking the liberty of grouping a few things
together by argument :)­.

Formatters
==========

removed all references to ...
[snip]
Format specifiers - this could come from locales (CLDR specifies this)
or strftime, but again, it's more complicated than is needed
[snip]
Added iso8601 output for every role, and made that the
stringification. ISO8601 is unambiguous world-wide, easy to read, and
easy to output.

I'm quite keen to have something here as a formatter. I was hoping
for CLDR, but I'd be happy with even a subset of CLDR that does what we want.
Or even, failing that, with the ISO8601 part being implemented as a formatter.

+ # These always return the long English names
+ method month-name () returns Str; # "January"
+ method day-name () returns Str; # "Tuesday"

This is one reason I was wanting a formatter -- then we wouldn't need
all these functions. People could just go $time.format('MMMM'­) and get what
they want. Like I said though, the core might be better off with a subset of
CLDR that does month name, day name, and the ISO8601 stringification.

+ # returns the date formatted in ISO8601 style - 2008-01-25
+ method iso8601 () returns Str
+ { [ self.year, self.month, self.date ].join('-') };

I was hoping we could leave this also to a formatter that would be
called upon by infix:{'~'}.


DateTime math
=============

removed all references to ...
[snip]
Any sort of date or time math
[snip]
Got rid of all mutating operators on everything. The built-ins should
be immutable for simplicity.

Date/time math was something else I'm also very keen to have. The
other built-ins play happily with operators -- why wouldn't the temporal ones?
By "mutating operators", do you mean "multi operators"? If so, I urge you to:
- Read my comments lower down in this e-mail about the infix:<~>
operator, which will give you some appropriate background
- See http://perlcabal.or­g/syn/S03.html#Smart­_matching which appears to
me to make the ~~ operator do all kinds of things (although I could be
wrong here). Actually, the point I'm making is much more easily seen
by finding "=head1 Smart matching" in
http://svn.pugscode­.org/pugs/docs/Perl6­/Spec/S03-operators.­pod

Other things
============

Here's the changes in summary:
removed all references to ...
Locales, including eras, which come from a locale - this is a vast and complicated domain
Alternate calendars - also vast and complicated
String parsing of any sort - ditto, see the pattern here? ;)
Comparing dates or times to durations - this just doesn't make
sense. Is 2009-02-23 greater or less than 5 days?

I agree, this was stupid :)­.

Renamed Temporal::Instant to Temporal::DateTime

Hmm. We had some mailing list discussion about this, and agreed on
Instant. I'd like to see your reasons in favour of DateTime.

One of my (unmentioned) reasons for not calling it DateTime is that I
was expecting the CPAN module to be called DateTime, and didn't want to stamp
on any names. But that's not as high a priority.

Got rid of Temporal::Subsecond­ and just made Temporal::Time allow for
sub-second resolutions. Not sure if this is best done with an
$.attosecond attribute or as a decimal number.

See other discussions on the mailing list.

Renamed Temporal::Timezone to Temporal::TimeZone:­:Observance. The
latter is a simple thing which represents the offset, isdst flag, and
short name for a given local time. This information should be
available on all supported platforms. TimeZones themselves are
complicated and very much platform-dependent.­ Better to leave this as
a separate CPAN6 distro.

Bewdy mate! :)­ [to translate that into non-Australian, it's
"Beauty, mate", or "I'm pleased, friend"].

Added numification overloading for Temporal::DateTime,­ which gives us
comparison for free.

Cool :)­.

In case I didn't say this elsewhere, I'd be happy to see localtime and
gmtime disappear in favour of other temporal constructors. And surely time()
could be merged in as well?

+ method infix:{'~'} return Str { self.iso8601 };

Also, while I may be wrong, my reading of S13 says that operator
overloading is not attached to an object (although maybe it's allowed to be
defined in it. That means that instead of

method infix:{'~'} return Str { self.iso8601 };

...you'd need to write one of:

Temporal::Date multi sub infix:{'~'}(Tempora­l::Date $self, Temporal::Date $other)
multi sub infix:{'~'}(Tempora­l::Date $self, Temporal::Date $other --> Temporal::Date)

Note also that I've been quite sloppy in not declaring return values
on a lot of these functions; if you'd like to fix that, feel free. Oh, and it
may also be that the first of those above should have the multi before the
Temporal::Date.

+role Temporal::DateTime {
+ has Temporal::Date $!date handles <year month day day-of-week>;

Can't do this, I think; this would require an instance of
Temporal::Date, which is a role and can't be instantiated. That's why I was
using "does" instead. I don't know what the alternative is, but I'll leave
that to you :)­.

+ has Temporal::Time $!time handles <hour minute second fractional-second>;­
+ has Temporal::TimeZone:­:Observance $!timezone handles <offset isdst>;

Ditto :)­.

HTH,


-------------------­--------------------­--------------------­----------
| Name: Tim Nelson | Because the Creator is, |
| E-mail: wayland@wayland.id.­au | I am |
-------------------­--------------------­--------------------­----------

----BEGIN GEEK CODE BLOCK----
Version 3.12
GCS d+++ s+: a- C++$ U+++$ P+++$ L+++ E- W+ N+ w--- V-
PE(+) Y+>++ PGP->+++ R(+) !tv b++ DI++++ D G+ e++>++++ h! y-
-----END GEEK CODE BLOCK-----

comment 6 answers | Add comment
r25489 - docs/Perl6/Spec/S32­-setting-library Guest 06:29:57
 Author: wayland
Date: 2009-02-23 04:29:57 +0100 (Mon, 23 Feb 2009)
New Revision: 25489

Modified:
docs/Perl6/Spec/S32­-setting-library/IO.­pod
Log:
Did some updates, and added a uri() method


Modified: docs/Perl6/Spec/S32­-setting-library/IO.­pod
===================­====================­====================­========
--- docs/Perl6/Spec/S32­-setting-library/IO.­pod 2009-02-23 03:07:23 UTC (rev 25488)
+++ docs/Perl6/Spec/S32­-setting-library/IO.­pod 2009-02-23 03:29:57 UTC (rev 25489)
@@ -33,7 +33,7 @@

our Bool method getc (IO $self: *@LIST)

-See C<Synopsis 16: IPC / IO / Signals> for details.
+See below for details.

=item print

@@ -41,7 +41,7 @@
our Bool multi print (*@LIST)
our Bool method print (Str $self: IO $io)

-See C<Synopsis 16: IPC / IO / Signals> for details.
+See below for details.

=item say

@@ -49,14 +49,14 @@
our Bool multi say (*@LIST)
our Bool method say (Str $self: IO $io)

-See C<Synopsis 16: IPC / IO / Signals> for details.
+See below for details.

=item printf

our Bool method printf (IO $self: Str $fmt, *@LIST)
our Bool multi printf (Str $fmt, *@LIST)

-See C<Synopsis 16: IPC / IO / Signals> for details.
+See below for details.

=item uri

@@ -202,6 +202,15 @@
blocking wait or immediatly return in the case of not having data
available.

+=item uri
+
+ method IO::Streamable uri(Str $uri) {...}
+
+This should be callable on the class, and act like a kind of "new()" function. When given
+a URI, it returns an IO::Streamable of the appropriate type, and throws an error when an
+inappropriate type is passed in. For example, calling IO::File.uri('http:­//....') will
+throw an error (but will suggest using just uri('http://...') instead).
+
=back

=head2 IO::Encoded

Add comment
S16 and S19 Timothy S. Nelson 06:21:34
 Just a note for the people working on S19. Large chunks of the IO
stuff will now be documented in S32-setting-library­/IO.pod, so you might want
to update your references to S16 to point there.

Just for any who haven't grasped the distinction, the IO stuff is in 3
places:

- S32-setting-library­/IO.pod documents classes and roles
- S29 documents functions that are exported by default (is this correct
Perl6 talk?
- S16 documents everything else, ie. default filehandles, but other
things may be added.

HTH,


-------------------­--------------------­--------------------­----------
| Name: Tim Nelson | Because the Creator is, |
| E-mail: wayland@wayland.id.­au | I am |
-------------------­--------------------­--------------------­----------

----BEGIN GEEK CODE BLOCK----
Version 3.12
GCS d+++ s+: a- C++$ U+++$ P+++$ L+++ E- W+ N+ w--- V-
PE(+) Y+>++ PGP->+++ R(+) !tv b++ DI++++ D G+ e++>++++ h! y-
-----END GEEK CODE BLOCK-----

Add comment
r25488 - in docs/Perl6/Spec: . S32-setting-library Guest 06:07:24
 Author: wayland
Date: 2009-02-23 04:07:23 +0100 (Mon, 23 Feb 2009)
New Revision: 25488

Modified:
docs/Perl6/Spec/S16­-io.pod
docs/Perl6/Spec/S32­-setting-library/IO.­pod
Log:
Moved stuff from S16-io to S32-setting-library­/IO


Modified: docs/Perl6/Spec/S16­-io.pod
===================­====================­====================­========
--- docs/Perl6/Spec/S16­-io.pod 2009-02-23 02:21:44 UTC (rev 25487)
+++ docs/Perl6/Spec/S16­-io.pod 2009-02-23 03:07:23 UTC (rev 25488)
@@ -40,946 +40,6 @@
Many of the roles and functions below will operate on the default handles. To set all 3
at once, do C<($*DEFIN, $*DEFOUT, $*DEFERR) ::= ($*IN, $*OUT, $*ERR)>.

-=head1 Roles
-
-The functionality of IO objects is broken down into several roles,
-which should identify the features each object supports.
-
-=head2 IO
-
-The base role only tags that this is an IO object for more generic
-purposes. It doesn't specify any methods or attributes.
-
-=head2 IO::Readable
-
-This role provides unbuffered read access to the data stream.
-
-role IO::Readable {
- has $.isReadable;
-
- method Int read($buf is rw, Int $length)
-}
-
-When the $.isReadable is set, it tries to change the readability of the filehandle. This
-is not always possible, but can be done in a number of cases. IO::Socket can remove
-readability by calling shutdown(), for example.
-
-=over
-
-=item method Int read($buf is rw, Int $length)
-
-Tries to read $length bytes and store in $buf. The contents of $buf
-are replaced and the actual number of bytes read is returned. A return
-of 0 means end of file. It might return unthrown failures, to be
-specified by each IO implementation.
-
-It is important to realize that this is "raw" read. You're going to
-have plain octets stored in $buf, if this is actually encoded data,
-you're going to need to encode it later, or use "getc" or other
-IO::Readable::Enco­ded methods.
-
-=back
-
-=head2 IO::Writeable
-
-This role provides unbuffered write access to the data stream.
-
-role IO::Writeable {
- has $.isWriteable;
-
- method Int write($buf, Int $length)
-}
-
-When the $.isWriteable is set, it tries to change the writeability of the filehandle.
-This is not always possible, but can be done in a number of cases. IO::Socket can remove
-writeability by calling shutdown(), for example.
-
-=over
-
-=item method Int write($buf, Int $length)
-
-Tries to write $length bytes of $buf. The actual number of bytes
-written is returned. It might return unthrown failures, to be
-specified by each IO implementation.
-
-It is important to realize that this is "raw" write. $buf should
-contain plain octets that are going to be sent. If $buf contains
-encoded data, you should decode it first, or use "print" or other
-IO::Writeable::Enc­oded methods.
-
-=back
-
-=head2 IO::Seekable
-
-=over
-
-=item method Bool eoi()
-
-Returns true if it's the end of the input (ie. end of file or whatever), returns false if
-not, returns undef if we can't say for certain.
-
-=item method Bool seek(Int $position)
-
-Position this stream into $position. The meaning of this position is
-always in "octets".
-
-=item method Int tell()
-
-Returns the current raw position in the stream in number of "octets".
-
-=back
-
-=head2 IO::Buffered
-
-Indicates that this object performs buffering. The management of the
-buffer is completely implementation specific.
-
-=over
-
-=item method Bool flush()
-
-Flushes the buffers associated with this object.
-
-=item method Bool autoflush() is rw
-
-Forces this object to keep its buffers empty
-
-=back
-
-=head2 IO::Streamable
-
-This role represents objects that depend on some external resource,
-which means that data might not be available at request.
-
-=over
-
-=item method Bool blocking() is rw
-
-This allows the user to control wether this object should do a
-blocking wait or immediatly return in the case of not having data
-available.
-
-=back
-
-=head2 IO::Encoded
-
-This is a generic role for encoded data streams.
-
-=over
-
-=item method Str encoding() is rw
-
-=item method Str locale() is rw
-
-Encoding and locale are required for sane conversions.
-
-=back
-
-=head2 IO::Readable::Encod­ed
-
-This role provides encoded access to a readable data stream, implies
-IO::Encoded. Might imply IO::Buffered, but that's not a requirement.
-
-=over
-
-=item method Str input_record_separa­tor() is rw
-
-This regulates how "readline" behaves.
-
-=item method Str input_field_separat­or() is rw
-
-This regulates how "readfield" behaves.
-
-=item method Str input_escape() is rw
-
-This allows the definition of a escape character, which should be used
-by readline and readfield.
-
-=item method Str readline()
-
-Reads the stream before it finds a $.input_record_sepa­rator and
-returns it (including the separator). If $.input_escape is set, it
-should pay attention to that.
-
-=item method Str readfield()
-
-Reads the stream before it finds a $.input_field_separ­ator and returns
-it (including the separator). If a readfield finds a
-$.input_record_sep­arator it consumes the record separator, but returns
-undef. If $.input_escape is set, it should pay attention to that.
-
-=item method Str getc(Int $length? = 1)
-
-Reads the next $length character in the set $.encoding according to
-the $.locale, or the undefined value at end of file, or if there was
-an error (in the latter case C<$!> is set).
-
-=back
-
-=head2 IO::Writeable::Enco­ded
-
-This role provides encoded access to a writeable data stream, implies
-IO::Encoded. Might imply IO::Buffered, but that's not a requirement.
-
-If these are called in their non-object form, they operate on C<$*DEFOUT>, except in the
-case of warn(), which operates on C<$*DEFERR>. The form with leading dot prints C<$_> to
-the appropriate default handle unless an explicit filehandle is supplied.
-
-=over
-
-=item method Str output_record_separ­ator() is rw
-
-This regulates how say and print(%hash) behaves.
-
-=item method Str output_field_separa­tor() is rw
-
-This regulates how print(@arr), say(@arr), print(%hash) and
-say(%hash) behave.
-
-=item method Str output_escape() is rw
-
-This allows the definition of a escape character, which should be used
-by say and print to preserve the record/field semantics.
-
-=item method Bool print(Str $str)
-
-=item method Bool say(Str $str)
-
-Sends $str to the data stream doing proper encoding conversions. Say
-sends an additional $.output_record_sep­arator. This should also
-convert "\n" to the desired $.output_record_sep­arator.
-
-=item method Bool print(Array @arr)
-
-=item method Bool say(Array @arr)
-
-Sends each element of @arr separated by $.output_field_sepa­rator. Say
-should add an additional $.output_record_sep­arator. If an element
-contains the $.output_record_sep­arator or the
-$.output_field_sea­parator and a $.output_escape is defined, it should
-do the escaping.
-
-=item method Bool print(Hash %hash)
-
-=item method Bool say(Hash %hash)
-
-Sends each pair of the hash separated by $.output_record_sep­arator,
-with key and value separated by $.output_field_sepa­rator. If one of
-those contains a $.output_record_sep­arator or a
-$.output_field_sea­parator and $.output_escape is set, it should do the
-escaping.
-
-=item our Bool method print (IO $self: *@LIST)
-
-=item our Bool multi print (*@LIST)
-
-=item our Bool method print (Str $self: IO $io)
-
-Prints a string or a list of strings. Returns Bool::True if
-successful, Failure otherwise. The IO handle, if supplied, must be
-an object that supports I/O. Indirect objects in Perl 6 must always
-be followed by a colon, and any indirect object more complicated than
-a variable should be put into parentheses.
-
-It is a compiler error to use a bare C<print> without arguments.
-(However, it's fine if you have an explicit argument list that evaluates to
-the empty list at runtime.)
-
-=item say our Bool method say (IO $self: *@LIST)
-
-=item our Bool multi say (*@LIST)
-
-=item our Bool method say (Str $self: IO $io)
-
-This is identical to print() except that it auto-appends a newline after
-the final argument.
-
- Was: print "Hello, world!\n";
- Now: say "Hello, world!";
-
-As with C<print>, it is a compiler error to use a bare C<say> without
-arguments.
-
-=item our Bool method printf (IO $self: Str $fmt, *@LIST)
-
-=item our Bool multi printf (Str $fmt, *@LIST)
-
-The function form works as in Perl 5 and always prints to $*DEFOUT.
-The method form uses IO handles, not formats, as objects.
-
-=back
-
-=head2 IO::Closeable
-
-This role indicates that this object can be closed.
-
-=over
-
-=item method Bool close()
-
-Closes the file or pipe associated with the object.
-
-Returns True on success, but might return an unthrown failure.
-Returns true only if IO buffers are successfully flushed and closes the system
-file descriptor.
-
-Unlike in Perl 5, an IO object is not a special symbol table entry
-neither this object is available magically anywhere else. But as in
-Perl 5, unless stated otherwise, IO::Closeable objects always close
-themselves during destruction
-
-=back
-
-=head2 IO::Socket
-
-role IO::Socket {
- has %.options;
-...
-}
-
-Accessing the %.options would on Unix be done with getsockopt/setsocko­pt.
-
-=over
-
-=item pair
-
- our List of IO method pair(Int $domain, Int $type, Int $protocol)
-
-A wrapper for socketpair(2), returns a pair of IO objects representing the
-reader and writer ends of the socket.
-
- use Socket;
- ($r, $w) = Socket.pair(AF_UNIX­, SOCK_STREAM, PF_UNSPEC);
-
-
-=back
-
-=head2 IO::Listening
-
-=item open
-
- method open()
-
- Does a bind() and a listen().
-
-=item accept
-
- method IO::Socket accept()
-
-=head2 IO::FileDescriptor
-
-This role indicates that this object actually represents an open file
-descriptor in the os level.
-
-=over
-
-=item method int fileno()
-
-File descriptors are always native integers, conforming to C89.
-
-=back
-
-=head1 Classes
-
-=head2 IO::File
-
-This does file input and output.
-
-class IO::File does IO::Streamable {
-...
-}
-
-=over
-
-=item new
-
- method new(Str :$­filename, $options?);
- method new(Int :$­fd);
-
- # Read
- $fobj = new IO::File($filename)­;
-
- # Write
- $fobj = new IO::File($filename,­ :w);
-
- # Read using file descriptor
- $fobj = new IO::File($fd);
-
-Associate an IO object with an already-open file descriptor,
-presumably passed in from the parent process.
-
-=item open()
-
- the :binmode option can be passed to open()
-
-=item IO.truncate
-
-=item IO.fcntl
-
-Available only as a handle method.
-
-=back
-
-=head2 IO::FileSystem
-
-This reads directories, deletes filesystem entries, creates links, and the like.
-
-class IO::FileSystem does IO::Streamable does Tree {
- has Str $.fstype; # ext3, ntfs, vfat, reiserfs, etc
- has Str $.illegal_chars; # ie. /\x0
- has Int $.max_path;
-...
-}
-
-It inherits $cwn and $root from Tree.
-
-=over 4
-
-=item glob
-
-Returns FSNode objects
-
-=item find
-
-Returns FSNode objects
-
-=item link
-
-=item mkdir
-
-=item IO::Dir::open EXPR
-
- my $dir = IO::Dir::open('.');­
-
-Opens a directory named EXPR for processing. Makes the directory looks like
-a list of autochomped lines, so just use ordinary IO operators after the open.
-
-=item readlink
-
-=item rename
-
-=item rmdir FILENAME
-X<rmdir> X<rd> X<directory, remove>
-
-=item rmdir
-
-Deletes the directory specified by FILENAME if that directory is
-empty. If it succeeds it returns true, otherwise it returns false and
-sets C<$!> (errno). If FILENAME is omitted, uses C<$_>.
-
-=item symlink
-
-=item unlink LIST
-X<unlink> X<delete> X<remove> X<rm>
-
-=item unlink
-
-Deletes a list of files. Returns the number of files successfully
-deleted.
-
- $cnt = unlink 'a', 'b', 'c';
-
-Be warned that unlinking a directory can inflict damage on your filesystem.
-Finally, using C<unlink> on directories is not supported on many operating
-systems. Use C<rmdir> instead.
-
-It is an error to use bare C<unlink> without arguments.
-
-=back
-
-=head2 IO::FSNode
-
-class IO::FSNode does Tree::Node {
- has Array of IO::FSNodeACL @.ACLs;
- has Hash of %.times;
-...
-}
-
-The %times has keys that can be eg. ctime, Modification, and Access (and maybe others on
-other operating systems), and the values are all DateTime objects.
-
-When .path() is implemented, it should return the path that this was opened with.
-
-=over 4
-
-=item IO ~~ :X
-X<:r>X<:w>X<:x>X<:­o>X<:R>X<:W>X<:X>X<:­O>X<:e>X<:z>X<:s>X<:­f>X<:d>X<:l>X<:p>
-X<:S>X<:b>X<:c>X<:­t>X<:u>X<:g>X<:k>X<:­T>X<:B>X<:M>X<:A>X<:­C>
-
-=item EXPR ~~ :X
-
- $file.:X
- $file ~~ :X
-
-A file test, where X is one of the letters listed below. This unary
-operator takes one argument, either a filename or a filehandle, and
-tests the associated file to see if something is true about it.
-
-A Pair used as a pattern is treated as a file test.
-
- :r File is readable by effective uid/gid.
- :w File is writable by effective uid/gid.
- :x File is executable by effective uid/gid.
- :o File is owned by effective uid.
-
- :R File is readable by real uid/gid.
- :W File is writable by real uid/gid.
- :X File is executable by real uid/gid.
- :O File is owned by real uid.
-
- :e File exists.
- :z File has zero size (is empty).
- :s File has nonzero size (returns size in bytes).
-
- :f File is a plain file.
- :d File is a directory.
- :l File is a symbolic link.
- :p­ File is a named pipe (FIFO), or Filehandle is a pipe.
- :S File is a socket.
- :b File is a block special file.
- :c File is a character special file.
- :t Filehandle is opened to a tty.
-
- :u File has setuid bit set.
- :g File has setgid bit set.
- :k File has sticky bit set.
-
- :T File is an ASCII text file (heuristic guess).
- :B File is a "binary" file (opposite of :T).
-
- :M Script start time minus file modification time, in days.
- :A Same for access time.
- :C Same for inode change time (Unix, may differ for other platforms)
-
-The interpretation of the file permission operators C<:r>, C<:R>,
-C<:w>, C<:W>, C<:x>, and C<:X> is by default based solely on the mode
-of the file and the uids and gids of the user. There may be other
-reasons you can't actually read, write, or execute the file. Such
-reasons may be for example network filesystem access controls, ACLs
-(access control lists), read-only filesystems, and unrecognized
-executable formats.
-
-Also note that, for the superuser on the local filesystems, the C<:r>,
-C<:R>, C<:w>, and C<:W> tests always return 1, and C<:x> and C<:X> return 1
-if any execute bit is set in the mode. Scripts run by the superuser
-may thus need to do a stat() to determine the actual mode of the file,
-or temporarily set their effective uid to something else.
-
-If you are using ACLs, there is a pragma called C<filetest> that may
-produce more accurate results than the bare stat() mode bits.
-When under the C<use filetest 'access'> the above-mentioned filetests
-will test whether the permission can (not) be granted using the
-access() family of system calls. Also note that the C<:x> and C<:X> may
-under this pragma return true even if there are no execute permission
-bits set (nor any extra execute permission ACLs). This strangeness is
-due to the underlying system calls' definitions. Read the
-documentation for the C<filetest> pragma for more information.
-
-The C<:T> and C<:B> switches work as follows. The first block or so of the
-file is examined for odd characters such as strange control codes or
-characters with the high bit set. If too many strange characters (>30%)
-are found, it's a C<:B> file; otherwise it's a C<:T> file. Also, any file
-containing null in the first block is considered a binary file. If C<:T>
-or C<:B> is used on a filehandle, the current IO buffer is examined
-rather than the first block. Both C<:T> and C<:B> return true on a null
-file, or a file at EOF when testing a filehandle. Because you have to
-read a file to do the C<:T> test, on most occasions you want to use a C<:f>
-against the file first, as in C<next unless $file ~~ :f && $file ~~ :T >.
-
-You can test multiple features using junctions:
-
- if -$filename ~~ :r & :w & :x {...}
-
-Or pass multiple tests together in OO style:
-
- if $filename.TEST(:­e,:­x) {...}
-
-
-=item realpath
-
- method Str realpath();
-
-Gets the real path to the object, resolving softlinks/shortcuts­, etc
-
-=item === operator
-
- method infix:<===>(Str $filename);
-
-Test whether the specified filename is the same file as this file. On a Unix system,
-this would presumably be done by comparing inode numbers or something.
-
-=item new
-
-This is called automatically on object creation.
-
-multi method new(Array of Str :@pathelements);
-multi method new(String :$­type, String :$­path);
-multi method new(String :$­path);
-
-This last throws an error if "use portable" pragma is used.
-
-Examples:
-
- $fsnode = new IO::FSNode(pathelem­ents => ['home', 'wayland']);
- $fsnode = new IO::FSNode(type => 'Unix', path => '/home/wayland');
- $fsnode = new IO::FSNode(path => '/home/wayland');
-
-=back
-
-=head2 IO::FSNodeACL
-
-This is a basic abstraction; for better control, use the operating-system specific
-interfaces, over which this is a thin veneer.
-
-class IO::FSNodeACL {
- has Str $.type; # "User", "Group", "Everyone", ???
- has Str $.id; # username or groupname; unused for $type eq "Everyone"
- has %.permissions;
- # Unsupported values may (or may not) throw
- # UnsupportedPermissi­on when set or read
- has IO::FSNode $.owningObject;
-...
-}
-
-The permissions used in %permissions are:
-
-=over
-
-=item Readable
-
-Should be supported by all filesystems as an item to read from the hash for the group
-"Everyone".
-
-=item Writeable
-
-Should be supported by all filesystems as an item to read from the hash for the group
-"Everyone".
-
-=item Executeable
-
-Supported on most Unix systems, anyway. Windows should be able to guess when this is
-read, and throw an exception if written to.
-
-=item Default
-
-An ACL of User,fred,Default sets the user "fred" to be the owner of the file. This can be
-done with groups too. Work on Unix, at least.
-
-=back
-
-The $.owningObject attribute of FSNodeACL shows what the ACL is set on. On a
-Windows system, this can be a parent directory, as permissions are inherited.
-
-=head2 IO::FileNode
-
- role IO::FileNode does IO::FSNode {
-...
- }
-
-=over
-
-=item our List multi method lines (IO $handle:)­ is export;
-
-=item our List multi lines (Str $filename);
-
-Returns all the lines of a file as a (lazy) List regardless of context.
-See also C<slurp>.
-
-=item our Item multi method slurp (IO $handle: *%opts) is export;
-
-=item our Item multi slurp (Str $filename, *%opts);
-
-Slurps the entire file into a Str or Buf regardless of context.
-(See also C<lines>.) Whether a Str or Buf is returned depends on
-the options.
-
-=back
-
-=head2 IO::DirectoryNode
-
- role IO::DirectoryNode does IO::FSNode {
-...
- }
-
-=head2 IO::Socket::TCP
-
-class IO::Socket::TCP does IO::Socket does IO::Streamable {
-...
-}
-
-=over
-
-=item has $.RemoteHost
-
-=item has $.RemotePort
-
-=item has $.LocalHost
-
-=item has $.LocalPort
-
-=item new
-
- method IO::Socket::TCP new(
- :$­RemoteHost, :$­RemotePort,
- :$­LocalHost, :$­LocalPort,
- :$­Blocking,
- :$­NoOpen
- );
-
-The creation of the object will also open the connection, unless NoOpen is specified.
-
-=item open
-
- method open()
-
-If it's not an IO::Listening, it does a connect().
-
-It's intended for the case where the creation of the object didn't do one.
-
-=item method Int read($buf is rw, Int $length)
-
-Does a recv().
-
-=item method Int write($buf, Int $length)
-
-Does a send().
-
-=item IO.getpeername
-
-=item /[get|set][host|net|proto|serv|sock].*/
-
-=back
-
-=head2 IO::Pipe
-
-class IO::Pipe does IO::Streamable {
-...
-}
-
-May also do IO::Readable and IO::Writable, depending on opening method.
-
-=over
-
-=item close()
-
-If the file handle came from a piped open, C<close> will additionally
-return false if one of the other system calls involved fails, or if the
-program exits with non-zero status. (If the only problem was that the
-program exited non-zero, C<$!> will be set to C<0>.) Closing a pipe
-also waits for the process executing on the pipe to complete, in case you
-want to look at the output of the pipe afterwards, and
-implicitly puts the exit status value of that command into C<$!>.
-
-=item Pipe.to
-
- our IO method to(Str $command, *%opts)
-
-Opens a one-way pipe writing to $command. IO redirection for
-stderr is specified with :err(IO) or :err<Str>. Other IO redirection
-is done with feed operators. XXX how to specify "2>&1"?
-
-=item Pipe.from
-
- our IO method from(Str $command, *%opts)
-
-Opens a one-way pipe reading from $command. IO redirection for
-stderr is specified with :err(IO) or :err<Str>. Other IO redirection
-is done with feed operators. XXX how to specify "2>&1"?
-
-=item Pipe.pair
-
- our List of IO method pair()
-
-A wrapper for pipe(2), returns a pair of IO objects representing the
-reader and writer ends of the pipe.
-
- ($r, $w) = Pipe.pair;
-
-=back
-
-=head1 Calls that operate on the default IO handle
-
-=over
-
-=item close()
-
-=item open()
-
-...
-
-=back
-
-=head1 OS-specific classes
-
-=head2 Unix
-
-=head2 IO::FSNode::Unix
-
-=item chown
-
- our Int multi chown ($uid = -1, $gid = -1, *@files)
-
-Changes the owner (and group) of a list of files. The first
-two elements of the list must be the numeric uid and gid, in
-that order. A value of -1 in either position is interpreted by
-most systems to leave that value unchanged. Returns the number
-of files successfully changed.
-
- $count = chown $uid, $gid, ’foo’, ’bar’;
- chown $uid, $gid, @filenames;
-
-On systems that support C<fchown>, you might pass file handles
-among the files. On systems that don’t support C<fchown>, passing
-file handles produces a fatal error at run time.
-
-Here’s an example that looks up nonnumeric uids in the passwd
-file:
-
- $user = prompt "User: ";
- $pattern = prompt "Files: ";
-
- ($login,$pass,$uid,­$gid) = getpwnam($user)
- or die "$user not in passwd file";
-
- @ary = glob($pattern); # expand filenames
- chown $uid, $gid, @ary;
-
-On most systems, you are not allowed to change the ownership of
-the file unless you’re the superuser, although you should be
-able to change the group to any of your secondary groups. On
-insecure systems, these restrictions may be relaxed, but this
-is not a portable assumption. On POSIX systems, you can detect
-this condition this way:
-
- use POSIX qw(sysconf _PC_CHOWN_RESTRICTE­D);
- $can_chown_giveaway­ = not sysconf(_PC_CHOWN_R­ESTRICTED);
-
-=item chmod LIST
-X<chmod> X<permission> X<mode>
-
-Changes the permissions of a list of files. The first element of the
-list must be the numerical mode, which should probably be an octal
-number, and which definitely should I<not> be a string of octal digits:
-C<0o644> is okay, C<0644> is not. Returns the number of files
-successfully changed.
-
- $cnt = chmod 0o755, 'foo', 'bar';
- chmod 0o755, @executables;
- $mode = '0644'; chmod $mode, 'foo'; # !!! sets mode to --w----r-T
- $mode = '0o644'; chmod $mode, 'foo'; # this is better
- $mode = 0o644; chmod $mode, 'foo'; # this is best
-
-=item lstat
-
-Returns a stat buffer. If the lstat succeeds, the stat buffer evaluates
-to true, and additional file tests may be performed on the value. If
-the stat fails, all subsequent tests on the stat buffer also evaluate
-to false.
-
-=item stat
-
-=item IO.stat
-
-Returns a stat buffer. If the lstat succeeds, the stat buffer evaluates
-to true, and additional file tests may be performed on the value. If
-the stat fails, all subsequent tests on the stat buffer also evaluate
-to false.
-
-=head2 IO::POSIX
-
-Indicates that this object can perform standard posix IO
-operations. It implies IO::Readable and IO::Writeable.
-
-=over
-
-=item method IO dup()
-
-=item has Bool $.blocking is rw
-
-=item method Bool flock(:$r,:$­w)
-
-=item method Bool funlock()
-
-=item ...
-
-=back
-
-=head1 Unfiled
-
-=over 4
-
-=item IO.ioctl
-
-Available only as a handle method.
-
-=item alarm
-
-=item prompt
-
- our Str prompt (Str $prompt)
-
- Should there be an IO::Interactive role?
-
-=item Str.readpipe
-
-=item sysopen
-
-=item IO.sysseek
-
-=item umask
-
-=back
-
-=head1 Removed functions
-
-=over
-
-=item IO.eof
-
-Gone, see IO::Endable
-
-=item IO.fileno
-
-See IO::FileDescriptor
-
-=item IO.name
-
-Changed to .path(), but we haven't gotten around to specifying this on all of them.
-
-The C<.name> method returns the name of the file/socket/uri the handle
-was opened with, if known. Returns undef otherwise. There is no
-corresponding C<name()> function.
-
-=item pipe
-
-Gone, see Pipe.pair
-
-=item select(both)
-
-Gone. (Note: for subsecond sleep, just use sleep with a fractional argument.)
-
-=item IO.shutdown()
-
-Gone, see IO::Socket.close(),­ $IO::Readable.isRea­dable, and $IO::Writeable.isWr­iteable
-
-=item socketpair
-
-Gone, see Socket.pair
-
-=item IO.sysread
-
-Gone, see IO::Readable.read()­
-
-=item IO.syswrite
-
-Gone, see IO::Writeable.read(­)
-
-=item utime
-
-Gone, see %IO::FSNode.times.
-
-=back
-
=head1 Additions

Please post errors and feedback to perl6-language. If you are making

Modified: docs/Perl6/Spec/S32­-setting-library/IO.­pod
===================­====================­====================­========
--- docs/Perl6/Spec/S32­-setting-library/IO.­pod 2009-02-23 02:21:44 UTC (rev 25487)
+++ docs/Perl6/Spec/S32­-setting-library/IO.­pod 2009-02-23 03:07:23 UTC (rev 25488)
@@ -7,16 +7,17 @@

=head1 Version

- Author: Rod Adams <rod@rodadams.net>
+ Author: Rod Adams <rod@rodadams.net>,­ the authors of the related Perl 5 docs.
Maintainer: Larry Wall <larry@wall.org>
Contributions: Aaron Sherman <ajs@ajs.com>
Mark Stosberg <mark@summersault.c­om>
Carl M sak <cmasak@gmail.com>
Moritz Lenz <moritz@faui2k3.org­>
Tim Nelson <wayland@wayland.id­.au>
- Date: 19 Mar 2009 extracted from S29-functions.pod
- Last Modified: 19 Feb 2009
- Version: 1
+ Daniel Ruoso <daniel@ruoso.com>
+ Date: 19 Feb 2009 extracted from S29-functions.pod; added stuff from S16-IO later
+ Last Modified: 23 Feb 2009
+ Version: 2

The document is a draft.

@@ -57,12 +58,995 @@

See C<Synopsis 16: IPC / IO / Signals> for details.

+=item uri
+
+ IO::Streamable method uri(Str $uri);
+
+Returns an appropriate IO::Streamable descendant, with the type depending on the uri
+passed in. Here's the mapping:
+
+ URI type IO type
+ ======== =======
+ file: IO::File or IO::Directory
+ ftp: IO::Socket::TCP (data channel)
+ http: IO::Socket::TCP
+
+IO::Streamable method uri(Str $uri) {
+ $uri.match(/^<alnum­>+\:/);
+ return(&$PROTOCOLS{­$1}($uri));
+}
+
+=item %PROTOCOLS global variable
+
+For each protocol, stores a subroutine reference that returns the appropriate object when
+the URI is passed in.
+
=back

+=head1 Roles
+
+The functionality of IO objects is broken down into several roles,
+which should identify the features each object supports.
+
+=head2 IO
+
+The base role only tags that this is an IO object for more generic
+purposes. It doesn't specify any methods or attributes.
+
+=head2 IO::Readable
+
+This role provides unbuffered read access to the data stream.
+
+role IO::Readable {
+ has $.isReadable;
+
+ method Int read($buf is rw, Int $length)
+}
+
+When the $.isReadable is set, it tries to change the readability of the filehandle. This
+is not always possible, but can be done in a number of cases. IO::Socket can remove
+readability by calling shutdown(), for example.
+
+=over
+
+=item method Int read($buf is rw, Int $length)
+
+Tries to read $length bytes and store in $buf. The contents of $buf
+are replaced and the actual number of bytes read is returned. A return
+of 0 means end of file. It might return unthrown failures, to be
+specified by each IO implementation.
+
+It is important to realize that this is "raw" read. You're going to
+have plain octets stored in $buf, if this is actually encoded data,
+you're going to need to encode it later, or use "getc" or other
+IO::Readable::Enco­ded methods.
+
+=back
+
+=head2 IO::Writeable
+
+This role provides unbuffered write access to the data stream.
+
+role IO::Writeable {
+ has $.isWriteable;
+
+ method Int write($buf, Int $length)
+}
+
+When the $.isWriteable is set, it tries to change the writeability of the filehandle.
+This is not always possible, but can be done in a number of cases. IO::Socket can remove
+writeability by calling shutdown(), for example.
+
+=over
+
+=item method Int write($buf, Int $length)
+
+Tries to write $length bytes of $buf. The actual number of bytes
+written is returned. It might return unthrown failures, to be
+specified by each IO implementation.
+
+It is important to realize that this is "raw" write. $buf should
+contain plain octets that are going to be sent. If $buf contains
+encoded data, you should decode it first, or use "print" or other
+IO::Writeable::Enc­oded methods.
+
+=back
+
+=head2 IO::Seekable
+
+=over
+
+=item method Bool eoi()
+
+Returns true if it's the end of the input (ie. end of file or whatever), returns false if
+not, returns undef if we can't say for certain.
+
+=item method Bool seek(Int $position)
+
+Position this stream into $position. The meaning of this position is
+always in "octets".
+
+=item method Int tell()
+
+Returns the current raw position in the stream in number of "octets".
+
+=back
+
+=head2 IO::Buffered
+
+Indicates that this object performs buffering. The management of the
+buffer is completely implementation specific.
+
+=over
+
+=item method Bool flush()
+
+Flushes the buffers associated with this object.
+
+=item method Bool autoflush() is rw
+
+Forces this object to keep its buffers empty
+
+=back
+
+=head2 IO::Streamable
+
+This role represents objects that depend on some external resource,
+which means that data might not be available at request.
+
+=over
+
+=item method Bool blocking() is rw
+
+This allows the user to control wether this object should do a
+blocking wait or immediatly return in the case of not having data
+available.
+
+=back
+
+=head2 IO::Encoded
+
+This is a generic role for encoded data streams.
+
+=over
+
+=item method Str encoding() is rw
+
+=item method Str locale() is rw
+
+Encoding and locale are required for sane conversions.
+
+=back
+
+=head2 IO::Readable::Encod­ed
+
+This role provides encoded access to a readable data stream, implies
+IO::Encoded. Might imply IO::Buffered, but that's not a requirement.
+
+=over
+
+=item method Str input_record_separa­tor() is rw
+
+This regulates how "readline" behaves.
+
+=item method Str input_field_separat­or() is rw
+
+This regulates how "readfield" behaves.
+
+=item method Str input_escape() is rw
+
+This allows the definition of a escape character, which should be used
+by readline and readfield.
+
+=item method Str readline()
+
+Reads the stream before it finds a $.input_record_sepa­rator and
+returns it (including the separator). If $.input_escape is set, it
+should pay attention to that.
+
+=item method Str readfield()
+
+Reads the stream before it finds a $.input_field_separ­ator and returns
+it (including the separator). If a readfield finds a
+$.input_record_sep­arator it consumes the record separator, but returns
+undef. If $.input_escape is set, it should pay attention to that.
+
+=item method Str getc(Int $length? = 1)
+
+Reads the next $length character in the set $.encoding according to
+the $.locale, or the undefined value at end of file, or if there was
+an error (in the latter case C<$!> is set).
+
+=back
+
+=head2 IO::Writeable::Enco­ded
+
+This role provides encoded access to a writeable data stream, implies
+IO::Encoded. Might imply IO::Buffered, but that's not a requirement.
+
+If these are called in their non-object form, they operate on C<$*DEFOUT>, except in the
+case of warn(), which operates on C<$*DEFERR>. The form with leading dot prints C<$_> to
+the appropriate default handle unless an explicit filehandle is supplied.
+
+=over
+
+=item method Str output_record_separ­ator() is rw
+
+This regulates how say and print(%hash) behaves.
+
+=item method Str output_field_separa­tor() is rw
+
+This regulates how print(@arr), say(@arr), print(%hash) and
+say(%hash) behave.
+
+=item method Str output_escape() is rw
+
+This allows the definition of a escape character, which should be used
+by say and print to preserve the record/field semantics.
+
+=item method Bool print(Str $str)
+
+=item method Bool say(Str $str)
+
+Sends $str to the data stream doing proper encoding conversions. Say
+sends an additional $.output_record_sep­arator. This should also
+convert "\n" to the desired $.output_record_sep­arator.
+
+=item method Bool print(Array @arr)
+
+=item method Bool say(Array @arr)
+
+Sends each element of @arr separated by $.output_field_sepa­rator. Say
+should add an additional $.output_record_sep­arator. If an element
+contains the $.output_record_sep­arator or the
+$.output_field_sea­parator and a $.output_escape is defined, it should
+do the escaping.
+
+=item method Bool print(Hash %hash)
+
+=item method Bool say(Hash %hash)
+
+Sends each pair of the hash separated by $.output_record_sep­arator,
+with key and value separated by $.output_field_sepa­rator. If one of
+those contains a $.output_record_sep­arator or a
+$.output_field_sea­parator and $.output_escape is set, it should do the
+escaping.
+
+=item our Bool method print (IO $self: *@LIST)
+
+=item our Bool multi print (*@LIST)
+
+=item our Bool method print (Str $self: IO $io)
+
+Prints a string or a list of strings. Returns Bool::True if
+successful, Failure otherwise. The IO handle, if supplied, must be
+an object that supports I/O. Indirect objects in Perl 6 must always
+be followed by a colon, and any indirect object more complicated than
+a variable should be put into parentheses.
+
+It is a compiler error to use a bare C<print> without arguments.
+(However, it's fine if you have an explicit argument list that evaluates to
+the empty list at runtime.)
+
+=item say our Bool method say (IO $self: *@LIST)
+
+=item our Bool multi say (*@LIST)
+
+=item our Bool method say (Str $self: IO $io)
+
+This is identical to print() except that it auto-appends a newline after
+the final argument.
+
+ Was: print "Hello, world!\n";
+ Now: say "Hello, world!";
+
+As with C<print>, it is a compiler error to use a bare C<say> without
+arguments.
+
+=item our Bool method printf (IO $self: Str $fmt, *@LIST)
+
+=item our Bool multi printf (Str $fmt, *@LIST)
+
+The function form works as in Perl 5 and always prints to $*DEFOUT.
+The method form uses IO handles, not formats, as objects.
+
+=back
+
+=head2 IO::Closeable
+
+This role indicates that this object can be closed.
+
+=over
+
+=item method Bool close()
+
+Closes the file or pipe associated with the object.
+
+Returns True on success, but might return an unthrown failure.
+Returns true only if IO buffers are successfully flushed and closes the system
+file descriptor.
+
+Unlike in Perl 5, an IO object is not a special symbol table entry
+neither this object is available magically anywhere else. But as in
+Perl 5, unless stated otherwise, IO::Closeable objects always close
+themselves during destruction
+
+=back
+
+=head2 IO::Socket
+
+role IO::Socket {
+ has %.options;
+...
+}
+
+Accessing the %.options would on Unix be done with getsockopt/setsocko­pt.
+
+=over
+
+=item pair
+
+ our List of IO method pair(Int $domain, Int $type, Int $protocol)
+
+A wrapper for socketpair(2), returns a pair of IO objects representing the
+reader and writer ends of the socket.
+
+ use Socket;
+ ($r, $w) = Socket.pair(AF_UNIX­, SOCK_STREAM, PF_UNSPEC);
+
+
+=back
+
+=head2 IO::Listening
+
+=item open
+
+ method open()
+
+ Does a bind() and a listen().
+
+=item accept
+
+ method IO::Socket accept()
+
+=head2 IO::FileDescriptor
+
+This role indicates that this object actually represents an open file
+descriptor in the os level.
+
+=over
+
+=item method int fileno()
+
+File descriptors are always native integers, conforming to C89.
+
+=back
+
+=head1 Classes
+
+=head2 IO::File
+
+This does file input and output.
+
+class IO::File does IO::Streamable {
+...
+}
+
+=over
+
+=item new
+
+ method new(
+ FSNode :$­FSNode,
+ Str :$­Filename,
+ :$­fd
+ Bool :$­NoOpen,
+ :$­Writeable,
+ );
+
+The FSNode, Filename and fd options are mutually exclusive. If "use portable" is in
+effect, the Filename option throws an error; use an FSNode instead.
+
+Examples:
+
+ # Read -- throws errors with 'use portable'
+ $fobj = new IO::File(Filename => $filename);
+
+ # Write -- works with 'use portable'
+ $fobj = new IO::File(
+ FSNode => IO::FSNode.new(type­ => 'Unix', Filename => $filename),
+ Writeable => 1
+ );
+
+ # Read using file descriptor
+ $fobj = new IO::File(fd => $fd);
+
+This final example associates an IO object with an already-open file descriptor,
+presumably passed in from the parent process.
+
+=item open()
+
+This function opens a file that had the "NoOpen" option passed to the new() method.
+
+=item IO.truncate
+
+=item IO.fcntl
+
+Available only as a handle method.
+
+=back
+
+=head2 IO::FileSystem
+
+This represents the filesystem.
+
+class IO::FileSystem does IO::Streamable does Tree {
+ has Str $.fstype; # ext3, ntfs, vfat, reiserfs, etc
+ has Str $.illegal_chars; # ie. /\x0
+ has Int $.max_path;
+...
+}
+
+It inherits $cwn and $root from Tree.
+
+=over 4
+
+=item glob
+
+Returns FSNode objects
+
+=item find
+
+Returns FSNode objects
+
+=item rename
+
+=back
+
+=head2 IO::FSNode
+
+class IO::FSNode does Tree::Node {
+ has Array of IO::FSNodeACL @.ACLs;
+ has Hash of %.times;
+...
+}
+
+The %times has keys that can be eg. ctime, Modification, and Access (and maybe others on
+other operating systems), and the values are all DateTime objects.
+
+When .path() is implemented, it should return the path that this was opened with.
+
+=over 4
+
+=item IO ~~ :X
+X<:r>X<:w>X<:x>X<:­o>X<:R>X<:W>X<:X>X<:­O>X<:e>X<:z>X<:s>X<:­f>X<:d>X<:l>X<:p>
+X<:S>X<:b>X<:c>X<:­t>X<:u>X<:g>X<:k>X<:­T>X<:B>X<:M>X<:A>X<:­C>
+
+=item EXPR ~~ :X
+
+ $file.:X
+ $file ~~ :X
+
+A file test, where X is one of the letters listed below. This unary
+operator takes one argument, either a filename or a filehandle, and
+tests the associated file to see if something is true about it.
+
+A Pair used as a pattern is treated as a file test.
+
+ :r File is readable by effective uid/gid.
+ :w File is writable by effective uid/gid.
+ :x File is executable by effective uid/gid.
+ :o File is owned by effective uid.
+
+ :R File is readable by real uid/gid.
+ :W File is writable by real uid/gid.
+ :X File is executable by real uid/gid.
+ :O File is owned by real uid.
+
+ :e File exists.
+ :z File has zero size (is empty).
+ :s File has nonzero size (returns size in bytes).
+
+ :f File is a plain file.
+ :d File is a directory.
+ :l File is a symbolic link.
+ :p­ File is a named pipe (FIFO), or Filehandle is a pipe.
+ :S File is a socket.
+ :b File is a block special file.
+ :c File is a character special file.
+ :t Filehandle is opened to a tty.
+
+ :u File has setuid bit set.
+ :g File has setgid bit set.
+ :k File has sticky bit set.
+
+ :T File is an ASCII text file (heuristic guess).
+ :B File is a "binary" file (opposite of :T).
+
+ :M Script start time minus file modification time, in days.
+ :A Same for access time.
+ :C Same for inode change time (Unix, may differ for other platforms)
+
+The interpretation of the file permission operators C<:r>, C<:R>,
+C<:w>, C<:W>, C<:x>, and C<:X> is by default based solely on the mode
+of the file and the uids and gids of the user. There may be other
+reasons you can't actually read, write, or execute the file. Such
+reasons may be for example network filesystem access controls, ACLs
+(access control lists), read-only filesystems, and unrecognized
+executable formats.
+
+Also note that, for the superuser on the local filesystems, the C<:r>,
+C<:R>, C<:w>, and C<:W> tests always return 1, and C<:x> and C<:X> return 1
+if any execute bit is set in the mode. Scripts run by the superuser
+may thus need to do a stat() to determine the actual mode of the file,
+or temporarily set their effective uid to something else.
+
+If you are using ACLs, there is a pragma called C<filetest> that may
+produce more accurate results than the bare stat() mode bits.
+When under the C<use filetest 'access'> the above-mentioned filetests
+will test whether the permission can (not) be granted using the
+access() family of system calls. Also note that the C<:x> and C<:X> may
+under this pragma return true even if there are no execute permission
+bits set (nor any extra execute permission ACLs). This strangeness is
+due to the underlying system calls' definitions. Read the
+documentation for the C<filetest> pragma for more information.
+
+The C<:T> and C<:B> switches work as follows. The first block or so of the
+file is examined for odd characters such as strange control codes or
+characters with the high bit set. If too many strange characters (>30%)
+are found, it's a C<:B> file; otherwise it's a C<:T> file. Also, any file
+containing null in the first block is considered a binary file. If C<:T>
+or C<:B> is used on a filehandle, the current IO buffer is examined
+rather than the first block. Both C<:T> and C<:B> return true on a null
+file, or a file at EOF when testing a filehandle. Because you have to
+read a file to do the C<:T> test, on most occasions you want to use a C<:f>
+against the file first, as in C<next unless $file ~~ :f && $file ~~ :T >.
+
+You can test multiple features using junctions:
+
+ if -$filename ~~ :r & :w & :x {...}
+
+Or pass multiple tests together in OO style:
+
+ if $filename.TEST(:­e,:­x) {...}
+
+
+=item realpath
+
+ method Str realpath();
+
+Gets the real path to the object, resolving softlinks/shortcuts­, etc
+
+=item === operator
+
+ method infix:<===>(Str $filename);
+
+Test whether the specified filename is the same file as this file. On a Unix system,
+this would presumably be done by comparing inode numbers or something.
+
+=item new
+
+This is called automatically on object creation.
+
+multi method new(Array of Str :@PathElements);
+multi method new(Str :$­Type, Str :$­Path, Str :$­Create);
+multi method new(Str :$­Path);
+
+This last throws an error if "use portable" pragma is used.
+
+If the "Create" option is passed in, and the node doesn't exist in the filesystem, it
+attempts to create the node; this can be used for "mkdir", "link", and similar
+functionality.
+
+Examples:
+
+ $fsnode = new IO::FSNode(PathElem­ents => ['home', 'wayland']);
+ $fsnode = new IO::FSNode(Type => 'Unix', Path => '/home/wayland');
+ $fsnode = new IO::FSNode(Path => '/home/wayland'); # portability error
+
+=item delete
+
+This deletes the FSNode from the filesystem. If the node has children, it throws an error
+unless the "Recursive" option is specified. Returns the number of nodes deleted.
+
+=back
+
+=head2 IO::FSNodeACL
+
+This is a basic abstraction; for better control, use the operating-system specific
+interfaces, over which this is a thin veneer.
+
+class IO::FSNodeACL {
+ has Str $.type; # "User", "Group", "Everyone", ???
+ has Str $.id; # username or groupname; unused for $type eq "Everyone"
+ has %.permissions;
+ # Unsupported values may (or may not) throw
+ # UnsupportedPermissi­on when set or read
+ has IO::FSNode $.owningObject;
+...
+}
+
+The permissions used in %permissions are:
+
+=over
+
+=item Readable
+
+Should be supported by all filesystems as an item to read from the hash for the group
+"Everyone".
+
+=item Writeable
+
+Should be supported by all filesystems as an item to read from the hash for the group
+"Everyone".
+
+=item Executeable
+
+Supported on most Unix systems, anyway. Windows should be able to guess when this is
+read, and throw an exception if written to.
+
+=item Default
+
+An ACL of User,fred,Default sets the user "fred" to be the owner of the file. This can be
+done with groups too. Work on Unix, at least.
+
+=back
+
+The $.owningObject attribute of FSNodeACL shows what the ACL is set on. On a
+Windows system, this can be a parent directory, as permissions are inherited.
+
+=head2 IO::FileNode
+
+ role IO::FileNode does IO::FSNode {
+...
+ }
+
+=over
+
+=item our List multi method lines (IO $handle:)­ is export;
+
+=item our List multi lines (Str $filename);
+
+Returns all the lines of a file as a (lazy) List regardless of context.
+See also C<slurp>.
+
+=item our Item multi method slurp (IO $handle: *%opts) is export;
+
+=item our Item multi slurp (Str $filename, *%opts);
+
+Slurps the entire file into a Str or Buf regardless of context.
+(See also C<lines>.) Whether a Str or Buf is returned depends on
+the options.
+
+=back
+
+=head2 IO::DirectoryNode
+
+ role IO::DirectoryNode does IO::FSNode {
+...
+ }
+
+=item open
+
+ $dir.open();
+
+Opens a directory for processing, if the new() method was passed the NoOpen option.
+Makes the directory looks like
+a list of autochomped lines, so just use ordinary IO operators after the open.
+
+=item rmdir FILENAME
+X<rmdir> X<rd> X<directory, remove>
+
+=item rmdir
+
+Deletes the directory specified by FILENAME if that directory is
+empty. If it succeeds it returns true, otherwise it returns false and
+sets C<$!> (errno). If FILENAME is omitted, uses C<$_>.
+
+=head2 IO::LinkNode
+
+ role IO::LinkNode does IO::FSNode {
+...
+ }
+
+=item link
+
+=item readlink
+
+=item symlink
+
+=head2 IO::Socket::TCP
+
+class IO::Socket::TCP does IO::Socket does IO::Streamable {
+...
+}
+
+=over
+
+=item has $.RemoteHost
+
+=item has $.RemotePort
+
+=item has $.LocalHost
+
+=item has $.LocalPort
+
+=item new
+
+ method IO::Socket::TCP new(
+ Str :$­RemoteHost, Str :$­RemotePort,
+ Str :$­LocalHost, Str :$­LocalPort,
+ Bool :$­Blocking,
+ Bool :$­NoOpen
+ );
+
+The creation of the object will also open the connection, unless NoOpen is specified.
+
+=item open
+
+ method open()
+
+If it's not an IO::Listening, it does a connect().
+
+It's intended for the case where the creation of the object didn't do one.
+
+=item method Int read($buf is rw, Int $length)
+
+Does a recv().
+
+=item method Int write($buf, Int $length)
+
+Does a send().
+
+=item IO.getpeername
+
+=item /[get|set][host|net|proto|serv|sock].*/
+
+=back
+
+=head2 IO::Pipe
+
+class IO::Pipe does IO::Streamable {
+...
+}
+
+May also do IO::Readable and IO::Writable, depending on opening method.
+
+=over
+
+=item close()
+
+If the file handle came from a piped open, C<close> will additionally
+return false if one of the other system calls involved fails, or if the
+program exits with non-zero status. (If the only problem was that the
+program exited non-zero, C<$!> will be set to C<0>.) Closing a pipe
+also waits for the process executing on the pipe to complete, in case you
+want to look at the output of the pipe afterwards, and
+implicitly puts the exit status value of that command into C<$!>.
+
+=item Pipe.to
+
+ our IO method to(Str $command, *%opts)
+
+Opens a one-way pipe writing to $command. IO redirection for
+stderr is specified with :err(IO) or :err<Str>. Other IO redirection
+is done with feed operators. XXX how to specify "2>&1"?
+
+=item Pipe.from
+
+ our IO method from(Str $command, *%opts)
+
+Opens a one-way pipe reading from $command. IO redirection for
+stderr is specified with :err(IO) or :err<Str>. Other IO redirection
+is done with feed operators. XXX how to specify "2>&1"?
+
+=item Pipe.pair
+
+ our List of IO method pair()
+
+A wrapper for pipe(2), returns a pair of IO objects representing the
+reader and writer ends of the pipe.
+
+ ($r, $w) = Pipe.pair;
+
+=back
+
+=head1 Calls that operate on the default IO handle
+
+=over
+
+=item close()
+
+=item open()
+
+...
+
+=back
+
+=head1 OS-specific classes
+
+=head2 Unix
+
+=head2 IO::FSNode::Unix
+
+=item chown
+
+ our Int multi chown ($uid = -1, $gid = -1, *@files)
+
+Changes the owner (and group) of a list of files. The first
+two elements of the list must be the numeric uid and gid, in
+that order. A value of -1 in either position is interpreted by
+most systems to leave that value unchanged. Returns the number
+of files successfully changed.
+
+ $count = chown $uid, $gid, ’foo’, ’bar’;
+ chown $uid, $gid, @filenames;
+
+On systems that support C<fchown>, you might pass file handles
+among the files. On systems that don’t support C<fchown>, passing
+file handles produces a fatal error at run time.
+
+Here’s an example that looks up nonnumeric uids in the passwd
+file:
+
+ $user = prompt "User: ";
+ $pattern = prompt "Files: ";
+
+ ($login,$pass,$uid,­$gid) = getpwnam($user)
+ or die "$user not in passwd file";
+
+ @ary = glob($pattern); # expand filenames
+ chown $uid, $gid, @ary;
+
+On most systems, you are not allowed to change the ownership of
+the file unless you’re the superuser, although you should be
+able to change the group to any of your secondary groups. On
+insecure systems, these restrictions may be relaxed, but this
+is not a portable assumption. On POSIX systems, you can detect
+this condition this way:
+
+ use POSIX qw(sysconf _PC_CHOWN_RESTRICTE­D);
+ $can_chown_giveaway­ = not sysconf(_PC_CHOWN_R­ESTRICTED);
+
+=item chmod LIST
+X<chmod> X<permission> X<mode>
+
+Changes the permissions of a list of files. The first element of the
+list must be the numerical mode, which should probably be an octal
+number, and which definitely should I<not> be a string of octal digits:
+C<0o644> is okay, C<0644> is not. Returns the number of files
+successfully changed.
+
+ $cnt = chmod 0o755, 'foo', 'bar';
+ chmod 0o755, @executables;
+ $mode = '0644'; chmod $mode, 'foo'; # !!! sets mode to --w----r-T
+ $mode = '0o644'; chmod $mode, 'foo'; # this is better
+ $mode = 0o644; chmod $mode, 'foo'; # this is best
+
+=item lstat
+
+Returns a stat buffer. If the lstat succeeds, the stat buffer evaluates
+to true, and additional file tests may be performed on the value. If
+the stat fails, all subsequent tests on the stat buffer also evaluate
+to false.
+
+=item stat
+
+=item IO.stat
+
+Returns a stat buffer. If the lstat succeeds, the stat buffer evaluates
+to true, and additional file tests may be performed on the value. If
+the stat fails, all subsequent tests on the stat buffer also evaluate
+to false.
+
+=head2 IO::POSIX
+
+Indicates that this object can perform standard posix IO
+operations. It implies IO::Readable and IO::Writeable.
+
+=over
+
+=item method IO dup()
+
+=item has Bool $.blocking is rw
+
+=item method Bool flock(:$r,:$­w)
+
+=item method Bool funlock()
+
+=item ...
+
+=back
+
+=head2 IO::File::Windows
+
+role IO::File::Windows does IO::File {
+ method open(Bool :$­BinaryMode) {...}
+}
+
+=item open()
+
+Takes the BinaryMode option to open the file in binary mode.
+
+=head1 Unfiled
+
+=over 4
+
+=item IO.ioctl
+
+Available only as a handle method.
+
+=item alarm
+
+=item prompt
+
+ our Str prompt (Str $prompt)
+
+ Should there be an IO::Interactive role?
+
+=item Str.readpipe
+
+=item sysopen
+
+=item IO.sysseek
+
+=item umask
+
+=back
+
+=head1 Removed functions
+
+=over
+
+=item IO.eof
+
+Gone, see IO::Endable
+
+=item IO.fileno
+
+See IO::FileDescriptor
+
+=item
Well, leaving that rant aside, I'm still tempted to say that times
in Perl 6 are TAI seconds since 2000. Standard TAI would work too.

I've wondered sometimes about the idea of having a dual/moving epoch.
By this, I mean that you have eg. two Ints, one which represents the years
since 1AD or whatever, and the other of which represents the number of seconds
from the beginning of that year. I'm sure many of you can see the advantages
and disadvantages of that scheme better than I can, but I thought I'd throw it
out there so you can all see whether or not you like it.


-------------------­--------------------­--------------------­----------
| Name: Tim Nelson | Because the Creator is, |
| E-mail: wayland@wayland.id.­au | I am |
-------------------­--------------------­--------------------­----------

----BEGIN GEEK CODE BLOCK----
Version 3.12
GCS d+++ s+: a- C++$ U+++$ P+++$ L+++ E- W+ N+ w--- V-
PE(+) Y+>++ PGP->+++ R(+) !tv b++ DI++++ D G+ e++>++++ h! y-
-----END GEEK CODE BLOCK-----

comment 9 answers | Add comment
ORA-00923 Rafael Visser 19:34:06
 Hi.

The following sql runs ok by sqlplus on the server.

===================­====================­====================­====================­====
!more wait_class_ii.sql
with aux as ( select *--ash.event_id
FROM gv$active_session_h­istory ash
where ash.sample_time > SYSDATE - 1/1440)
select evt.wait_class, count(ash.event_id)­
FROM aux ash, gv$event_name evt
where
evt.wait_class in ('User I/O','Network','Sys­tem
I/O','Commit','Othe­r','Application',
'Configuration','Co­ncurrency','Cluster'­,'Administrative')
AND ash.event_id(+) = evt.event_id
GROUP BY evt.wait_class;

@wait_class_ii.sql

WAIT_CLASS
COUNT(ASH.EVENT_ID)­
-------------------­--------------------­--------------------­-----
-------------------­
User I/O
495
Application
0
Network
108
Concurrency
1
Administrative
0
Configuration
0
Cluster
0
Other
169
System I/O
23
Commit
16

10 filas seleccionadas.

===================­====================­====================­====================­====



But, when run the same sql on dbi on a client machine, i receive the
following error:
DBD::Oracle::db prepare failed: ORA-00923: palabra clave FROM no
encontrada donde se esperaba (DBD ERROR: error possibly near <*> in
dicator at char 134 in 'with aux as (SELECT *--ash.event_id FROM
gv$active_session_h­istory ash where ash.sample_time > SYSDATE - 1/
1440)


This is a part of The code


$sth=$dbh->prepare(­"with aux as (SELECT *--ash.event_id FROM
gv\$active_session_­history ash where ash.sample_time > SYSDATE -
1/1440)
SELECT evt.wait_class, count(ash.event_id)­ FROM aux ash,
gv\$event_name evt
where evt.wait_class in ('User I/O','Network','Sys­tem
I/O','Commit','Othe­r','Application',
'Configuration','Co­ncurrency','Cluster'­,'Administrative')
AND ash.event_id(+) = evt.event_id
GROUP BY evt.wait_class
ORDER BY count(ash.event_id)­ DESC ");



Do you know where am i doing wrong?..

SUSE Linux version 2.6.16.60-0.31-xen
Perl Version = 5.008008
DBI Version = 1.605


Thanks in Advance.
rv

comment 4 answer | Add comment
Saturday, 21 February 2009
r25469 - docs/Perl6/Spec Guest 03:04:03
 Author: lwall
Date: 2009-02-21 01:04:02 +0100 (Sat, 21 Feb 2009)
New Revision: 25469

Modified:
docs/Perl6/Spec/S06­-routines.pod
Log:
rm some fossils from quasi


Modified: docs/Perl6/Spec/S06­-routines.pod
===================­====================­====================­========
--- docs/Perl6/Spec/S06­-routines.pod 2009-02-20 23:40:26 UTC (rev 25468)
+++ docs/Perl6/Spec/S06­-routines.pod 2009-02-21 00:04:02 UTC (rev 25469)
@@ -13,9 +13,9 @@

Maintainer: Larry Wall <larry@wall.org>
Date: 21 Mar 2003
- Last Modified: 4 Jan 2009
+ Last Modified: 20 Feb 2009
Number: 6
- Version: 100
+ Version: 101


This document summarizes Apocalypse 6, which covers subroutines and the
@@ -2475,7 +2475,7 @@

return quasi { say "foo" };

-Modifiers to the C<:code> adverb can modify the operation:
+Modifiers to the C<quasi> can modify the operation:

:ast(MyAst) # Default :ast(AST)
:lang(Ruby) # Default :lang($?PARSER)
@@ -2495,7 +2495,7 @@
moose(); # resolves to 'my $x'

If you want to mention symbols from the scope of the macro call, use the
-import syntax as modifiers to C<:code>:
+import syntax as modifiers to C<quasi>:

:COMPILING<$x> # $x always refers to $x in caller's scope
:COMPILING # All free variables fallback to caller's scope

Add comment
Friday, 20 February 2009
r25461 - docs/Perl6/Spec/S32­-setting-library Guest 22:28:27
 Author: autarch
Date: 2009-02-20 21:30:29 +0100 (Fri, 20 Feb 2009)
New Revision: 25461

Modified:
docs/Perl6/Spec/S32­-setting-library/Tem­poral.pod
Log:
Make the Temporal::Time $.second attribute a Num, per TimToady, and do
away with attoseconds entirely.


Modified: docs/Perl6/Spec/S32­-setting-library/Tem­poral.pod
===================­====================­====================­========
--- docs/Perl6/Spec/S32­-setting-library/Tem­poral.pod 2009-02-20 17:20:37 UTC (rev 25460)
+++ docs/Perl6/Spec/S32­-setting-library/Tem­poral.pod 2009-02-20 20:30:29 UTC (rev 25461)
@@ -111,21 +111,14 @@
role Temporal::Time {
my subset Hour of Int where { 0 <= $^a <= 23 };
my subset Minute of Int where { 0 <= $^a <= 59 };
- my subset Second of Int where { 0 <= $^a <= 60 };
- my subset Attosecond of Int where { 0 <= $^a <= 10**18 };
+ my subset Second of Num where { 0 <= $^a <= 60 };

has Hour $.hour = 0;
has Minute $.minute = 0;
has Second $.second = 0;
- # 10^-18 - there's really no point in going any smaller (this
- # is the smallest unit ever measured), but maybe it's better
- # to make $.second a floating point value instead?
- has Attosecond $.attosecond = 0;

- method fractional-second () { self.second / 10**18 }
-
method iso8601 () returns Str
- { [ self.hour, self.minute, self.fractional-second ].join(':') }
+ { [ self.hour, self.minute, self.second ].join(':') }

method Str { self.iso8601() };

@@ -135,8 +128,6 @@
$self.minute <=> $other.minute
||
$self.second <=> $other.second
- ||
- $self.attosecond <=> $other.attosecond;
}
}


Add comment
r25465 - docs/Perl6/Spec Guest 22:28:27
 Author: lwall
Date: 2009-02-20 23:02:13 +0100 (Fri, 20 Feb 2009)
New Revision: 25465

Modified:
docs/Perl6/Spec/S02­-bits.pod
Log:
typo


Modified: docs/Perl6/Spec/S02­-bits.pod
===================­====================­====================­========
--- docs/Perl6/Spec/S02­-bits.pod 2009-02-20 21:59:01 UTC (rev 25464)
+++ docs/Perl6/Spec/S02­-bits.pod 2009-02-20 22:02:13 UTC (rev 25465)
@@ -973,7 +973,7 @@
Capture Function call arguments (right-hand side of a binding)
Blob An undifferentiated mass of bits
Instant A point on the continuous atomic timeline (TAI)
- Duration The differences between two Instants
+ Duration The difference between two Instants

Insofar as Lists are lazy, they're really only partially immutable, in
the sense that the past is fixed but the future is not. The portion of

Add comment
r25462 - docs/Perl6/Spec/S32­-setting-library Guest 22:28:27
 Author: autarch
Date: 2009-02-20 21:33:45 +0100 (Fri, 20 Feb 2009)
New Revision: 25462

Modified:
docs/Perl6/Spec/S32­-setting-library/Tem­poral.pod
Log:
Some formatting tweaks - also remove returns from overloading methods like Str & Num


Modified: docs/Perl6/Spec/S32­-setting-library/Tem­poral.pod
===================­====================­====================­========
--- docs/Perl6/Spec/S32­-setting-library/Tem­poral.pod 2009-02-20 20:30:29 UTC (rev 25461)
+++ docs/Perl6/Spec/S32­-setting-library/Tem­poral.pod 2009-02-20 20:33:45 UTC (rev 25462)
@@ -137,8 +137,8 @@
my subset Offset of Int where { -86400 < $^a < 86400 };

has Offset $.offset;
- has Bool $.isdst;
- has Str $.abbreviation; # CST, AST
+ has Bool $.isdst;
+ has Str $.abbreviation; # CST, AST

# The ISO8601 standard does not allow for offsets with
# sub-minute resolutions. In real-world practice, this is not
@@ -174,15 +174,15 @@
method iso8601 () returns Str
{ self.date.is8601 ~ 'T' ~ self.time.iso8601 ~ self.timezone.iso86­01 }

- method Str return Str { self.iso8601 }
+ method Str { self.iso8601 }

# This involves a whole bunch of code - see Perl 5's
# Time::Local
method epoch returns Num { ... }

- method Int returns Int { self.epoch.truncate­ }
+ method Int { self.epoch.truncate­ }

- method Num returns Num { self.epoch }
+ method Num { self.epoch }
}

=head1 Additions

Add comment
r25464 - docs/Perl6/Spec Guest 22:28:27
 Author: lwall
Date: 2009-02-20 22:59:01 +0100 (Fri, 20 Feb 2009)
New Revision: 25464

Modified:
docs/Perl6/Spec/S02­-bits.pod
Log:
define Instant and Duration as core types representing atomic time


Modified: docs/Perl6/Spec/S02­-bits.pod
===================­====================­====================­========
--- docs/Perl6/Spec/S02­-bits.pod 2009-02-20 21:56:48 UTC (rev 25463)
+++ docs/Perl6/Spec/S02­-bits.pod 2009-02-20 21:59:01 UTC (rev 25464)
@@ -12,9 +12,9 @@

Maintainer: Larry Wall <larry@wall.org>
Date: 10 Aug 2004
- Last Modified: 6 Feb 2009
+ Last Modified: 20 Feb 2009
Number: 2
- Version: 152
+ Version: 153

This document summarizes Apocalypse 2, which covers small-scale
lexical items and typological issues. (These Synopses also contain
@@ -972,6 +972,8 @@
Signature Function parameters (left-hand side of a binding)
Capture Function call arguments (right-hand side of a binding)
Blob An undifferentiated mass of bits
+ Instant A point on the continuous atomic timeline (TAI)
+ Duration The differences between two Instants

Insofar as Lists are lazy, they're really only partially immutable, in
the sense that the past is fixed but the future is not. The portion of
@@ -983,6 +985,21 @@
the degree of laziness/eagerness desired in context. The iterator
API is described in S07.

+C<Instant>s and C<Duration>s are measured in atomic seconds with
+fractions. Notionally they are real numbers which may be implemented
+in either C<Num> or C<Rat> types. (Fixed-point implementations are
+strongly discouraged.) Interfaces that take C<Duration> arguments,
+such as sleep(), may also take C<Num> arguments, but C<Instant>
+arguments must be explicitly created via any of various culturally
+aware time specification APIs that, by and large, are outside the
+CORE of Perl 6, with the possible exception of a constructor taking a
+native TAI value. In numeric context a C<Duration> happily returns a
+C<Num> representing seconds. If pressed for a number, an C<Instant>
+will return the length of time in atomic seconds from the TAI epoch,
+but it will be unhappy about it. Systems which cannot provide
+a steady time base, such as POSIX systems, will simply have to make
+their best guess as to the correct atomic time.
+
=head2 Mutable types

Objects with these types have distinct C<.WHICH> values that do not change

Add comment
More trees and roles Timothy S. Nelson 21:44:14
 On IRC, ruoso wrote:

wayland, one important thing I didn't mention in the mail is that I
understand that if some attribute is going to be undefined for some cases in
a Role, then it doesn't belong in that role, but in a more specialized
one...
the good thing about roles is that they don't require an hierarchy
(which is what makes the Java API so terrible)

One problem (as I mentioned elsewhere just now) is that I'm trying to
specify an API with optional parts. Maybe I should stop using roles for this
:)­.

I'd argue, also that Undefined isn't really undefined, it's really a
value. For example, say you malloc some memory in C, there could be anything
in it; it really *is* undefined. Whereas the Perl 6 "Undefined" value is
guaranteed to always return "Undefined".

I guess it's because I was expecting people using a composition of
Tree to go:

if(! defined($footree.ro­ot)) { warn "Unrooted tree"; }

...instead of

if(! $footree.has('$root­')) { warn "Unrooted tree"; }
# Does this even work???

Or maybe even:

try {
$footree.root;
CATCH {
when /Error: has no attribute named 'root'/ {
warn "Unrooted tree";
}
}
}

...you can see why I prefer the first one :)­.

Anyway, HTH,


-------------------­--------------------­--------------------­----------
| Name: Tim Nelson | Because the Creator is, |
| E-mail: wayland@wayland.id.­au | I am |
-------------------­--------------------­--------------------­----------

----BEGIN GEEK CODE BLOCK----
Version 3.12
GCS d+++ s+: a- C++$ U+++$ P+++$ L+++ E- W+ N+ w--- V-
PE(+) Y+>++ PGP->+++ R(+) !tv b++ DI++++ D G+ e++>++++ h! y-
-----END GEEK CODE BLOCK-----

comment 1 answer | Add comment

Add new topic:

How:  Register )
 
Login:   Password:   
Comments by: Premoderation:
Topic:
  
 
Пожалуйста, относитесь к собеседникам уважительно, не используйте нецензурные слова, не злоупотребляйте заглавными буквами, не публикуйте рекламу и объявления о купле/продаже, а также материалы нарушающие сетевой этикет или законы РФ. Ваш ip-адрес записывается.


QAIX > Perl web-programmingGo to page: « previous | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | next »

see also:
[Installation & Configuration] - Re…
[Security & JAAS/JBoss] - Re: Custom…
[Security & JAAS/JBoss]…
pass tests:
see also:
HERE IS A STORY OF OUR LIVES!!!
THE FIRST TIME I MADE MY SISTER PROUD…
MY SISTER DREAMT SO MUCH ABOUT ME THOSE…

  Copyright © 2001—2010 QAIX
Идея: Монашёв Михаил.
Авторами текстов, изображений и видео, размещённых на этой странице, являются пользователи сайта.
See Help and FAQ in the community support.qaix.com.
Write in the community about the bugs you have noticedbugs.qaix.com.
Write your offers and comments in the communities suggest.qaix.com.
Information for parents.
Пишите нам на .
If you would like to report an abuse of our service, such as a spam message, please .
Если Вы хотите пожаловаться на содержимое этой страницы, пожалуйста .