 |
| Recent blog posts: | |
 |
| They have birthday today: | |
 |
| Forums: | | |
 |
| Discuss: | |
 |
| Recent forum topics: | |
 |
| Recent forum comments: | |
 |
| Модератор: | |
 |
Wednesday, 25 February 2009
|
| Re: Temporal changes Ruud H.G. van Tol 07:15:07 |
| | Martin D Kealey wrote:
Ah, we want a noun that isn't readily confused as an adjective. Suitable terms might include: Instant Jiffy Juncture Moment Occasion Snap Tick ... Once
-- Ruud
|
| | 9 answers | Add comment |
|
| Rules mentioned in specifications, etc Richard Hainsworth 06:51:45 |
| | Here is a list of rules (see below) that are spread around the language design documents, but which lack a home in which they are systematically canonically defined.
I suggest they be added to the new S28 (which is possible if S28 is special-names, not special-variables)
Richard
Where can I find a list of rules that are provided by default? I don't know that a canonical list exists. However, I can tell you what rules PGE provides by default (these came from scraping various versions of the synopses, apocalypses, and exigeses):
<ident> <null> <fail> <upper> <lower> <alpha> <digit> <xdigit> <space> <print> <graph> <blank> <cntrl> <punct> <alnum> <sp> <lt> <gt> <dot> <ws> <wb> <before> <after>
Pm
|
| | 2 answer | Add comment |
|
| r25538 - docs/Perl6/Spec Guest 06:48:09 |
| | Author: wayland Date: 2009-02-25 04:48:08 +0100 (Wed, 25 Feb 2009) New Revision: 25538
Modified: docs/Perl6/Spec/S05-regex.pod Log: Added Predefined Metasyntax section, as per richard++
Modified: docs/Perl6/Spec/S05-regex.pod =================================================================== --- docs/Perl6/Spec/S05-regex.pod 2009-02-25 03:39:17 UTC (rev 25537) +++ docs/Perl6/Spec/S05-regex.pod 2009-02-25 03:48:08 UTC (rev 25538) @@ -1617,6 +1617,60 @@ =back +=head2 Predefined Metasyntax + +The following symbols are predefined entries in the metasyntax. + +=over + +=item * ident + +=item * null + +=item * fail + +=item * upper + +=item * lower + +=item * alpha + +=item * digit + +=item * xdigit + +=item * space + +=item * print + +=item * graph + +=item * blank + +=item * cntrl + +=item * punct + +=item * alnum + +=item * sp + +=item * lt + +=item * gt + +=item * dot + +=item * ws + +=item * wb + +=item * before + +=item * after + +=back + =head1 Backslash reform =over
|
| | Add comment |
|
| Synopsis for Signatures? Jon Lang 04:59:46 |
| | At present, signatures appear to serve at least three rather diverse purposes in Perl 6:
* parameter lists for routines (can also be used to specify what a given routine returns; explored in detail in S06). * variable declaration (see "declarators" in S03). * parametric roles (currently only addressed to any extent in A12; presumably, this will be remedied when S14 is written).
Given that signatures have grown well beyond their origins as subroutine parameter lists, and given that signatures have their own syntax, perhaps they should be moved out of S06? I could see S08 being retasked to address signatures (and perhaps captures, given the intimate connection between these two), since its original purpose (i.e., references) has been deprecated.
-- Jonathan "Dataweaver" Lang
|
| | 2 answer | Add comment |
|
| r25536 - docs/Perl6/Spec Guest 04:58:36 |
| | Author: lwall Date: 2009-02-25 02:58:36 +0100 (Wed, 25 Feb 2009) New Revision: 25536
Modified: docs/Perl6/Spec/S14-roles-and-parametric-types.pod Log: indent examples
Modified: docs/Perl6/Spec/S14-roles-and-parametric-types.pod =================================================================== --- docs/Perl6/Spec/S14-roles-and-parametric-types.pod 2009-02-24 22:42:08 UTC (rev 25535) +++ docs/Perl6/Spec/S14-roles-and-parametric-types.pod 2009-02-25 01:58:36 UTC (rev 25536) @@ -409,27 +409,27 @@ 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.greet(); # Hello -Slovak.new.greet(); # Ahoj -Lolcat.new.greet(); # OH HAI + 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.greet(); # 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.request("yorkshire pudding"); -Slovak.new.request("borovicka"); -Lolcat.new.request("CHEEZEBURGER"); + 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.request("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 @@ -438,27 +438,27 @@ 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) ~ "?"; + role Request[Str $statement] { + method request($object) { say "$statement $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'); + role Request[Str $statement, &transform] { + method request($object) { + say "$statement " ~ transform($object) ~ "?"; + } } -} -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.request("yorkshire pudding"); -Slovak.new.request("borovicka"); -Lolcat.new.request("CHEEZEBURGER"); + 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.request("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 @@ -466,23 +466,23 @@ Role attributes can also be used to initialise attributes: - role AttrParams[$a, $b] { - has $.x = $a; - has $.y = $b; - } + 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" } - } + 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 + 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 + 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
|
| | Add comment |
|
| S14 markup Jon Lang 04:24:01 |
| | Someone should go through the Parametric Roles section and properly indent the code blocks. They're not rendering properly at http://perlcabal.org/syn/S14.html
-- Jonathan "Dataweaver" Lang
|
| | Add comment |
Tuesday, 24 February 2009
|
| min= (from "Rakudo Built-ins Can Now Be Written In Perl 6") David Green 22:23:49 |
| | On 2009-Feb-23, Jonathan Worthington posted to Rakudo.org:
Applied a patch from bacek++ to get "min= and "max=" working ("$foo min= 100" will assign 100 to $foo if it's smaller than what is in $foo). Nice -- except I first read that backwards, i.e. even though it follows straight from the definition of "[op]=", it made me think of forcing a minimum value, which would actually be max=.
I can think of a few ways to deal with this:
1) Get used to it. Maybe document it somewhere to catch fewer people off-guard, but otherwise simply expect people to check their code.
2) Override it by defining an explicit infix:<min=> operator that does max=, and vice versa. People like me will never notice that something fishy is going on, but it penalizes the folks who are actually paying attention to what "min=" ought to mean!
3) Avoid the potential for confusion by having another way to set min/ max values, such as: $foo.min = 100; min($foo) = 100; # lvalue function $foo = get-foo() :min(100); # adverb on =
I'm not crazy about any of those, but that did suggest what is probably a better way to approach it anyway: setting limits at declaration rather than repeating them every time the variable is assigned to:
my $foo is limited(100..200); $foo = 5; # really does $foo = 100
-David
|
| | 6 answers | Add comment |
|
| r25529 - docs/Perl6/Spec Guest 22:23:49 |
| | Author: lwall Date: 2009-02-24 20:58:11 +0100 (Tue, 24 Feb 2009) New Revision: 25529
Modified: docs/Perl6/Spec/S02-bits.pod docs/Perl6/Spec/S06-routines.pod Log: initial whack at describing how settings are snapshotted and how they interact with invocation of MAIN for settings that want to install flow control around the user code.
Modified: docs/Perl6/Spec/S02-bits.pod =================================================================== --- docs/Perl6/Spec/S02-bits.pod 2009-02-24 18:33:56 UTC (rev 25528) +++ docs/Perl6/Spec/S02-bits.pod 2009-02-24 19:58:11 UTC (rev 25529) @@ -1823,7 +1823,12 @@ in which case C<CORE> remains the scope of the standard language, while C<SETTING> represents the scope defining the DSL that functions as the setting of the current file. See also the C<-L>/C<--language> -switch described in L<S19-commandline>. +switch described in L<S19-commandline>. If a setting wishes +to gain control of the main execution, it merely needs to declare +a C<MAIN> routine as documented in S06. In this case the ordinary +execution of the user's code is suppressed; instead, execution +of the user's code is entirely delegated to the setting's C<MAIN> routine, +which calls back to the user's lexically embedded code with C<YOU_ARE_HERE>. Note that, since the C<UNIT> of an eval is the eval string itself, the C<SETTING> of an eval is the language in effect at the point
Modified: docs/Perl6/Spec/S06-routines.pod =================================================================== --- docs/Perl6/Spec/S06-routines.pod 2009-02-24 18:33:56 UTC (rev 25528) +++ docs/Perl6/Spec/S06-routines.pod 2009-02-24 19:58:11 UTC (rev 25529) @@ -15,7 +15,7 @@ Date: 21 Mar 2003 Last Modified: 24 Feb 2009 Number: 6 - Version: 102 + Version: 103 This document summarizes Apocalypse 6, which covers subroutines and the @@ -2370,8 +2370,7 @@ }; You can get the current routine name by calling C<&?ROUTINE.name>. -(The outermost routine at a file-scoped compilation unit is always -named C<&MAIN> in the file's package.) +Outside of any sub declaration, this call returns failure. Note that C<&?ROUTINE> refers to the current single sub, even if it is declared "multi". To redispatch to the entire suite under a given short @@ -2839,6 +2838,34 @@ particular parameter, an attempt will be made to match it as if it had been written C<-a -b -c>. +=head2 Relationship of MAIN routine with lexical setting + +The preceding section describes the use of C<MAIN> in the user's code. +There may also be an implicit C<MAIN> routine supplied by the setting +of the current compilation unit. (The C<-n> and C<-p> command-line +switches are implemented this way.) In this case the user's mainline +code is not automatically executed; instead, execution is controlled +by the setting's C<MAIN> routine. That routine calls C<YOU_ARE_HERE> +at the point where the user's code is to be lexically inserted (in +the abstract). A setting may also call C<YOU_ARE_HERE> outside of +a C<MAIN> routine, in which case it functions as a normal setting, +and the C<YOU_ARE_HERE> merely indicates where the user's code +goes logically. (Or from the compiler's point of view, which the +lexical scope to dump a snapshot of for later use by the compiler +as the setting for a different compilation unit.) In this case the +execution of the user code proceeds as normal. In fact, the C<CORE> +setting ends with a C<YOU_ARE_HERE> to dump the C<CORE> lexical +scope as the standard setting. In this sense, C<CORE> functions as +an ordinary prelude. + +If a C<MAIN> routine is declared both in the setting and in the +user's code, the setting's C<MAIN> functions as the actual mainline +entry point. The user's C<MAIN> functions in an embedded fashion; +the setting's invocation of C<YOU_ARE_HERE> functions as the main +invocation from the point of view of the user's code, and the +user's C<MAIN> routine will be invoked at the end of each call to +C<YOU_ARE_HERE>. + =head2 Implementation note on autothreading of only subs The natural way to implement autothreading for multi subs is to
|
| | Add comment |
|
| r25528 - docs/Perl6/Spec Guest 21:33:56 |
| | Author: rhr Date: 2009-02-24 19:33:56 +0100 (Tue, 24 Feb 2009) New Revision: 25528
Modified: docs/Perl6/Spec/S28-special-variables.pod Log: [S28] we don't have both $*IN and $*STDIN etc.
Modified: docs/Perl6/Spec/S28-special-variables.pod =================================================================== --- docs/Perl6/Spec/S28-special-variables.pod 2009-02-24 18:23:06 UTC (rev 25527) +++ docs/Perl6/Spec/S28-special-variables.pod 2009-02-24 18:33:56 UTC (rev 25528) @@ -80,9 +80,6 @@ ::?ROLE # current role (as package name) $?ROLE # current role (as variable) &?ROUTINE S06 # current sub or method (itself) - $*STDERR S16 # standard error handle; is an IO object - $*STDIN S16 # standard input handle; is an IO object - $*STDOUT S16 # standard output handle; is an IO object $*UID # system user id Note that contextual variables such as C<$*OUT> may have more than
|
| | Add comment |
|
| r25523 - docs/Perl6/Spec Guest 19:02:04 |
| | Author: lwall Date: 2009-02-24 17:02:03 +0100 (Tue, 24 Feb 2009) New Revision: 25523
Modified: docs/Perl6/Spec/S02-bits.pod Log: remove confusing sidenote
Modified: docs/Perl6/Spec/S02-bits.pod =================================================================== --- docs/Perl6/Spec/S02-bits.pod 2009-02-24 12:50:13 UTC (rev 25522) +++ docs/Perl6/Spec/S02-bits.pod 2009-02-24 16:02:03 UTC (rev 25523) @@ -12,9 +12,9 @@ Maintainer: Larry Wall <larry@wall.org> Date: 10 Aug 2004 - Last Modified: 20 Feb 2009 + Last Modified: 24 Feb 2009 Number: 2 - Version: 153 + Version: 154 This document summarizes Apocalypse 2, which covers small-scale lexical items and typological issues. (These Synopses also contain @@ -1416,7 +1416,7 @@ $?foo compiler hint variable $=foo pod variable $<foo> match variable, short for $/{'foo'} - $!foo object attribute private storage (mapped to $foo though) + $!foo object attribute private storage Most variables with twigils are implicitly declared or assumed to be declared in some other scope, and don't need a "my" or "our".
|
| | Add comment |
|
| "$!foo mapped to $foo", say what? Carl M sak 19:00:01 |
| | I read this line in S02, and was distraught:
$!foo object attribute private storage (mapped to $foo though)
I read this as meaning "when you declare $!foo, you will then also be able to refer to it as $foo".
Jonathan Worthington pointed out on #perl6 that S12 says the exact opposite:
has $brain; # also declares $!brain;
So, which of the following is true?
(1) The spec is inconsistent on this point, and should be straightened out. (2) "Mapped to" means the opposite of what I thought, and all is well. (3) The spec actually doesn't contradict itself, but "mapped to" is too imprecise a term to use here.
// Carl
|
| | 1 answer | Add comment |
|
| S28 Richard Hainsworth 14:02:09 |
| | The official Perl6 Documentation site <http://perlcabal.org/syn/> list this document as special-names not special-variables
variables is more constrictive, so suggest a change in name of pod.
pugs-commits@feather.perl6.nl wrote:
Author: wayland Date: 2009-02-23 04:47:22 +0100 (Mon, 23 Feb 2009) New Revision: 25490 Added: docs/Perl6/Spec/S28-special-variables.pod Log: Created the draft spec here. It's very drafty, but no more than some.
|
| | Add comment |
|
| Temporal revisited Dave Rolsky 10:57:06 |
| | After some discussion I made a number of drastic revisions to S32-setting-library/Temporal.pod
What I want to see in Perl 6 is a set of very minimal roles that can be used to provide a simply object from gmtime() and localtime(). These objects should not handle locales, proper Olson timezones, string parsing, user-defined formatting, or math.
They're basically simply little data blobs with some overloading and a few handy methods.
I imagine that a real classes which do math, handle leap seconds, formatting, and so on will _also_ do these roles, but this should be done out of core.
I don't really know Perl 6 all that well, so I'd welcome review, in particular of my Perl 6-isms, and also just of the general concepts.
-dave
/*============================================================ http://VegGuide.org http://blog.urth.org Your guide to all that's veg House Absolute(ly Pointless) ============================================================*/
|
| | 17 answers | Add comment |
|
| r25445 - docs/Perl6/Spec/S32-setting-library Guest 10:07:49 |
| | Author: autarch Date: 2009-02-19 19:14:48 +0100 (Thu, 19 Feb 2009) New Revision: 25445
Modified: docs/Perl6/Spec/S32-setting-library/Temporal.pod Log: This is a very drastic revision (hopefully this won't turn into a revert war ;)
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? ;)
Format specifiers - this could come from locales (CLDR specifies this) or strftime, but again, it's more complicated than is needed
Comparing dates or times to durations - this just doesn't make sense. Is 2009-02-23 greater or less than 5 days?
Any sort of date or time math
Added iso8601 output for every role, and made that the stringification. ISO8601 is unambiguous world-wide, easy to read, and easy to output.
Renamed Temporal::Instant to Temporal::DateTime
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.
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.
Got rid of all mutating operators on everything. The built-ins should be immutable for simplicity.
Added numification overloading for Temporal::DateTime, which gives us comparison for free.
Modified: docs/Perl6/Spec/S32-setting-library/Temporal.pod =================================================================== --- docs/Perl6/Spec/S32-setting-library/Temporal.pod 2009-02-19 17:45:07 UTC (rev 25444) +++ docs/Perl6/Spec/S32-setting-library/Temporal.pod 2009-02-19 18:14:48 UTC (rev 25445) @@ -15,9 +15,10 @@ Moritz Lenz <moritz@faui2k3.org> Tim Nelson <wayland@wayland.id.au> Daniel Ruoso <daniel@ruoso.com> + Dave Rolsky <autarch@urth.org> Date: 19 Mar 2009 extracted from S29-functions.pod and S16-IO.pod Last Modified: 19 Feb 2009 - Version: 1 + Version: 2 The document is a draft. @@ -31,8 +32,7 @@ =item gmtime - our Time multi gmtime ( Time $time? ) - our Time multi method gmtime ( Time $time: ) + our Temporal::DateTime multi gmtime ( Num $epoch? = time() ) Identical to: @@ -40,179 +40,160 @@ =item localtime - our Time multi localtime ( Time $time?, Time::Zone $tz? ) - our Time multi method localtime ( Time $time: Time::Zone $tz? ) + our Temporal::DateTime multi localtime ( Num $epoch? = time() ) -Returns a time object whose default timezone is C<$tz> (or the system's -default timezone if none is provided). +These functions take an epoch value and return a C<Temporal::DateTime> +object. For C<localtime> the time zone is taken from the local +system. For C<gmtime> the time zone is aways UTC. -If used as a function, and no time is provided, the current time is used. +If no time is provided, the current time is used. -Note that no matter what, C<$time>'s concept of "its timezone" is discarded -in favor of something new. - =item time - our Time multi time() + our Num time() -Returns a C<Time> object. There are a number of uses for this -object, all of which can be found in the documentation for C<Time>. +Returns an epoch value for the current time. -There is, by default, no timezone associated with this Time object, so -whatever default the system has will take over if timezone-specific -data is accessed. - =back =head1 Roles +The intent behind these classes is to provide an absolutely minimal, +but still useful, set of core behavior. The assumption is that the +core will ship with a simple set of classes so that C<gmtime> and +C<localtime> have something to return. + =head2 Temporal::Date -You probably want to use the Temporal::Instant object instead. +You probably want to use the Temporal::DateTime object instead. role Temporal::Date { - has Int $.year; - has Int $.month; - has Int $.day; # Day of month - has Int $.dayofweek; - has Int $.era; # BC, AD, etc, depending on locale - has Str $.defaultformat; # A CLDR-formatted string, for use with toString(); + my subset Month of Int where { 1 <= $^a <= 12 }; + my subset Day of Int where { 1 <= $^a <= 31 }; + my subset DayOfWeek of Int where { 1 <= $^a <= 7 }; - method toString($format => $.defaultformat); + has Int $.year; + has Month $.month = 1; + has Day $.day = 1; - multi method Temporal::Instant infix:<+>(Temporal: ate $self, Temporal::Time $other); - multi method Temporal::Instant infix:<+>(Temporal: ate $self, Temporal::Duration $other); + # This can be cached internally, but it's a calculated value, + # not an attribute. + method day-of-week () returns DayOfWeek; - multi method infix:{'<=>'}(Temporal::Date $self, Temporal::Date $other); - multi method infix:{'<=>'}(Temporal::Date $self, Temporal::Duration $other); -} + # These always return the long English names + method month-name () returns Str; # "January" + method day-name () returns Str; # "Tuesday" -Example: + # returns the date formatted in ISO8601 style - 2008-01-25 + method iso8601 () returns Str + { [ self.year, self.month, self.date ].join('-') }; -$date = new Date('2002/01/01'); -$date.month.name(); # January -$date.month.name('short'); # Jan + method infix:{'~'} return Str { self.iso8601 }; -$format will naturally need to allow for eras. + multi method infix:{'<=>'} (Temporal::Date $self, Temporal::Date $other) { + $self.year <=> $other.year + || + $self.month <=> $other.month + || + $self.day <=> $other.day; + } +} -=over +Example: -=item +$date = Date.new( :year(2008), :month(1), :day(25) ); +$date.month(); # 1 - method toString($format = 'YYYY/MM/DD'); - -$format contains things like YYYY/MM/DD or whatever. - -=back - =head2 Temporal::Time -You probably want to use the Temporal::Instant object instead. +You probably want to use the Temporal::DateTime object instead. role Temporal::Time { - has $.hour; - has $.minute; - has $.second; + 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 }; - method toString($format?); - # This can't be right; how do we specify this - multi method infix:{'<=>'}(Temporal::Time $self, Temporal::Time $other); - multi method infix:{'<=>'}(Temporal::Time $self, Temporal::Duration $other); -} + 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; -When created, recognises "today" as a possibility. + method fractional-second () { self.second / 10**18 } -role Temporal::Timezone { - has $.number; + method iso8601 () returns Str + { [ self.hour, self.minute, self.fractional-second ].join(':') } - method name($format); - method is_dst(); -} + method Str returns Str { self.iso8601() }; -role Temporal::Subsecond { - has $.nanosecond; + multi method infix:{'<=>'} (Temporal::Time $self, Temporal::Time $other) { + $self.hour <=> $other.hour + || + $self.minute <=> $other.minute + || + $self.second <=> $other.second + || + $self.attosecond <=> $other.attosecond; + } } -=head1 Classes +=head2 Temporal::TimeZone::Observance -=head2 Temporal::Timezone +role Temporal::TimeZone::Observance { + my subset Offset of Int where { -86400 < $^a < 86400 }; -=head2 Temporal::Instant + has Offset $.offset; + has Bool $.isdst; + has Str $.abbreviation; # CST, AST -class Temporal::Instant - does Temporal::Date - does Temporal::Time - does Temporal::Timezone - does Temporal::Subsecond -{ - has $.locale; - has $.parser; - has $.formatter; # Only for output formats + # 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 { + my $hours = self.offset.abs / 3600; + my $minutes = self.offset.abs % 3600; - multi method Temporal::Instant infix:<+>(Temporal::Instant $self, Duration $other); + return self.offset < 0 ?? '-' :: '+' + ~ $hours.fmt('%02d') + ~ $minutes.truncate.fmt('%02d'); + } - multi method infix:<->(Temporal::Instant $self, Duration $other); - multi method infix:<->(Temporal::Instant $self, Duration $other); - - multi method infix:{'<=>'}(Temporal::Instant $self, Temporal::Instant $other); - multi method infix:{'<=>'}(Temporal::Instant $self, Duration $other); - - method new(:$String); - method truncate(Str $to); - method last(Str $type, Str $of); - method toString($format?); + method Str returns Str { self.iso8601 } } -All formats are CLDR, although implementations may want to have another set of functions -that use the strftime functions instead. +This is called an I<observance> because it represents the state of a +time zone for a given instant. A real Temporal::TimeZone role would +return an observance when given a particular datetime. -=over +We don't specify a proper C<Temporal::TimeZone> role because time +zones are messy and complex. The system libraries are able to give us +sufficient information to create an observance for a time, but are not +able to give us proper time zone information. -=item new +=head2 Temporal::DateTime - method new(Str String) # parser defaults to 'strptime' or something similar - | (Str $parser, Str $String) # $parser = 'strptime' - | (Str $parser, Int $Epoch) # $parser = 'epoch' - | (Str $parser, Str $Timezone?) # $parser = 'today' [unless strptime does this] - ; +role Temporal::DateTime { + has Temporal::Date $!date handles <year month day day-of-week>; + has Temporal::Time $!time handles <hour minute second fractional-second>; + has Temporal::TimeZone::Observance $!timezone handles <offset isdst>; -Tries to parse the date and time specified using $parser. + method iso8601 () returns Str + { self.date.is8601 ~ 'T' ~ self.time.iso8601 ~ self.timezone.iso8601 } -If $Epoch is passed in instead, then it interprets the time as being in seconds since the -epoch (which is determined on a system-by-system basis). + method Str return Str { self.iso8601 } -If $parser is 'today', then the current time is gotten. Timezone would be useful for -simulating eg. gmtime(). + # This involves a whole bunch of code - see Perl 5's + # Time::Local + method epoch returns Num { ... } -=item truncate + method Int returns Int { self.epoch.truncate } -Can be used to truncate a function to the current day, or whatever. - -=item last - - $date.last('day', of => 'month'); - -=back - -=head2 Temporal::Duration - -class Temporal::Duration - does Temporal::Date - does Temporal::Time - does Temporal::Subsecond -{ + method Num returns Num { self.epoch } } -=head2 Temporal::Recurring - -This class specifies when a repetitive action (eg. a cron job) happens. - -class Temporal::Recurring { -... -} - -Should allow creation from the format that cron uses (ie. */5 * * * * ). - =head1 Additions Please post errors and feedback to perl6-language. If you are making
|
| | 10 answers | Add comment |
|
| r25518 - docs/Perl6/Spec Guest 08:13:28 |
| | Author: lwall Date: 2009-02-24 06:13:28 +0100 (Tue, 24 Feb 2009) New Revision: 25518
Modified: docs/Perl6/Spec/S28-special-variables.pod Log: redelete fossil
Modified: docs/Perl6/Spec/S28-special-variables.pod =================================================================== --- docs/Perl6/Spec/S28-special-variables.pod 2009-02-24 05:10:35 UTC (rev 25517) +++ docs/Perl6/Spec/S28-special-variables.pod 2009-02-24 05:13:28 UTC (rev 25518) @@ -23,9 +23,6 @@ Perl 5 variable(s). The list of main entries is also followed by a table showing the 5 and 6 variables side-by-side. -Most/All variables of the form $*SOMETHING should also work in the form -$SOMETHING (without the '*') unless masked by "my $SOMETHING". - =head1 Overview =head2 Secondary Sigils (also known as "twigils"):
|
| | Add comment |
|
| r25517 - docs/Perl6/Spec Guest 08:10:36 |
| | Author: wayland Date: 2009-02-24 06:10:35 +0100 (Tue, 24 Feb 2009) New Revision: 25517
Modified: docs/Perl6/Spec/S28-special-variables.pod Log: - Made twigils short (see S02 for full doco). - Rearranged main variable list
Modified: docs/Perl6/Spec/S28-special-variables.pod =================================================================== --- docs/Perl6/Spec/S28-special-variables.pod 2009-02-24 05:04:42 UTC (rev 25516) +++ docs/Perl6/Spec/S28-special-variables.pod 2009-02-24 05:10:35 UTC (rev 25517) @@ -9,7 +9,7 @@ Contributions: Tim Nelson <wayland@wayland.id.au> Date: 23 Feb 2009, created from miscellaneous documents lying around Last Modified: 23 Feb 2009 - Version: 2 + Version: 3 =head1 Introduction @@ -23,66 +23,78 @@ Perl 5 variable(s). The list of main entries is also followed by a table showing the 5 and 6 variables side-by-side. +Most/All variables of the form $*SOMETHING should also work in the form +$SOMETHING (without the '*') unless masked by "my $SOMETHING". + =head1 Overview =head2 Secondary Sigils (also known as "twigils"): - $? # constants (variable only at compile time, see S02) - $* # context variables and globals (run time, see S02) - $= # pod documents, file-scoped (see S02) - $^ # self-declaring block positional parameter (see S06 placeholder variables) - $: # self-declaring block named parameter (see S06 placeholder variables) - $< # current $/ scope (see S02) - $. # public attribute accessor (see S12 attributes) - $! # private attribute storage (see S12 attributes) +A quick reminder of the relevant twigils: + $?foo # Lexically-scoped (compile time, see S02) + $*foo # Contextualiseable Global variable (run time, see S02) + $=foo # File-scoped (see S02) +XXX Something else claimed that $=foo was a POD variable; Larry says it's not +well-defined, yet, and we're waiting on Damian to write S26 before we'll know what's going +on XXX + =head2 Named variables (see S02): - $/ # match object from last match (see S05) - $0 # first captured value from match: $/[0] - @*ARGS # command-line arguments - &?BLOCK # current block (itself, see S06) - @?BLOCK # current blocks (themselves, see S06) - ::?CLASS # current class (as package name) - $?CLASS # current class (as variable) - @?CLASS # current classes - %?CONFIG # configuration hash - $=DATA # data block handle (=begin DATA ... =end) - $*EGID # effective group id - %*ENV # system environment - $*ERR # standard error handle (see S16) - $*EUID # effective user id - $*EXECUTABLE_NAME # executable name - $?FILE # current filename of source file - $?GRAMMAR # current grammar - @?GRAMMAR # current grammars - $*GID # group id - $*IN # standard input handle (see S16) - $?LABEL # label of current block - @?LABEL # labels of current blocks - $?LINE # current line number in source file - $?MODULE # current module - @?MODULE # current modules - $?OS # operating system compiled for - $*OS # operating system running under - $?OSVER # operating system version compiled for - $*OSVER # operating system version running under - $*OUT # standard output handle (see S16) - $?PACKAGE # current package (as object) - @?PACKAGE # current packages - $?PACKAGENAME # name of current package (see S10) - $?PERLVER # perl version compiled for - $*PERLVER # perl version running under - $*PROGRAM_NAME # name of the program being executed - $*PID # system process id - ::?ROLE # current role (as package name) - $?ROLE # current role (as variable) - @?ROLE # current roles - &?ROUTINE # current sub or method (itself, see S06) - @?ROUTINE # current subs or methods (themselves) - $*UID # system user id + Variable Spec Description + -------- ---- ----------- + $/ S05 # match object from last match + $0, $1, $2 S05 # first captured value from match: $/[0] + @*ARGS S06 # command-line arguments + &?BLOCK S06 # current block (itself) + @?BLOCK S06 # current blocks (themselves) + ::?CLASS # current class (as package name) + $?CLASS # current class (as variable) + @?CLASS # current classes + %?CONFIG # configuration hash + $=DATA # data block handle (=begin DATA ... =end) + $*EGID # effective group id + %*ENV # system environment + $*ERR S16 # Standard error handle; is an IO object + $*EUID # effective user id + $*EXECUTABLE_NAME # executable name + $?FILE # current filename of source file + $?GRAMMAR # current grammar + @?GRAMMAR # current grammars + $*GID # group id + $*IN S16 # Standard input handle; is an IO object + $?LABEL # label of current block + @?LABEL # labels of current blocks + $?LINE # current line number in source file + $?MODULE # current module + @?MODULE # current modules + %*OPTS S19 # Options from command line + %*OPT... S19 # Options from command line to be passed down + %*OPTS S19 # Options from command line + %*OPT... S19 # Options from command line to be passed down + $?OS # operating system compiled for + $*OS # operating system running under + $?OSVER # operating system version compiled for + $*OSVER # operating system version running under + $*OUT S16 # Standard output handle; is an IO object + $?PACKAGE # current package (as object) + @?PACKAGE # current packages + $?PACKAGENAME S10 # name of current package + $?PERLVER # perl version compiled for + $*PERLVER # perl version running under + $*PROGRAM_NAME # name of the program being executed + $*PID # system process id + ::?ROLE # current role (as package name) + $?ROLE # current role (as variable) + @?ROLE # current roles + &?ROUTINE S06 # current sub or method (itself) + @?ROUTINE # current subs or methods (themselves) + $*STDERR S16 # standard error handle; is an IO object + $*STDIN S16 # standard input handle; is an IO object + $*STDOUT S16 # standard output handle; is an IO object + $*UID # system user id Note that contextual variables such as C<$*OUT> may have more than one current definition in the outer dynamic context, in which case
|
| | Add comment |
|
| r25516 - docs/Perl6/Spec/S32-setting-library Guest 08:04:43 |
| | Author: lwall Date: 2009-02-24 06:04:42 +0100 (Tue, 24 Feb 2009) New Revision: 25516
Modified: docs/Perl6/Spec/S32-setting-library/Any.pod docs/Perl6/Spec/S32-setting-library/IO.pod Log: more DEF extermination
Modified: docs/Perl6/Spec/S32-setting-library/Any.pod =================================================================== --- docs/Perl6/Spec/S32-setting-library/Any.pod 2009-02-24 04:57:59 UTC (rev 25515) +++ docs/Perl6/Spec/S32-setting-library/Any.pod 2009-02-24 05:04:42 UTC (rev 25516) @@ -98,7 +98,7 @@ our multi method warn ( Object $o: ) is export -Prints a warning to C<$*DEFERR>, which is usually bound to C<$*ERR>. See +Prints a warning to C<$*ERR>, which is usually finds C<$PROCESS::ERR>. See C<Synopsis 16: IPC / IO / Signals> for details. =back
Modified: docs/Perl6/Spec/S32-setting-library/IO.pod =================================================================== --- docs/Perl6/Spec/S32-setting-library/IO.pod 2009-02-24 04:57:59 UTC (rev 25515) +++ docs/Perl6/Spec/S32-setting-library/IO.pod 2009-02-24 05:04:42 UTC (rev 25516) @@ -322,9 +322,9 @@ 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. +If these are called in their non-object form, they operate on C<$*OUT>, except in the +case of warn(), which operates on C<$*ERR>. The form with leading dot prints C<$_> to +the appropriate handle unless C<$_> happens to be a filehandle. =over @@ -409,7 +409,7 @@ =item our Bool multi printf (Str $fmt, *@LIST) -The function form works as in Perl 5 and always prints to $*DEFOUT. +The function form works as in Perl 5 and always prints to $*OUT. The method form uses IO handles, not formats, as objects. =back
|
| | Add comment |
|
| r25515 - docs/Perl6/Spec/S32-setting-library Guest 07:57:59 |
| | Author: wayland Date: 2009-02-24 05:57:59 +0100 (Tue, 24 Feb 2009) New Revision: 25515
Modified: docs/Perl6/Spec/S32-setting-library/IO.pod Log: Added some things taken from the S28 sources.
Modified: docs/Perl6/Spec/S32-setting-library/IO.pod =================================================================== --- docs/Perl6/Spec/S32-setting-library/IO.pod 2009-02-24 04:56:48 UTC (rev 25514) +++ docs/Perl6/Spec/S32-setting-library/IO.pod 2009-02-24 04:57:59 UTC (rev 25515) @@ -190,6 +190,21 @@ Forces this object to keep its buffers empty +If set to nonzero, forces a flush right away and after every write +or print on the currently selected output channel. +Default is 0 (regardless of whether the channel is really buffered +by the system or not; +$OUT_FH.autoflush tells you only whether you've asked Perl +explicitly to flush after each write). +$*OUT will typically be line buffered if output is to the +terminal and block buffered otherwise. +Setting this variable is useful primarily when you are +outputting to a pipe or socket, +such as when you are running a Perl program under rsh +and want to see the output as it's happening. +This has no effect on input buffering. + + =back =head2 IO::Streamable @@ -246,10 +261,32 @@ =over +=item method Int input_record_count() + +Returns a count of the number of records (lines?) that have been input. +Now with cleaned-up localization usage. + =item method Str input_record_separator() is rw This regulates how "readline" behaves. +The input record separator, newline by default. +This influences Perl's idea of what a ``line'' is. +Works like awk's RS variable, including treating empty lines +as a terminator if set to the null string. +(An empty line cannot contain any spaces or tabs.) +You may set it to a multi-character string to match a multi-character +terminator, or to undef to read through the end of file. +Setting it to "\n\n" means something slightly different +than setting to "", if the file contains consecutive empty lines. +Setting to "" will treat two or more consecutive empty lines +as a single empty line. Setting to "\n\n" will blindly assume +that the next input character belongs to the next paragraph, +even if it's a newline. + +Remember: the value of input_record_separator is a string, not a regex. +awk has to be better for something. + =item method Str input_field_separator() is rw This regulates how "readfield" behaves. @@ -291,6 +328,10 @@ =over +=item method Int output_record_count() + +Returns a count of the number of records (lines?) that have been output. + =item method Str output_record_separator() is rw This regulates how say and print(%hash) behaves.
|
| | Add comment |
|
| r25514 - docs/Perl6/Spec Guest 07:56:48 |
| | Author: wayland Date: 2009-02-24 05:56:48 +0100 (Tue, 24 Feb 2009) New Revision: 25514
Modified: docs/Perl6/Spec/S19-commandline.pod Log: Added a note about @*ARGS
Modified: docs/Perl6/Spec/S19-commandline.pod =================================================================== --- docs/Perl6/Spec/S19-commandline.pod 2009-02-24 04:36:33 UTC (rev 25513) +++ docs/Perl6/Spec/S19-commandline.pod 2009-02-24 04:56:48 UTC (rev 25514) @@ -353,7 +353,10 @@ =back +=head2 Remaining arguments +Any remaining arguments to the Perl6 program are placed in the @*ARGS array. + =head1 Option Reference Perl 6 options, descriptions, and services.
|
| | Add comment |
|
| r25509 - in docs/Perl6/Spec: . S32-setting-library Guest 03:53:45 |
| | Author: wayland Date: 2009-02-24 01:53:45 +0100 (Tue, 24 Feb 2009) New Revision: 25509
Modified: docs/Perl6/Spec/S16-io.pod docs/Perl6/Spec/S32-setting-library/IO.pod Log: S16: Referred to other documents IO.pod: Got rid of filetest pragma
Modified: docs/Perl6/Spec/S16-io.pod =================================================================== --- docs/Perl6/Spec/S16-io.pod 2009-02-24 00:44:29 UTC (rev 25508) +++ docs/Perl6/Spec/S16-io.pod 2009-02-24 00:53:45 UTC (rev 25509) @@ -41,6 +41,12 @@ 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 and Classes + +The roles and classes that define most of the functionality for IO are defined in +S32-setting-library/IO.pod. The main functions used are listed in S29 with references to +S32-setting-library/IO.pod. + =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-24 00:44:29 UTC (rev 25508) +++ docs/Perl6/Spec/S32-setting-library/IO.pod 2009-02-24 00:53:45 UTC (rev 25509) @@ -592,29 +592,28 @@ :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. +C<:w>, C<:W>, C<:x>, and C<:X> is by default based on: +=over + +=item * The mode of the file and the uids and gids of the user + +=item * ACLs (access control lists) + +=item * read-only filesystems + +=back + +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 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%)
|
| | Add comment |
|
| r25507 - docs/Perl6/Spec Guest 03:42:31 |
| | Author: wayland Date: 2009-02-24 01:42:31 +0100 (Tue, 24 Feb 2009) New Revision: 25507
Added: docs/Perl6/Spec/S31-pragmatic-modules.pod Log: S31: Collected the pragmata from everywhere, and listed them here with cross-references
Added: docs/Perl6/Spec/S31-pragmatic-modules.pod =================================================================== --- docs/Perl6/Spec/S31-pragmatic-modules.pod (rev 0) +++ docs/Perl6/Spec/S31-pragmatic-modules.pod 2009-02-24 00:42:31 UTC (rev 25507) @@ -0,0 +1,77 @@ +=encoding utf8 + +=head1 Title + +[DRAFT] Synopsis 31: Pragmatic Modules + +=head1 Version + + Author: Tim Nelson <wayland@wayland.id.au> + Maintainer: Larry Wall <larry@wall.org> + Contributions: + Date: 24 Feb 2009 + Last Modified: 24 Feb 2009 + Version: 1 + +The document is a draft. + +If you read the HTML version, it is generated from the pod in the pugs +repository under /docs/Perl6/Spec/S31-pragmatic-modules.pod so edit it there in +the SVN repository if you would like to make changes. + +=head1 Overview + +It is a general policy in Perl6 that any pragma designed to influence +the surface behavior of a keyword is identical to the keyword itself, unless +there is good reason to do otherwise. On the other hand, pragmas designed +to influence deep semantics should not be named identically, though of +course some similarity is good. + +All floating point IEEE modes must be lexically available via pragma except in cases +where that would entail heroic efforts to bypass a braindead platform. + +XXX FIX: I (Tim Nelson) have no clue as to what the above entails, so the spec does not +reflect this XXX + +=head1 Pragmata + +=over + +=item use autoindex -- see S09-data.pod + +=item use bytes -- see S05-regex.pod + +=item use chars -- see S05-regex.pod + +=item use codes -- see S05-regex.pod + +=item use graphs -- see S05-regex.pod + +=item use m :foo -- see S05-regex.pod + +=item use MONKEY_PATCHING -- see S12-objects.pod + +=item use PDL -- see S09-data.pod + +=item use regex :foo -- see S05-regex.pod + +=item use rule :foo -- see S05-regex.pod + +=item use rx :foo -- see S05-regex.pod + +=item use s :foo -- see S05-regex.pod + +=item use self -- see S06-routines.pod + +=item use token :foo -- see S05-regex.pod + +=item use oo :closed :final -- see S12-objects.pod + +=back + +=head1 Additions + +Please post errors and feedback to perl6-language. If you are making +a general laundry list, please separate messages by topic. + +
|
| | Add comment |
|
|