Re: The --perl switch [was Re: $Ignore_Exitcode in Test-Harness]

2005-12-25 Thread Andy Lester
On Sun, Dec 25, 2005 at 10:49:28PM +0200, Shlomi Fish ([EMAIL PROTECTED]) wrote:
> However prove does not have a "--perl" switch:

Fixed in Test::Harness 2.57_01.  Thanks.

xoxo,
Andy

-- 
Andy Lester => [EMAIL PROTECTED] => www.petdance.com => AIM:petdance


Re: $Ignore_Exitcode in Test-Harness

2005-12-25 Thread Andy Lester
On Sun, Dec 25, 2005 at 01:46:21PM +0200, Shlomi Fish ([EMAIL PROTECTED]) wrote:
> 
> # Some experimental versions of OS/2 build have broken $?
> my $Ignore_Exitcode = $ENV{HARNESS_IGNORE_EXITCODE};
> 
> Meaning, that neaither the environment variable nor the variable that has 
> been 
> assigned from it are referenced. Is it because this functionality was removed 
> or because these lines were accidently removed? In any case, it should be 
> fixed.

I've pulled it out.  Thanks.

xoxo,
Andy


-- 
Andy Lester => [EMAIL PROTECTED] => www.petdance.com => AIM:petdance


Re: Iterating over complex structures

2005-12-25 Thread Rob Kinyon
On 12/22/05, Michele Dondi <[EMAIL PROTECTED]> wrote:
> Suppose I want to navigate a tree and print out info contained in each of
> its leaves along with info gathered from the position in the tree of the
> list itself? Can I do it in a "universal" manner as hinted above that
> would work for other situations as well?

In Ruby, each collection class that wishes to be iterated over mixes
in the Enumerable class. In a crude way, you can almost use that as
the definition of what makes an class a collection. All the class has
to provide is each(), which is a method that, according to the Ruby
book, "yields successive members of the collection." If the class
wishes to use the sorting items, then it has to provide a meaningful
spaceship operator.

each() (and a number of other methods) then takes a block that it
executes at every node.

As everything in Perl6 will be an object, I think we should be looking
at Ruby for possible solutions to this kind of problem. The Ruby way,
imho, would be to provide a set of "each()" methods that you can
choose to use, depending on how you wanted to iterate over the object.
The each() method you choose could maintain some kind of state about
where the element is in the collection. Or, and this would be my
preference, the elements should have the ability to return that state
when queried.

This implication here is that there should be an Enumerable role (or
set of roles) in Perl6 that provides this kind of capability. In
addition, there should probably be a useful set of base classes to do
things like Set, Bag, Tree, etc. Then, if I wanted to create a 3-2
tree which only takes values that is-a Floober and default to
iterating over it in level-order, I can do that in less than 20 lines
of code within a class. Then, I use that class when I want to use my
arbitrary data structure.

The further implication of this is that I don't think we will be using
AoHoAoHo... in applications anymore. In 1-off scripts, sure! But,
we'll have the infrastructure to create usable classes that abstract
away 90% of the complexity of our data structures, allowing us to
focus on the similarities in our code vs. the differences. Ruby takes
duck-typing to a religious mantra, which can be annoying, but it's
definitely very productive. Perl6 could do worse than copying that to
a large degree.

Of course, this doesn't work for arbitrary complex structures, but I
don't think anything would work for those.

Rob


Re: How to use Devel::Cover?

2005-12-25 Thread James E Keenan

Scott Wang wrote:

Hi ,

I am new to use Devel::Cover.

We have lots of product Perl modules in our product "lib" folder and we have 
lots of Perl test scripts to cover those modules, right now, we are trying to get the 
code coverage metrics for our tests on those modules. I find we might get help by using 
Devel::Cover, would you please give me some idea on how I should use the Devel::Cover to 
generate our tests coverage metrics on our Perl modules?




Are you asking for assistance in how to get stats for a *single* Perl 
module?  If so, that's easy (and easily learned from the docs):


perl Makefile.PL
make
cover -delete
make test HARNESS_PERL_SWITCHES=-MDevel::Cover
cover

That creates a subdirectory cover_db/which holds the database created by 
running Devel::Cover, as well as HTML files which vividly display what's 
covered and what's not by statement, branch, condition, subroutine, etc.


When I'm developing a Perl module I sometimes like to save text versions 
coverage reports in a separate subdirectory.  So I'll call:


cover cover_db --report=text > coverage.mymodule.myversionnumber.txt

