Str.warn?
I'm about to add Cwarn to S29. Found this in S16: ] =item warn LIST ] ] =item Str.warn ] ] Prints a warning just like Perl 5, except that it is always sent to ] the object in $*DEFERR, which is just standard error ($*ERR). First off, shouldn't that be CObject.warn or something similar? I suppose strings will be the most likely receivers of C.warn calls, but C.print, C.say and C.printf all reside in CObject... Second, is there a heartfelt need for the method form? My first thought upon seeing it was no! why?. There's such a thing as taking OO too far. // Carl
Re: rfc: The values of a junction
On Jan 5, 2:24 pm, d...@dave.whipp.name (Dave Whipp) wrote: Handling all the variations around this (including compound junctions) will be quite tricky to implement, even if we did have introspection for junctions. Incidentally, we'd also need introspection of arrays, to extract the infinite ranges without iterating over them.
Writing to an iterator
I was just reading through S07, and it occurred to me that if one wanted to, one could handle stacks and queues as iterators, rather than by push/pop/shift/unshift of a list. All you'd have to do would be to create a stack or queue class with a private list attribute and methods for reading from and writing to it. The first two parts are easy: has @!list; handles the first, and method prefix:= { .pop } handles the second (well, mostly). How would I define the method for writing to an iterator? -- Jonathan Dataweaver Lang
r24798 - docs/Perl6/Spec
Author: particle Date: 2009-01-07 20:42:33 +0100 (Wed, 07 Jan 2009) New Revision: 24798 Modified: docs/Perl6/Spec/S19-commandline.pod Log: [S19] flesh out most of option reference Modified: docs/Perl6/Spec/S19-commandline.pod === --- docs/Perl6/Spec/S19-commandline.pod 2009-01-07 18:03:45 UTC (rev 24797) +++ docs/Perl6/Spec/S19-commandline.pod 2009-01-07 19:42:33 UTC (rev 24798) @@ -220,15 +220,15 @@ Bool :c($check-syntax), Bool :$doc, :e($execute), -Bool :F($autoloop-split), + :F($autoloop-split), Bool :h($help), :I(@include), -#TODO -M, + :u($use), Bool :n($autoloop-no-print), :O($output-format) = 'exe', :o($output-file) = $*OUT, Bool :p($autoloop-print), - :S(@search-path), +Bool :S($search-path), Bool :T($taint), Bool :v($version), Bool :V($verbose-config), @@ -242,129 +242,105 @@ Turns on autosplit mode. -=item ++ARGSPROC [options, values] ++/ARGSPROC +=item ++CMD --command-line-parser *parser* ++/CMD -{{TODO don't like this name, but don't like ++CMD either}} +Add a command-line processor. When this option is parsed, it immediately +triggers an action that affects or replaces the the command-line parser. +Therefore, it's a good idea to put this option as early as possible in the +argument list. -Add a command-line processor. - -Notes: When this option is parsed, it immediately triggers an action that -could affect the remainder of the parse. Therefore, it's a good idea to put -this option as early as possible in the argument list. - -{{TODO more details needed}} - - =item --check-syntax, -c -Check syntax, then exit. +Check syntax, then exit. Desugars to C-e 'CHECK{ compiles_ok(); exit; }'. -Notes: Desugars to C++COMPILER -e 'CHECK{ compiles_ok(); exit; }' ++/COMPILER - =item --doc -perldoc +Lookup Perl documentation in Pod format. Desugars to +C-e 'CHECK{ compiles_ok(); dump_perldoc(); }'. C$+ARGS contains the +arguments passed to Cperl6, and is available at CCHECK time, so +Cdump_perldoc() can respond to command-line options. -Notes: Desugars to -C++COMPILER -e 'CHECK{ compiles_ok(); dump_perldoc(); }' ++/COMPILER +=item ++DEBUGGER [*switches*, *flags*] ++/DEBUGGER -{{TODO what do i pass to dump_perldoc? C$+ARGS, maybe?}} +Set debugging switches and flags. -=item ++DEBUGGER [switches, flags] ++/DEBUGGER +Note: This is speculative, for lack of a debugger specification. -Set debugging flags. +=item --execute, -e *line* -Notes: At least it's a start. Need a debugger spec for more. - -=item --execute, -e commandline - -Execute a single-line program. Multiple C-e options may be chained together, +Execute a single-line program. Multiple C-e options may be chained together, each one representing an input line with an implicit newline at the end. If you wish to run in lax mode, without strictures and warnings enabled, pass a value of '6' to the first -e on the command line, like C-e6. See LSynopsis 11|S11-modules.pod/Forcing Perl 6 for details. -=item --autoloop-split, -F [string, closure, etc] +=item --autoloop-split, -F *expression* -Pattern to split on (used with -a). Accepts unicode strings (as long as your -shell lets you pass them). Allows passing a closure -(e.g. -F {use Text::CSV}). Awk's not better any more :) +Pattern to split on (used with -a). Substitutes an expression for the default +split function, which is C{split ' '}. Accepts unicode strings (as long as +your shell lets you pass them). Allows passing a closure +(e.g. -F {use Text::CSV}). Awk's not better any more :) -Notes: Substitutes a function for the default function which -is { split ' ' } or whatever. - =item --help, -h -Print summary of options. Desugars to C++CMD --print-help --exit ++/CMD. +Print summary of options. Desugars to C++CMD --print-help --exit ++/CMD. -=item --include, -I +=item --include, -I *directory*[,*directory*[,...]] -Prepend directory to @*INC. +Prepend directories to @*INC, for searching ad hoc libraries. Searching the +standard library follows the policies laid out in LS11-modules. -Notes: this is unspecced elsewhere, so may not survive long. +=item --use, -u *module* -[at best, @*INC will only be the user's ad hoc libraries. The API for -searching the standard lib will not be defined in terms of @*INC so that -we can enforce the standard library policies laid out in S11.] +C--use *module* and C-u *module* desugars to C-e 'use *module*'. +Specify version info and import symbols by appending info to the module name: -=item -m[-]module, -M[-]module, -M[-]'module ...', -[mM][-]module=arg[,arg]... + -u'Sense:ver1.2.1:authcpan:JRANDOM common @horse' -{{TODO needs new or extended syntax}} +You'll need the quotes so your shell doesn't complain about redirection. +There is no special command-line syntax for C'no *module*, use C-e. -use/no module. - =item
r24799 - docs/Perl6/Spec
Author: particle Date: 2009-01-07 20:53:32 +0100 (Wed, 07 Jan 2009) New Revision: 24799 Modified: docs/Perl6/Spec/S19-commandline.pod Log: [S19] describe unchanged syntax Modified: docs/Perl6/Spec/S19-commandline.pod === --- docs/Perl6/Spec/S19-commandline.pod 2009-01-07 19:42:33 UTC (rev 24798) +++ docs/Perl6/Spec/S19-commandline.pod 2009-01-07 19:53:32 UTC (rev 24799) @@ -85,8 +85,36 @@ =head2 Unchanged Syntactic Features -{{TODO short names, clustering, etc}} +Several features have not changed from Perl 5, including: +=over 4 + +=item * + +The most common options have a single-letter short name + +=item * + +Single-letter options may be clustered with the same syntax and semantics + +=item * + +Many command-line options behave similarly, such as + -a # autosplit + -c # check syntax + -e *line*# execute + -F *expression* # specify autosplit value + -h # display help + -I *directory*[,*directory*[,...]] # add include paths + -n # act like awk + -p # act like sed + -S # search PATH for script + -T # Taint mode + -v # display version info + -V # display verbose config info + +=back + =head2 Removed Syntactic Features {{ -jg
Re: returning one or several values from a routine
Jon Lang wrote: I believe that we already have a signature creation operator, namely :( @paramlist ). Yes, sorry, I missed that. ... Regardless, the magic that makes this work would be the ability to assign a flat list of values to a signature. Is this wise? We already have the ability to do that in function calls. I'd like to see exactly the same semantics apply when assigning (or binding) to a signature. So I don't regard it as magic, just a fundamental feature of the language.
r24801 - docs/Perl6/Spec
Author: particle Date: 2009-01-08 02:57:51 +0100 (Thu, 08 Jan 2009) New Revision: 24801 Modified: docs/Perl6/Spec/S19-commandline.pod Log: [S19] preliminary musings on metasyntactic options Modified: docs/Perl6/Spec/S19-commandline.pod === --- docs/Perl6/Spec/S19-commandline.pod 2009-01-07 23:12:41 UTC (rev 24800) +++ docs/Perl6/Spec/S19-commandline.pod 2009-01-08 01:57:51 UTC (rev 24801) @@ -372,53 +372,30 @@ =back -=head1 Run-time System +=head1 Metasyntactic Options -{{TODO total rewrite needed}} +Metasyntactic options are a subset of delimited options used to pass arguments +to an underlying component of Perl. Perl itself does not parse these options, +but makes them available to run-time components via the C%+META-ARGS context +variable. -The run-time system delimited option (C++RTS ... ++/RTS or -C++RTS=string ... ++/RTS=string) allows options to be passed to an underlying -component of Perl. Perl itself does not parse these options, but makes them -available to run-time components. +Standard in Perl 6 are three underlying components, CCMD, CPARSER, +and CDEBUGGER. Implementations may expose other components via this +interface, so consult the documentation for your Perl 6 implementation. -[Note that with my proposed system you can still nest without the artificial =: -++RTS ++GC -generational ++/GC ++/RTS -] +{{TODO more description and examples}} -The C=string variation allows for disabmiguation when the run-time system -also allows the parsing of an option named C++RTS. For example, -Cperl ++RTS=outer -a :b +C --RTS foo bar ++/RTS=outer -makes sure the run-time system receives C-a :b +C --RTS foo bar. + On command line... Subsystem gets... + ++X a -b ++/X a -b -Additionally, some implementations may use this variation to pass arguments -to particular subsystems. For example, Rakudo Perl may choose to implement -Cperl ++RTS=parrot --runcore=gc-debug -t 7 ++/RTS=parrot ++RTS=PGE --disable-keepall --optimize ++/RTS=PGE -to mean C--runcore=gc-debug -t 7 gets passed to parrot, and -C--disable-keepall --optimize gets passed to PGE. + # Nested options + +++X a -b ++X -c ++/X -d e +++/X a -b ++X -c ++/X -d e -[perl ++PARROT --runcore=gc-debug -t 7 ++/PARROT ++PGE --disable-keepall --optimize ++/PGE + # More than once + ++X a -b ++/X -c ++X -d e ++/X a -b -d e + +++X a -b +++/X -c ++X -d e ++/X a -b -d e -{{ -jg -should certain string prefixes or perhaps uppercase strings be reserved -for this purpose? -}} -[doesn't seem very necessary, if we make sure ++ has its own namespace. currently -that namespace is quite barren. we wouldn't even necessarily need to enforce uppercase, -since - -perl ++parrot --runcore=gc-debug -t 7 ++/parrot ++pge --disable-keepall --optimize ++/pge - -is just about as readable, especially if written: - -perl ++parrot --runcore=gc-debug -t 7 ++/parrot \ -++pge --disable-keepall --optimize ++/pge \ -foo bar baz - - -or some such.] - - =head1 Environment Variables Environment variables may be used to the same effect as command-line
r24802 - docs/Perl6/Spec
Author: particle Date: 2009-01-08 03:08:39 +0100 (Thu, 08 Jan 2009) New Revision: 24802 Modified: docs/Perl6/Spec/S19-commandline.pod Log: [S19] fix pod-o Modified: docs/Perl6/Spec/S19-commandline.pod === --- docs/Perl6/Spec/S19-commandline.pod 2009-01-08 01:57:51 UTC (rev 24801) +++ docs/Perl6/Spec/S19-commandline.pod 2009-01-08 02:08:39 UTC (rev 24802) @@ -100,6 +100,7 @@ =item * Many command-line options behave similarly, such as + -a # autosplit -c # check syntax -e *line*# execute
r24803 - docs/Perl6/Spec
Author: particle Date: 2009-01-08 03:19:31 +0100 (Thu, 08 Jan 2009) New Revision: 24803 Modified: docs/Perl6/Spec/S19-commandline.pod Log: [S19] add a sentence on unchanged syntax features, fix some pod formatting errors, and remember to update document metadata Modified: docs/Perl6/Spec/S19-commandline.pod === --- docs/Perl6/Spec/S19-commandline.pod 2009-01-08 02:08:39 UTC (rev 24802) +++ docs/Perl6/Spec/S19-commandline.pod 2009-01-08 02:19:31 UTC (rev 24803) @@ -14,8 +14,8 @@ Maintainer: Jerry Gay jerry@rakudoconsulting.com Date: 12 Dec 2008 - Last Modified: 4 Jan 2009 - Version: 10 + Last Modified: 7 Jan 2009 + Version: 11 This is a draft document. This document describes the command line interface. It has changed extensively from previous versions of Perl in order to increase @@ -99,21 +99,25 @@ =item * -Many command-line options behave similarly, such as +Many command-line options behave similarly, for example: - -a # autosplit - -c # check syntax - -e *line*# execute - -F *expression* # specify autosplit value - -h # display help - -I *directory*[,*directory*[,...]] # add include paths - -n # act like awk - -p # act like sed - -S # search PATH for script - -T # Taint mode - -v # display version info - -V # display verbose config info + Option...Still means... + -a Autosplit + -c Check syntax + -e *line*Execute + -F *expression* Specify autosplit value + -h Display help + -I *directory*[,*directory*[,...]] Add include paths + -n Act like awk + -p Act like sed + -S Search PATH for script + -T Taint mode + -v Display version info + -V Display verbose config info +All of these options have extended syntax, and some may have slightly +different semantics, so see L/Option Reference below for the details. + =back =head2 Removed Syntactic Features @@ -302,7 +306,7 @@ If you wish to run in lax mode, without strictures and warnings enabled, pass a value of '6' to the first -e on the command line, like C-e6. -See LSynopsis 11|S11-modules.pod/Forcing Perl 6 for details. +See LSynopsis 11|S11-modules/Forcing Perl 6 for details. =item --autoloop-split, -F *expression* @@ -318,7 +322,8 @@ =item --include, -I *directory*[,*directory*[,...]] Prepend directories to @*INC, for searching ad hoc libraries. Searching the -standard library follows the policies laid out in LS11-modules. +standard library follows the policies laid out in +LSynopsis 11|S11-modules. =item --use, -u *module* @@ -357,7 +362,7 @@ =item --taint, -T -Turns on taint checking. See LSynopsis 23|S23-security.pod for details. +Turns on taint checking. See LSynopsis 23|S23-security for details. Commits very early. Put this option as early on the command-line as possible. =item --version, -v
Pairs and .pairs
I have some questions about Pair objects. Synopsis 2 currently shows Pairs as being immutable, but there are a few places in the test suite that expect to modify the value component of a Pair, so I'm asking here: (1) If I use .pairs to obtain a list of Pairs from an array or hash, are the values of those Pairs references to the original elements or copies of them? For example, after my @list = (1,2,3); for @list.pairs { .value += 10; } does @list contain 1,2,3 or 11,12,13 ? (2) If I build a Pair using infix:«=», is the value portion of the new pair modifiable -- i.e., can it act as an lvalue? If it can be an lvalue, is it really a reference to the original value? my $x = 12; my $p = (key = $x); $p.value += 10; # valid? If valid, is $x modified? Pm
r24805 - docs/Perl6/Spec
Author: masak Date: 2009-01-08 07:11:11 +0100 (Thu, 08 Jan 2009) New Revision: 24805 Modified: docs/Perl6/Spec/S29-functions.pod Log: [S29] multiple changes: * added Object.warn (to be moved in the next commit to Any) * added invocant colon to Object.perl (to be moved in the next commit to Any) * added `is export` to Object.perl Modified: docs/Perl6/Spec/S29-functions.pod === --- docs/Perl6/Spec/S29-functions.pod 2009-01-08 05:10:02 UTC (rev 24804) +++ docs/Perl6/Spec/S29-functions.pod 2009-01-08 06:11:11 UTC (rev 24805) @@ -199,11 +199,18 @@ =item perl - our Str multi method perl (Object $o) + our Str multi method perl ( Object $o: ) is export Returns a perlish representation of the object, so that calling Ceval on the returned string reproduces the object as accurately as possible. +=item warn + + our multi method warn ( Object $o: ) is export + +Prints a warning to C$*DEFERR, which is usually bound to C$*ERR. See +CSynopsis 16: IPC / IO / Signals for details. + =back =head2 Any
r24806 - docs/Perl6/Spec
Author: masak Date: 2009-01-08 07:15:11 +0100 (Thu, 08 Jan 2009) New Revision: 24806 Modified: docs/Perl6/Spec/S29-functions.pod Log: [S29] moved .perl and .warn from Object to Any. removed Object heading for now. Modified: docs/Perl6/Spec/S29-functions.pod === --- docs/Perl6/Spec/S29-functions.pod 2009-01-08 06:11:11 UTC (rev 24805) +++ docs/Perl6/Spec/S29-functions.pod 2009-01-08 06:15:11 UTC (rev 24806) @@ -190,29 +190,6 @@ =head1 Function Packages -=head2 Object - -Every object conforms to the type CObject. The following methods are thusly -available on every object. - -=over - -=item perl - - our Str multi method perl ( Object $o: ) is export - -Returns a perlish representation of the object, so that calling Ceval -on the returned string reproduces the object as accurately as possible. - -=item warn - - our multi method warn ( Object $o: ) is export - -Prints a warning to C$*DEFERR, which is usually bound to C$*ERR. See -CSynopsis 16: IPC / IO / Signals for details. - -=back - =head2 Any The following are defined in the CAny role: @@ -276,6 +253,20 @@ Returns CTrue if a the invocant an instance of class C$type, or of a subset type or a derived class (through inheritance) of C$type. +=item perl + + our Str multi method perl ( Object $o: ) is export + +Returns a perlish representation of the object, so that calling Ceval +on the returned string reproduces the object as accurately as possible. + +=item warn + + our multi method warn ( Object $o: ) is export + +Prints a warning to C$*DEFERR, which is usually bound to C$*ERR. See +CSynopsis 16: IPC / IO / Signals for details. + =back =head2 Num
r24807 - docs/Perl6/Spec
Author: masak Date: 2009-01-08 07:36:06 +0100 (Thu, 08 Jan 2009) New Revision: 24807 Modified: docs/Perl6/Spec/S29-functions.pod Log: [S29] added slice and hash contextualizers, reordered item and list Modified: docs/Perl6/Spec/S29-functions.pod === --- docs/Perl6/Spec/S29-functions.pod 2009-01-08 06:15:11 UTC (rev 24806) +++ docs/Perl6/Spec/S29-functions.pod 2009-01-08 06:36:06 UTC (rev 24807) @@ -1757,20 +1757,42 @@ also knows its encoding preferences. (These are knowable in the lexical scope via the $?NF and $?ENC compile-time constants).) +=item item + + our Item multi item ( $item ) + +Forces generic Item context on its argument, and returns it. + =item list our List multi list ( *...@list ) Forces List Context on it's arguments, and returns them. +=item slice -=item item + our List multi slice ( *...@list ) - our Item multi item ( $item ) +Forces the argument list to be evaluated in slice context. +(Slices are considered to be potentially multidimensional in Perl 6.) +A list of CCaptures will be transformed into a list of lists. +Equivalent to C@@() (except that empty C@@() means C@@($/), while +empty Cslice() means a null slice). -Forces generic Item context on its argument, and returns it. +=item hash +The Chash contextualizer + our Hash multi hash ( *...@list ) + +Forces the argument list to be evaluated in hash context. +The expression is evaluated in list context (flattening any CCaptures), +then a hash will be created from the list, taken as a list of CPairs. +(Any element in the list that is not a CPair will pretend to be a key +and grab the next value in the list as its value.) Equivalent to +C%() (except that empty C%() means C%($/), while +empty Chash() means an empty hash). + =item :16, :8, :2, :10 our Num multi prefix::16 ( Str $hexstr )