On Sat, Jul 11, 2009 at 22:02, Minimiscience<minimiscie...@gmail.com> wrote: > I tried to find the answers to these in the Synopses, but I couldn't. Plan > B is to ask the mailing list. > > - What does the "first" method/subroutine return when no elements of the > list match? Does it return the empty list? Does the return value count as > undefined/failure?
from http://perlcabal.org/syn/S32/Containers.html grep takes a list or array of values and returns a lazily evaluated list comprised of all of the values from the original list for which the $test smart-matches as true. ... first works exactly like grep but returns only the first matching value. Since grep is defined as returning a list of matching elements and first is defined as being the same as grep, I would say that it returns an empty list if nothing matches. The empty list is one of the false values. > > - What type is the $buf argument to the IO::Readable::read method supposed > to be? Should it be a Buf, and, if so, does the size of the Buf's elements > matter? How would one indicate a desired element size when reading to an > uninitialized Buf? A similar question also applies to IO::Writeable::write. > (Also, "Writable" is misspelled.) from http://perlcabal.org/syn/S32/IO.html#IO%3A%3AReadable 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::Encoded methods. Given that it claims that $buf will will contain plain octets, $buf should be a Buf8. > > - How does one get/set the number/size of elements in a Buf object? No idea, I am not certain it has been defined yet. > > - Exactly what happens if & when a call to open() fails? Is an exception > thrown, and, if so, how does one catch it? The open function does throw an exception, and you catch it with try: #!perl6 use v6; my $fh; try { $fh = open "foo.txt"; CATCH { say "oops, file doesn't exist" } }; say "made it"; > > - How does one declare multiple variables of the same type with a single > "my" statement? Is it "my Int ($x, $y);", "my(Int $x, Int $y);", or > something else? Are the parentheses still necessary when declaring more > than one variable? What about when initializing more than one variable? At least currently, only my Int $x; my Int $y; works. > > - Is there some sort of shortcut (e.g., of the form ".‽method") for calling > a method on an object if the object is defined and returning undef if it is > not defined? I was hoping that ".?method" could do this, but it doesn't > seem to (in Rakudo, at least). Not a clue. > > Thank you in advance, > Minimiscience -- Chas. Owens wonkden.net The most important skill a programmer can have is the ability to read.