If, on the other hand, you're asking how to collate the results of 
running Devel::Cover on *many* modules, well, that's something I haven't 
had to do, though others have.  Check archives of this list as well as 
Paul Johnson's home page.


jimk


Re: A couple of questions

2005-12-25 Thread Leopold Toetsch


On Dec 25, 2005, at 23:48, Steve Gunnell wrote:


Hi People,

When you use $P0 = compreg, "PIR" is there any way to get an optimizing
compiler ( or not ) or do you always get a version that follows the
flags that were passed to Parrot?


Currently you can't pass any more arguments (like runcore or debug 
flags), these are just inherited from commandline. This will be 
extended to a more flexible compiler invocation in the future. 
Proposals welcome, I presume it boils down to some named argument 
passing extension.


Is there any implementation of the Perl pack/unpack functions planned 
or

should we be using the Struct PMC?


There are currently 2 experimental features to attack this direction:
* :immediate subroutines that return a PMC result
  see e.g. t/pmc/string_36.pir or examples/shootout/revcomp.pir
* using Eval.get_string to get a stringish representation aka packfile 
of an Eval PMC

  see e.g. t/pmc/eval_15.pir ff


When using the Read/Readline opcodes how do we specify what encoding is
to be assumed for the incoming string?


There is one output encoding filter currently:

  pout = getstdout
  push pout, 'utf8'

The same should work with an import filter, that is a (TODO) read 
method implemented in src/io/io_utf8.c or similar.

Patches welcome.



Thanks and Merry Christmas,

Steve Gunnell


Weleome, Happy patching & ;-)
leo



A couple of questions

2005-12-25 Thread Steve Gunnell
Hi People,

When you use $P0 = compreg, "PIR" is there any way to get an optimizing
compiler ( or not ) or do you always get a version that follows the
flags that were passed to Parrot?

Is there any implementation of the Perl pack/unpack functions planned or
should we be using the Struct PMC?

When using the Read/Readline opcodes how do we specify what encoding is
to be assumed for the incoming string?

Thanks and Merry Christmas,

Steve Gunnell



How to use Devel::Cover?

2005-12-25 Thread Scott Wang
Hi ,

I am new to use Devel::Cover.

We have lots of product Perl modules in our product "lib" folder and we have 
lots of Perl test scripts to cover those modules, right now, we are trying to 
get the code coverage metrics for our tests on those modules. I find we might 
get help by using Devel::Cover, would you please give me some idea on how I 
should use the Devel::Cover to generate our tests coverage metrics on our Perl 
modules?

Thanks in advance,

Scott


-
Yahoo! Photos
 Ring in the New Year with Photo Calendars. Add photos, events, holidays, 
whatever.

The --perl switch [was Re: $Ignore_Exitcode in Test-Harness]

2005-12-25 Thread Shlomi Fish
Hi all!

Replying to myself, I should note that I found another problem in 
Test::Harness. Reading from the Test::Harness man page:

http://xrl.us/jb6q

<
=item C

Usually your tests will be run by C<$^X>, the currently-executing Perl.
However, you may want to have it run by a different executable, such as
a threading perl, or a different version.

If you're using the F utility, you can use the C<--perl> switch.
>

However prove does not have a "--perl" switch:

