Re: easier duck typing in .can
Yuval Kogman wrote: Since CANDO is a multimethod, IMHO this can be safely extended to allow: $object.can(Class); $object.can(Role); to better support duck typing. Why would you not use .does or .isa there? Are you wanting this to go through all of the Class/Role's methods and check that the $object.can() them? I think that perhaps .can($Method) (where $Method.isa(Meta::Method)) would be acceptable, then .can(Role) can either be defined to be .can(all(Role.get_methods)), or we just leave the user to use that snippet - after all, such extreme duck typing is expensive and shouldn't be huffmanised overly IMHO. We want people to use the Role objects unless they have a really good reason, and besides you can always just wrap things up in a Facade if you have to. Sam.
[perl #38146] [TODO] OS.pmc - file copy 38146
Hi, I am trying implement #38146 todo item. While looking at the code for os.pmc there are IFDEF constructs defined for different operating systems (For e.g. WIN32 for now). I am just wonedring if it would make sense to seperate out code for each supported operating system under a directory structure. At the time of build the specific code for target operating system is added to the source tree. This very similar to the Linux source tree where the architecture specific code is implemented in a differen directory structure and correct directory structure is selected based on the architecture you are compiling for. There a couple of benifits that come to mind: 1. All the OS specific is maintained under seperated directory structure for each OS. 2. Defines a clean seperation b/w OS and Parrot Code. 3. Makes it easy to port Parrot to new platforms without breaking the implemented functionality for other platforms. Let me know what your thoguths are. Thanks, Vishal
Conditionally included list elements
Hi all, one construct that keeps infuriating me in Perl 5 is when I’m spelling out an explicit list where I want to include particular elements only under certain circumstances, ie. $foo, $bar, $baz, $quux but $baz should only be part of the list when $wibble is true. In Perl 5, I can express this using one of two ways: the Looks Like Java way and the Looks Like Linenoise way. my @list = ( $foo, $bar ); push @list, $baz if $wibble; push @list, $quux; @list # or $foo, $bar, ( $wibble ? $baz : () ), $quux There are other ways too, but all of them are either worse or colossally worse. Is there a construct in Perl 6 to express this more immediately? Something along the lines of the following would seem ideal: $foo, $bar, ( $baz if $wibble ), $quux Regards, -- #Aristotle *AUTOLOAD=*_;sub _{s/(.*)::(.*)/print$2,(,$\/, )[defined wantarray]/e;$1}; Just-another-Perl-hacker;
Re: easier duck typing in .can
On Sun, Jun 18, 2006 at 18:08:00 +1200, Sam Vilain wrote: Why would you not use .does or .isa there? Are you wanting this to go through all of the Class/Role's methods and check that the $object.can() them? Because if you don't control $object's class you can't change it. -- Yuval Kogman [EMAIL PROTECTED] http://nothingmuch.woobling.org 0xEBD27418 pgpO42QaY5S9n.pgp Description: PGP signature
Re: Conditionally included list elements
A. Pagaltzis skribis 2006-06-18 10:28 (+0200): $foo, $bar, ( $wibble ? $baz : () ), $quux Is there a construct in Perl 6 to express this more immediately? Something along the lines of the following would seem ideal: $foo, $bar, ( $baz if $wibble ), $quux pugs my @foo = 1, 2, 3, { 4 if 0 }.(), 5; say @foo.perl [1, 2, 3, 5] bool::true pugs my @foo = 1, 2, 3, { 4 if 1 }.(), 5; say @foo.perl [1, 2, 3, 4, 5] bool::true Though I have no idea if this is intended behaviour. It differs from Perl 5, and I couldn't find any spec detailing the change. Juerd -- http://convolution.nl/maak_juerd_blij.html http://convolution.nl/make_juerd_happy.html http://convolution.nl/gajigu_juerd_n.html
Re: Conditionally included list elements
* Juerd [EMAIL PROTECTED] [2006-06-18 14:10]: pugs my @foo = 1, 2, 3, { 4 if 0 }.(), 5; say @foo.perl [1, 2, 3, 5] bool::true pugs my @foo = 1, 2, 3, { 4 if 1 }.(), 5; say @foo.perl [1, 2, 3, 4, 5] bool::true That’s “conceptually noisy” though… I don’t know if I’d end up picking $foo, $bar, { $baz if $wibble }.(), $quux over $foo, $bar, ( $wibble ?? $baz !! () ), $quux With more complex “movable parts,” there would be even less difference between the two than here. Does Perl 6 have `do BLOCK` like Perl 5? That would make it $foo, $bar, do { $baz if $wibble }, $quux which I find more acceptable. Regards, -- #Aristotle *AUTOLOAD=*_;sub _{s/(.*)::(.*)/print$2,(,$\/, )[defined wantarray]/e;$1}; Just-another-Perl-hacker;
Re: Conditionally included list elements
On 6/18/06, A. Pagaltzis [EMAIL PROTECTED] wrote: Is there a construct in Perl 6 to express this more immediately? Something along the lines of the following would seem ideal: $foo, $bar, ( $baz if $wibble ), $quux How about this: pugs sub infix:pv($x, $cond) { $cond ?? ($x,) !! () }; say 1, 2, (3 pv 1), 4 1234 bool::true pugs sub infix:pv($x, $cond) { $cond ?? ($x,) !! () }; say 1, 2, (3 pv 0), 4 124 bool::true I couldn't think of a good name for the new operator, though. Stuart
Re: Conditionally included list elements
A. Pagaltzis skribis 2006-06-18 14:40 (+0200): Does Perl 6 have `do BLOCK` like Perl 5? That would make it $foo, $bar, do { $baz if $wibble }, $quux pugs 1, 2, do { 3 if 0 }, 4 (1, 2, 4) pugs 1, 2, do { 3 if 1 }, 4 (1, 2, 3, 4) Again I have no idea if this empty list is SUPPOSED to happen. Juerd -- http://convolution.nl/maak_juerd_blij.html http://convolution.nl/make_juerd_happy.html http://convolution.nl/gajigu_juerd_n.html
Re: Conditionally included list elements
Stuart Cook skribis 2006-06-18 22:59 (+1000): pugs sub infix:pv($x, $cond) { $cond ?? ($x,) !! () }; say 1, 2, (3 pv 1), 4 1234 bool::true pugs sub infix:pv($x, $cond) { $cond ?? ($x,) !! () }; say 1, 2, (3 pv 0), 4 124 bool::true I couldn't think of a good name for the new operator, though. pugs sub infix:?!($cond, $x) { $cond ?? ($x,) !! () } undef pugs 1, 2, (0 ?! 3), 4 (1, 2, 4) pugs 1, 2, (1 ?! 3), 4 (1, 2, 3, 4) pugs 1, 2, 0 ?! 3, 4 (1, 2, 4) pugs 1, 2, 1 ?! 3, 4 (1, 2, 3, 4) I'd always use it with parens, though. Juerd -- http://convolution.nl/maak_juerd_blij.html http://convolution.nl/make_juerd_happy.html http://convolution.nl/gajigu_juerd_n.html
Re: Conditionally included list elements
* Juerd [EMAIL PROTECTED] [2006-06-18 15:10]: Again I have no idea if this empty list is SUPPOSED to happen. Maybe TheLarry can enlighten us… :-) Regards, -- Aristotle Pagaltzis // http://plasmasturm.org/
Re: Conditionally included list elements
Hi Stuart, * Stuart Cook [EMAIL PROTECTED] [2006-06-18 15:05]: On 6/18/06, A. Pagaltzis [EMAIL PROTECTED] wrote: Is there a construct in Perl 6 to express this more immediately? Something along the lines of the following would seem ideal: $foo, $bar, ( $baz if $wibble ), $quux How about this: pugs sub infix:pv($x, $cond) { $cond ?? ($x,) !! () }; say 1, 2, (3 pv 1), 4 1234 bool::true Good point! I like. However, what are the evaluation semantics here? Neither the ternary nor the `if`-based solutions evaluate the expression they return if the condition turns out to be false. Wouldn’t your solution evaluate it unconditionally? Regards, -- Aristotle Pagaltzis // http://plasmasturm.org/
Re: Conditionally included list elements
On Sun, Jun 18, 2006 at 05:18:14PM +0200, A. Pagaltzis wrote: pugs sub infix:pv($x, $cond) { $cond ?? ($x,) !! () }; say 1, 2, (3 pv 1), 4 However, what are the evaluation semantics here? Neither the ternary nor the `if`-based solutions evaluate the expression they return if the condition turns out to be false. Wouldn’t your solution evaluate it unconditionally? That can be solved with an explicit thunk: sub infix:pv1 ($x, $cond) { $cond ?? ($x(),) !! () }; say 1, 2, {3} pv 1, 4 Or maybe 'is lazy' on $x? -- Gaal Yahas [EMAIL PROTECTED] http://gaal.livejournal.com/
Re: Conditionally included list elements
On Sun, Jun 18, 2006 at 05:18:52PM +0200, A. Pagaltzis wrote: : Maybe TheLarry can enlighten us… :-) We already have the operator you want. It's spelled Cxx?. :-) Larry
Re: Conditionally included list elements
* Larry Wall [EMAIL PROTECTED] [2006-06-18 19:05]: On Sun, Jun 18, 2006 at 05:18:52PM +0200, A. Pagaltzis wrote: : Maybe TheLarry can enlighten us… :-) We already have the operator you want. It's spelled Cxx?. :-) Nice. :-) How’s it used? S03 doesn’t list it. Regards, -- #Aristotle *AUTOLOAD=*_;sub _{s/(.*)::(.*)/print$2,(,$\/, )[defined wantarray]/e;$1}; Just-another-Perl-hacker;
Re: Conditionally included list elements
* Larry Wall [EMAIL PROTECTED] [2006-06-18 19:40]: On Sun, Jun 18, 2006 at 07:27:57PM +0200, A. Pagaltzis wrote: * Larry Wall [EMAIL PROTECTED] [2006-06-18 19:05]: We already have the operator you want. It's spelled Cxx?. :-) Nice. :-) How’s it used? S03 doesn’t list it. Nope. Doesn't list the C**- or C||! operators either. :-) (Hint: it doesn't matter if you put a space between the Cxx and the C?.) Ahh. So you’re telling me that Perl 5 has the same operator, but it spells it Cx!!. Clever! Regards, -- #Aristotle *AUTOLOAD=*_;sub _{s/(.*)::(.*)/print$2,(,$\/, )[defined wantarray]/e;$1}; Just-another-Perl-hacker;
[perl #38146] [TODO] OS.pmc - file copy 38146
Hi, I am trying implement #38146 todo item. While looking at the code for os.pmc there are IFDEF constructs defined for different operating systems (For e.g. WIN32 for now). I am just wonedring if it would make sense to seperate out code for each supported operating system under a directory structure. At the time of build the specific code for target operating system is added to the source tree. This very similar to the Linux source tree where the architecture specific code is implemented in a differen directory structure and correct directory structure is selected based on the architecture you are compiling for. There a couple of benifits that come to mind: 1. All the OS specific is maintained under seperated directory structure for each OS. 2. Defines a clean seperation b/w OS and Parrot Code. 3. Makes it easy to port Parrot to new platforms without breaking the implemented functionality for other platforms. Let me know what your thoguths are. Thanks, Vishal
RE: Using Perl in QA departments
Really Nice Information Thanks a lot Thanks and Regards, Abhir Kulkarni -Original Message- From: Gabor Szabo [mailto:[EMAIL PROTECTED] Sent: Sunday, June 18, 2006 12:43 AM To: perl-qa@perl.org Subject: Using Perl in QA departments If anybody is interested on this list, the slides and the examples of my 2 days course are available here: http://www.szabgab.com/perl_in_test_automation.html regards Gabor