[Pdx-pm] Perl 6 Docs and Differences

Michael G Schwern schwern at pobox.com
Fri Oct 3 20:13:18 PDT 2008


Erik Hollensbe wrote:
> It seems like ~~ is a more primitive ocaml match/ruby case, where there is the 
> concept of "match equality" (I'm thinking of the file tests and regexes 
> particularly) that may be different from standard equality. Is that correct? 
> Does ~~ provide a direct syntax for multiple possible matches, or is that 
> expected to be provided by the boolean operators, e.g., to test if a file is 
> a directory or a file:
> 
> $fn ~~ :f | :d # I doubt this is right but I hope this gets the point across
> 
> or is there something more along the lines of:
> 
> match $fn
> with :f
> with :d
> 
> which could potentially express the same thing.

Using given/when you'd write that like:

	given $m {
		when :f | :d {
			...
		}
	}

but I'm not entirely sure how the file test operators work.
See http://perlcabal.org/syn/S03.html#Smart_matching for the full power of ~~.

I do know they're always futzing with ways to eliminate the need for:

if( $foo eq 'bar' or $foo eq 'baz' or $foo eq 'wibble' )


> Another curiosity is the change in how code refs are used in method calls. 
> Does this apply to the soft reference special case as well?
> 
> e.g., perl 5:
> 
> $foo = "bar";
> 
> $self->$foo("something"); # calls $self->bar("something");

I suspect it's supposed to, but it's not implemented.

$ ./perl6 -e 'my $foo = "foo";  $foo("bar")'
invoke() not implemented in class 'Perl6Str'


> Also, unless I'm missing something, the whole concept of soft references seems 
> unaddressed. Are these disappearing entirely? While 99% of the time they are 
> something to avoid, the 1% of the time they're handy... they're really handy.

References appear to have been completely replaced by "Capture objects" which
is news to me.  I'm not going to pretend to know about them, read this.
http://svn.pugscode.org/pugs/docs/Perl6/FAQ/Capture.pod


> Anyways, the progress that's being made and seeing it take shape is a very 
> exciting thing; thanks for linking these documents.

Here is a slightly out of date but more complete set of Perl 6 docs that might
prove more user friendly.
http://search.cpan.org/dist/Perl6-Doc/


-- 
52. Not allowed to yell "Take that Cobra" at the rifle range.
    -- The 213 Things Skippy Is No Longer Allowed To Do In The U.S. Army
           http://skippyslist.com/list/


More information about the Pdx-pm-list mailing list