<==
$ prove --perl /usr/bin/perl t/*.t
Unknown option: p
==>

I also cannot find it anywhere in the code.

I hope some people would be able to address the issues I've raised after the 
weekend, as it is now the winters Holidays vacation.

And before I forget: Happy Hanukkah and Merry Christmas, everyone!

Regards,

Shlomi Fish

On Sunday 25 December 2005 13:46, Shlomi Fish wrote:
> Hi all!
>
> In Test::Harness, one can find the following statement:
>
> 
> # Some experimental versions of OS/2 build have broken $?
> my $Ignore_Exitcode = $ENV{HARNESS_IGNORE_EXITCODE};
>
>
> However:
>
> 
> shlomi:~/Download/unpack/Test-Harness-2.56$ grep -rE 'Ignore|IGNORE' .
> ./lib/Test/Harness.pm:my $Ignore_Exitcode = $ENV{HARNESS_IGNORE_EXITCODE};
> ./lib/Test/Harness.pm:=item C
>
>
> Meaning, that neaither the environment variable nor the variable that has
> been assigned from it are referenced. Is it because this functionality was
> removed or because these lines were accidently removed? In any case, it
> should be fixed.
>
> I am asking this because I'm working on Test::Run which is derived from
> Test::Harness, and would like to clean up the global variables there, and
> remove the handling of the environment variables to a separate module
> (Test::Run::CmdLine).
>
> Regards,
>
>   Shlomi Fish
>
> -
> Shlomi Fish  [EMAIL PROTECTED]
> Homepage:http://www.shlomifish.org/
>
> 95% of the programmers consider 95% of the code they did not write, in the
> bottom 5%.

-- 

-
Shlomi Fish  [EMAIL PROTECTED]
Homepage:http://www.shlomifish.org/

95% of the programmers consider 95% of the code they did not write, in the
bottom 5%.


Re: binding arguments

2005-12-25 Thread Ingo Blechschmidt
Hi,

Juerd wrote:
> The next thing I thought was: hey, argument *passing* is actually
> *binding* to variables in the sub, so why not use the := operator?
> That works very well, because binding as an expression makes no sense
> anyway, it being a language thing. And luckily, named arguments are
> also a language thing, so that works out:

I disagree about binding only being a language thing:

# Happened to me in Perl 5 today
sub foo ($long_parameter_name) {
return 42
if (my $short := $long_parameter_name) == $specialcase;
...usual processing with $short...
}

push @foo, (my $head := pop @grtz);

(my $alias := $long_name).grtz();
# etc.

(Unless of course, you consider this to be obfuscation.)


--Ingo



Re: for loop list of lists: flattening arguments to pointy sub

2005-12-25 Thread Ingo Blechschmidt
Hi,

Andrew Savige wrote:
> In Pugs, you can process a simple list of lists like this:
> 
> my @lol = ( [ '1a', '1b' ], [ '2a', '2b' ], [ '3a', '3b' ] );
> for @lol -> $t { say "1st='$t[0]' 2nd='$t[1]'" }
> 
> Yet the $t[0] and $t[1] look untidy to me, so I'd prefer to specify
> that the for closure block takes two parameters, something like:
> 
> for  -> $x, $y { say "1st='$x' 2nd='$y'" }
> 
> But I have no clue what to put in place of  above.

for @lol -> [$x,$y] { say "1st='$x' 2nd='$y'" }

(Assuming that the syntax for unpacking array parameters wasn't changed
when I weren't looking.)

You can read more about this in S06, "Unpacking array parameters" [1].


--Ingo

[1]
http://dev.perl.org/perl6/doc/design/syn/S06.html#Unpacking_array_parameters



$Ignore_Exitcode in Test-Harness

2005-12-25 Thread Shlomi Fish
Hi all!

In Test::Harness, one can find the following statement:


# Some experimental versions of OS/2 build have broken $?
my $Ignore_Exitcode = $ENV{HARNESS_IGNORE_EXITCODE};


However:


shlomi:~/Download/unpack/Test-Harness-2.56$ grep -rE 'Ignore|IGNORE' .
./lib/Test/Harness.pm:my $Ignore_Exitcode = $ENV{HARNESS_IGNORE_EXITCODE};
./lib/Test/Harness.pm:=item C


Meaning, that neaither the environment variable nor the variable that has been 
assigned from it are referenced. Is it because this functionality was removed 
or because these lines were accidently removed? In any case, it should be 
fixed.

I am asking this because I'm working on Test::Run which is derived from 
Test::Harness, and would like to clean up the global variables there, and 
remove the handling of the environment variables to a separate module 
(Test::Run::CmdLine).

Regards,

Shlomi Fish

-
Shlomi Fish  [EMAIL PROTECTED]
Homepage:http://www.shlomifish.org/

95% of the programmers consider 95% of the code they did not write, in the
bottom 5%.


for loop list of lists: flattening arguments to pointy sub

2005-12-25 Thread Andrew Savige
Flattening argument lists is not yet working in Pugs, so I can't easily play
around with this one, hence this question.

In Pugs, you can process a simple list of lists like this:

my @lol = ( [ '1a', '1b' ], [ '2a', '2b' ], [ '3a', '3b' ] );
for @lol -> $t { say "1st='$t[0]' 2nd='$t[1]'" }

Yet the $t[0] and $t[1] look untidy to me, so I'd prefer to specify that the
for closure block takes two parameters, something like:

for  -> $x, $y { say "1st='$x' 2nd='$y'" }

But I have no clue what to put in place of  above.

Thanks,
/-\


Send instant messages to your online friends http://au.messenger.yahoo.com