Re: some assembly wanted
Matt Diephouse [EMAIL PROTECTED] wrote: Leopold Toetsch [EMAIL PROTECTED] wrote: IIRC it was already mentioned here: http://shootout.alioth.debian.org/ - the Computer Language Shootout. It would be quite interesting to have Parrot figures too and see benchmark timings decrease steadily ;-) How is this different from timeparrot? http://xrl.us/f9oy The difference is comparison to ~60 different compiled and interpreted languages (click Sandbox). So we'd just need the benchmark code translated to PIR. I've here harmonic.pir and ack.pir (the latter sucks badly) Adding .pasm, .imc, and .pir scripts to examples/benchmarks/ will cause them to be benchmarked and graphed as part of timeparrot every day. Yes I know. We should do that additionally to get figures vs time to see how Parrot evolves. leo
parse problem with subroutines?
Running pugs r4158, I find that (some, at least) subroutine calls only work with no whitespace between the sub name and the arguments. sub numcmp ($a, $b) { return $a = $b }; $v = numcmp(1,2); # works fine $v = numcmp (1,2); # fails with $v = numcmp I don't see anywhere in the canon that no whitespace is allowed between the function name and the opening paren of the arguments. E6 /Molecules/ states that whitespace is optional. Attached is a test case suitable for pugs (t/subroutines/numcmp.t). david d zuhn [EMAIL PROTECTED]
[perl #36045] [PATCH]Loop Improvements
# New Ticket Created by Curtis Rawls # Please include the string: [perl #36045] # in the subject line of all future correspondence about this issue. # URL: https://rt.perl.org/rt3/Ticket/Display.html?id=36045 This patch makes improvements to the loop struct. Changes to loops: -Added index to loop header -Added set of exit blocks -Replaced entry with preheader index -Modified dump_loops() to display new info -Curtis Rawls loop.patch Description: Binary data
Re: [perl #36045] [PATCH]Loop Improvements
Curtis Rawls (via RT) wrote: This patch makes improvements to the loop struct. Thanks, applied - r8219 BTW: would you like to take a look at the register allocator? It works but consumes enormous amounts of resources for e.g. Dan's Evil Subs[1]. I've here an IIRC slightly modfied version of Bill's original patch, which I could sync to current Parrot. I think that first we should split (for some register count bigger then a threshold) the register allocation into 4 passes, one for each register kind. That should reduce resource usage immediately. But I'm not an expert here. [1] See e.g. [perl #32418] ff - original patch by Bill Coffman leo
Re: parse problem with subroutines?
On 5/31/05, david d zuhn [EMAIL PROTECTED] wrote: Running pugs r4158, I find that (some, at least) subroutine calls only work with no whitespace between the sub name and the arguments. $v = numcmp (1,2); # fails with I don't see anywhere in the canon that no whitespace is allowed between the function name and the opening paren of the arguments. Synopsis 2: Whitespace is not allowed before the parens, but there is a corresponding .() operator, which allows you to insert optional whitespace before the dot. $v = numcmp .(1,2); # should pass Cheers, Carl
new / BUILD errors
Here's a demo script: #!/usr/bin/pugs use v6; class Foo { multi method new (Class $class: Str $date) { say ok; return $class.new(date = $date); } submethod BUILD (+$date) { say date: '$date'; } } my $foo = Foo.new(date = 'blah'); =cut pugs test.pl ok date: '' Problem 1: I call the constructor with a named argument, so I expect my explicit 'new' method to _not_ get called, and for the default 'new' method inherited from Class to get called. However, ok is printed, showing my 'new' method is called. Problem 2: As shown in the output above, $date in BUILD is undef. Also, if I add say $class.perl; inside of my 'new' method, it prints =: \{obj:Class} Is this correct? Should it not be \{obj:Class} ? If someone can confirm the problems above are bugs, I'll add tests to the test suite for it. I'm running pugs svn version 4201. Cheers, Carl
Test::Object
Just a quick heads up and request for comments on a testing module I'm putting together. Test::Object See search.cpan.org once the initial POD-only upload is done, but in short I want a way to be able to define tests or groups of tests that ANY object of a particular class should pass, and then be able to throw objects at a test function and have it test that object against *every* class that the object claims to implement. I'm hitting this problem with large and deep class trees where what I should really be doing is testing it against every parent class and role, but in reality I do the specifics for that subclass, plus a couple of specific ones for the parents. The HTML version outlines the details well enough. You would... Test::Object-register( 'Class::Name' = \coderef ); ... the tests for various classes, and then just pass any object to... object_ok( $object ); ... and Test::Object will throw the object at all appropriate registered tests. Thoughts? Something exist already that I'm missing? Adam K
Re: Declarations of constants
Ingo Blechschmidt wrote: Hi, # Way 1 my $MEANING_OF_LIFE is constant = 42; Forgive my ignorance here, but for all of these different ways of doing constants, will they all optimize (including partial evaluation/currying) at compile/build/init/run-time? my $gravity is constant = 10; # One significant figure sub time_to_ground ($height, $accel) { ...acceleration math... } my $time = time_to_ground( 500, $gravity ); ... thus simplifying internally to my $time = 1234; Adam K
Re: Declarations of constants
[EMAIL PROTECTED] (Adam Kennedy) writes: Forgive my ignorance here, but for all of these different ways of doing constants, will they all optimize (including partial evaluation/currying) at compile/build/init/run-time? Gosh, I hope not. my $gravity is constant = 10; # One significant figure sub time_to_ground ($height, $accel) { ...acceleration math... } The ability to play around with the working of time_to_ground before it runs is one of the things I like about Perl. -- A language that doesn't have everything is actually easier to program in than some that do. -- Dennis M. Ritchie
r8223 - HLL support 4
The first steps for HLL language and type support are in. You can now dynamically load a HLL _group PMC library by just including a .HLL line in PASM/PIR, e.g. .HLL Tcl, tcl_group ... $P0 = new .TclInt # Integer constant The .HLL pragma registers at compile time the given HLL language name within src/hll.c and loads the given library with Parrot_load_lib(). Please note that this does not yet work for .pbc files as the HLL isn't stored in the PBC yet (this will come soon). See also t/dynclass/foo.t for 2 examples. Have fun, leo
Parrot makefile on Win32
The parrot makefile has several places where nmake baulks at the length of the expanded command lines. I've found that I can work around this is some places using inline files, but I'm having trouble working out where/how to make the adjustments. I also have my doubts whether this would be compatible with other make programs. Is anyone else successfully building parrot on win32 native? If so, how are they avoiding this problem? Thanks njs
pugs 'make clean' fatal error on ms windows
Running `make clean` on WindowsXP is dying with an expanded command line too long error. Output as follows: make clean Microsoft (R) Program Maintenance Utility Version 1.50 Copyright (c) Microsoft Corp 1988-94. All rights reserved. cd ext\Algorithm-TokenBucket C:\Perl\bin\perl.exe -Iinc -MExtUtils::C ommand -e test_f Makefile MAKE clean cd ext\Benchmark C:\Perl\bin\perl.exe -Iinc -MExtUtils::Command -e te st_f Makefile MAKE clean cd ext\CGI C:\Perl\bin\perl.exe -Iinc -MExtUtils::Command -e test_f M akefile MAKE clean cd ext\Config-Tiny C:\Perl\bin\perl.exe -Iinc -MExtUtils::Command -e test_f Makefile MAKE clean cd ext\File-Spec C:\Perl\bin\perl.exe -Iinc -MExtUtils::Command -e te st_f Makefile MAKE clean cd ext\fp C:\Perl\bin\perl.exe -Iinc -MExtUtils::Command -e test_f Ma kefile MAKE clean cd ext\HTML-Entities C:\Perl\bin\perl.exe -Iinc -MExtUtils::Command - e test_f Makefile MAKE clean cd ext\lib C:\Perl\bin\perl.exe -Iinc -MExtUtils::Command -e test_f M akefile MAKE clean cd ext\libwww-perl C:\Perl\bin\perl.exe -Iinc -MExtUtils::Command -e test_f Makefile MAKE clean cd ext\Locale-KeyedText C:\Perl\bin\perl.exe -Iinc -MExtUtils::Comman d -e test_f Makefile MAKE clean cd ext\Net-IRC C:\Perl\bin\perl.exe -Iinc -MExtUtils::Command -e test _f Makefile MAKE clean cd ext\Perl-MetaModel C:\Perl\bin\perl.exe -Iinc -MExtUtils::Command -e test_f Makefile MAKE clean cd ext\Pod-Event-Parser C:\Perl\bin\perl.exe -Iinc -MExtUtils::Comman d -e test_f Makefile MAKE clean cd ext\Set C:\Perl\bin\perl.exe -Iinc -MExtUtils::Command -e test_f M akefile MAKE clean cd ext\Test C:\Perl\bin\perl.exe -Iinc -MExtUtils::Command -e test_f Makefile MAKE clean cd ext\Test-Builder C:\Perl\bin\perl.exe -Iinc -MExtUtils::Command -e test_f Makefile MAKE clean cd ext\Tree C:\Perl\bin\perl.exe -Iinc -MExtUtils::Command -e test_f Makefile MAKE clean NMAKE : fatal error U1095: expanded command line 'C:\Perl\bin\perl.exe -Iinc -ME xtUtils::Command -e rm_rf pugs* src\Pugs\pugs_config.h src\Pugs\pugs_version.h s rc\Pugs\pugs_config.h src\Pugs\Config.hs blib6 test.log src\Pugs\Embed\Parrot.hs src\Pugs\Embed\Parrot_hsc.* src\Pugs\Run\Perl5_stub.* src\Data\Yaml\Syck_stub.* src\Data\Yaml\Syck.hs pcre\*.o* perl5\*.o* syck\*.o* src\*.hpp src\*.hi src\*.o * src\Data\*.hpp src\Data\*.hi src\Data\*.o* src\IMC\*.hpp src\IMC\*.hi src\IMC\ *.o* src\pcre\*.hpp src\pcre\*.hi src\pcre\*.o* src\perl5\*.hpp src\perl5\*.hi s rc\perl5\*.o* src\perl6\*.hpp src\perl6\*.hi src\perl6\*.o* src\pge\*.hpp src\pg e\*.hi src\pge\*.o* src\Pugs\*.hpp src\Pugs\*.hi src\Pugs\*.o* src\RRegex\*.hpp src\RRegex\*.hi src\RRegex\*.o* src\syck\*.hpp src\syck\*.hi src\syck\*.o* src\D ata\Yaml\*.hpp src\Data\Yaml\*.hi src\Data\Yaml\*.o* src\pge\library\*.hpp src\p ge\library\*.hi src\pge\library\*.o* src\pge\PGE\*.hpp src\pge\PGE\*.hi src\pge\ PGE\*.o* src\Pugs\AST\*.hpp src\Pugs\AST\*.hi src\Pugs\AST\*.o* src\Pugs\Compile \*.hpp src\Pugs\Compile\*.hi src\Pugs\Compile\*.o* src\Pugs\Cont\*.hpp src\Pugs\ Cont\*.hi src\Pugs\Cont\*.o* src\Pugs\Embed\*.hpp src\Pugs\Embed\*.hi src\Pugs\E mbed\*.o* src\Pugs\External\*.hpp src\Pugs\External\*.hi src\Pugs\External\*.o* src\Pugs\Parser\*.hpp src\Pugs\Parser\*.hi src\Pugs\Parser\*.o* src\Pugs\Prim\*. hpp src\Pugs\Prim\*.hi src\Pugs\Prim\*.o* src\Pugs\Rule\*.hpp src\Pugs\Rule\*.hi src\Pugs\Rule\*.o* src\Pugs\Run\*.hpp src\Pugs\Run\*.hi src\Pugs\Run\*.o* src\P ugs\Types\*.hpp src\Pugs\Types\*.hi src\Pugs\Types\*.o* src\pge\library\Data\*.h pp src\pge\library\Data\*.hi src\pge\library\Data\*.o* src\Pugs\Compile\Parrot\* .hpp src\Pugs\Compile\Parrot\*.hi src\Pugs\Compile\Parrot\*.o* ./blib Makefile.a perl D:\pugstemp\blib\arch\auto\Perl6\Pugs/extralibs.all D:\pugstemp\blib\arch\a uto\Perl6\Pugs/extralibs.ld perlmain.c tmon.out mon.out so_locations pm_to_blib *.obj *.lib perl.exe perl perl.exe Pugs.bso Pugs.def libPugs.def Pugs.exp Pugs. x core core.*perl.*.? *perl.core core.[0-9] core.[0-9][0-9] core.[0-9][0-9][0-9] core.[0-9][0-9][0-9][0-9] core.[0-9][0-9][0-9][0-9][0-9]' too long Stop.
Re: parse problem with subroutines?
On 5/31/05, david d zuhn [EMAIL PROTECTED] wrote: this is a pretty fundamental change in perl that ought to be made a bit clearer (it's not in the p5-p6 porting guide, for example). Agreed. I remembered this being discussed by Abigail. Found it here: http://www.perlmonks.org/?node_id=346083 It references A12 - methods: Parentheses are required on the dot notation if there are any arguments (not counting adverbial arguments). There may be no space between the method name and the left parenthesis unless you use the dot form of parentheses: .doit # okay, no arguments .doit() # okay, no arguments .doit ()# ILLEGAL (two terms in a row) .doit.()# okay, no arguments, same as .doit() .doit .() # okay, no arguments, same as .doit() Carl
Re: parse problem with subroutines?
$v = numcmp (1,2); # fails with Synopsis 2: Whitespace is not allowed before the parens, but there is a corresponding .() operator, which allows you to insert optional whitespace before the dot. $v = numcmp .(1,2); # should pass The quoted text is in a paragraph describing explicit function references and how to call through them. If this is indeed a statement that all function calls, especially the ordinary sort that are used most often, must be of the form a(b) rather than allowing a (b), this is a pretty fundamental change in perl that ought to be made a bit clearer (it's not in the p5-p6 porting guide, for example). david d zuhn [EMAIL PROTECTED]
date and time formatting
As I am interested in human-readable dates and times, and having found no conclusive discussion on time formatting, I make my recommendation for a syntax (to start discussion, and allow for date formatting to be implemented in pugs): I would like for time() to return an object, which in numeric context is the number of seconds from the epoch (the new epoch, of course), and which in string context is a human-readable string. We could also use localtime(), and leave time() alone. Possible syntax could be: $time_object = time(); $epoch_seconds = +$time_object; $human_readable = ~$time_object; $human_readable = $time_object.format; # default format $human_readable = $time_object.format($pattern); $human_readable = $time_object.format($pattern, offset = 'local'); The default offset would probably be 'local', and would account for daylight saving time. The offset could be changed to a floating-point value indicating hours offset from UTC. A timezone module could perhaps allow for timezone names, which would allow for daylight saving time computation for non-local times. The default offset would probably be stored in a global variable. The default format would probably be an ISO 8601 format, like: 1994-11-05T08:15:30-05:00 and the default format pattern would probably be stored in a global variable, possibly as an strftime() pattern. -kolibrie
Re: date and time formatting
On 5/31/05, Nathan Gray [EMAIL PROTECTED] wrote: As I am interested in human-readable dates and times, and having found no conclusive discussion on time formatting, I make my recommendation for a syntax (to start discussion, and allow for date formatting to be implemented in pugs): What's wrong with porting DateTime? Rob
Re: Test::Object
On 31 May 2005, at 09:47, Adam Kennedy wrote: [snip] Something exist already that I'm missing? [snip] I'd use Test::Class (but I would say that :-) So the example from your POD would be something like: { package Foo::Test; use base qw( Test::Class ); use Test::More; # we take the ::Test suffix off to get the name of the class we're testing # (this should really be in a Test::Class base class - and will be soon) sub class_under_test { my $self = shift; my $test_class = ref $self; $test_class =~ s/::Test$//s; return $test_class; }; # here is where we create our object under test sub create_fixture :Test( setup ) { my $self = shift; $self-{object} = $self-class_under_test-new; }; # here we make sure foo returns true sub foo_returns_correct_value : Test { my $object = shift-{object}; ok( $object-foo ); }; # here we check answer returns 42 (just for the sake of another test) sub the_answer_to_live_the_universe_and_everything : Test { my $object = shift-{object}; is( $object-answer, 42 ); }; } { package FooBar::Test; use base qw( Foo::Test ); use Test::More; # we just have to say what's different about FooBar objects, the # common behaviour stays the same sub foo_returns_correct_value : Test { my $object = shift-{object}; is( $object-foo, 'bar' ); }; } Test::Class-runtests; which would give us: # FooBar::Test-foo_returns_correct_value ok 1 - foo returns correct value # # FooBar::Test-the_answer_to_live_the_universe_and_everything ok 2 - the answer to live the universe and everything # # Foo::Test-foo_returns_correct_value ok 3 - foo returns correct value # # Foo::Test-the_answer_to_live_the_universe_and_everything ok 4 - the answer to live the universe and everything Cheers, Adrian
Re: parse problem with subroutines?
On 5/31/05, Jonathan Scott Duff [EMAIL PROTECTED] wrote: I didn't really realize that there was a p5-p6 porting guide until I saw this. I'll add something to the guide as above (plus subs). I've already added a bit about method calls, but I'll leave it alone for you to do arrays/hashes. Carl
Re: Parrot makefile on Win32
On 5/31/05, Nigel Sandever [EMAIL PROTECTED] wrote: The parrot makefile has several places where nmake baulks at the length of the expanded command lines. though you weren't explicit, i suspect you're using the ms c++ toolkit to build parrot on win32. some months ago, i ran into the same problem. since i have switched to msvc, i have not ran into any command-line length problems, nor have i read any reports of these problems with cygwin or mingw. I've found that I can work around this is some places using inline files, but I'm having trouble working out where/how to make the adjustments. if i recall correctly, linking parrot.exe was a trouble spot. the main makefile is generated from config/gen/makefiles/root.in, and $(PARROT) is built around line 649 (revision 8223). you might consider adding a dependency to that line, and create the inline file in the new dependency. any inline files should be added to the 'clean' target for removal. I also have my doubts whether this would be compatible with other make programs. Is anyone else successfully building parrot on win32 native? If so, how are they avoiding this problem? as i said, i'm not having any problems building with msvc-7.1. i'd be happy to test any patches you submit with that compiler. Thanks njs ~jerry
Re: r8223 - HLL support 4
Leopold Toetsch wrote: Please note that this does not yet work for .pbc files as the HLL isn't stored in the PBC yet (this will come soon). Should work now (rev 8224). See also t/dynclass/foo.t for 2 examples. $ ./parrot -o f.pbc t/dynclass/foo_9.pir $ ./parrot f.pbc 42 leo
Re: parse problem with subroutines?
ok, that was quick :) Shall I remove what I'd already added to the bottom of the file? Carl
Re: parse problem with subroutines?
On Tue, May 31, 2005 at 08:05:04AM -0500, david d zuhn wrote: If this is indeed a statement that all function calls, especially the ordinary sort that are used most often, must be of the form a(b) rather than allowing a (b), this is a pretty fundamental change in perl that ought to be made a bit clearer It's not just function calls. Arrays and hashes require no whitespace between the name and the subscript unless you use the dot form. @a[0] # ok @a.[0] # ok @a [0] # WRONG @a .[0]# ok %h{'k'} # ok %h.{'k'}# ok %h {'k'}# WRONG %h .{'k'} # ok %hk # ok %h.k # ok %h k # WRONG %h .k# ok Also note that the dot follows the subscript so that the following are also incorrect: foo. () # WRONG @a. [0]# WRONG %h. {'k'} # WRONG %h. k# WRONG Unless I'm completely mistaken, in which case someone had better correct me :-) (it's not in the p5-p6 porting guide, for example). I didn't really realize that there was a p5-p6 porting guide until I saw this. I'll add something to the guide as above (plus subs). -Scott -- Jonathan Scott Duff [EMAIL PROTECTED]
Re: some assembly wanted
Leopold Toetsch [EMAIL PROTECTED] wrote: Matt Diephouse [EMAIL PROTECTED] wrote: Leopold Toetsch [EMAIL PROTECTED] wrote: IIRC it was already mentioned here: http://shootout.alioth.debian.org/ - the Computer Language Shootout. It would be quite interesting to have Parrot figures too and see benchmark timings decrease steadily ;-) How is this different from timeparrot? http://xrl.us/f9oy The difference is comparison to ~60 different compiled and interpreted languages (click Sandbox). Okay. I wasn't sure that you meant to actually add it to the Shootout. Looking at the site again, I found the FAQ and understand what you are saying. -- matt diephouse http://matt.diephouse.com
Re: pugs 'make clean' fatal error on ms windows
On 5/31/05, Carl Franks [EMAIL PROTECTED] wrote: Running `make clean` on WindowsXP is dying with an expanded command line too long error. You need to get a later version of nmake. The latest is 7.10, I believe. Aank
Re: date and time formatting
On Tue, May 31, 2005 at 09:23:11AM -0400, Nathan Gray wrote: As I am interested in human-readable dates and times, and having found no conclusive discussion on time formatting, I make my recommendation for a syntax (to start discussion, and allow for date formatting to be implemented in pugs): I would like for time() to return an object, which in numeric context is the number of seconds from the epoch (the new epoch, of course), and which in string context is a human-readable string. We could also use localtime(), and leave time() alone. Just a friendly note that since this is a language design issue (as opposed to an implementation one) this thread likely belongs only on perl6-language and not on perl6-compiler. I'm just trying to keep the traffic on the lists at a reasonable volume ... :-) Followups to p6l, please, unless there's an obvious reason why they need to be on p6c. Pm
Bad code generated by imcc optimiser
(I'm reposting this because I'm not sure what happened to the one that I sent to parrotbugs; forgive me if two eventually appear) Folks, There seems to be some problems with -O1 when instructions are optimised at the end of functions. For instance, take sub main func () end sub func $I0 += 1 end which translates to main: @pcc_sub_call_0: set I0, 1 set I1, 0 set I2, 0 set I3, 0 set I4, 0 set S1, set_p_pc P0, func invokecc null I0 null I3 returncc func: add I30, 1 null I0 null I3 returncc When optimised with -O1 you instead get main: @pcc_sub_call_0: set I0, 1 set I1, 0 set I2, 0 set I3, 0 set I4, 0 set S1, set_p_pc P0, func invokecc null I0 null I3 returncc func: inc I30 where the tail of func is lost after the instruction has been substituted (and as such core dumps for me as control goes past the end of the bytecode). In what is semi-related to this, if a deleted instruction (e.g. $I0+=0) is at the end of a function, you get a core dump in imcc/optimiser.c in this line (because ins is NULL): ins = ins-prev ? ins-prev : unit-instructions; If no ones picked this up in the next couple of days, I'll hopefully have time to get my teeth into it... Cheers, Nick
r8225 - HLL support 6 - type mappings
I've now put together the missing pieces and filled the gaps - here we go - an example: dynclasses/pyfloat.pmc:class_init() - registers a type mapping Float = PyFloat t/dynclass/pycomplex_3.pir - denotes that's using Python HLL by .HLL Python, python_group classes/complex.pmc:absolute() - uses this type mapping to create a PyFloat for it's result Please note that due to the changed frozen image of Sub PMCs (added HLL_id) current PBC files have become invalid. Run make realclean; perl Configure.pl... leo
Re: pugs 'make clean' fatal error on ms windows
On 5/31/05, Aankhen [EMAIL PROTECTED] wrote: You need to get a later version of nmake. The latest is 7.10, I believe. 1.50 - 7.10 That's quite a version number jump! I've updated it, and it works now, thanks. Carl
Re: [PATCH]Loop Improvements
At 10:19 AM +0200 5/31/05, Leopold Toetsch wrote: Curtis Rawls (via RT) wrote: This patch makes improvements to the loop struct. Thanks, applied - r8219 BTW: would you like to take a look at the register allocator? It works but consumes enormous amounts of resources for e.g. Dan's Evil Subs[1]. I've here an IIRC slightly modfied version of Bill's original patch, which I could sync to current Parrot. When patches that improve assembly time of Big Evil code go in, feel free to ping me and I'll give things a whirl. I'm not generally keeping up to date with parrot builds on the system I'm doing my dev work on, so it can be a while before I notice. (While here being a month or more sometimes) Believe me, speeding up compile times would make Dan a Happy Camper(tm) :) -- Dan --it's like this--- Dan Sugalski even samurai [EMAIL PROTECTED] have teddy bears and even teddy bears get drunk
Re: Bad code generated by imcc optimiser
Nick Glencross wrote: (I'm reposting this because I'm not sure what happened to the one that I sent to parrotbugs; forgive me if two eventually appear) Folks, There seems to be some problems with -O1 when instructions are optimised at the end of functions. Fixed, thanks for testing. In what is semi-related to this, if a deleted instruction (e.g. $I0+=0) is at the end of a function, you get a core dump in imcc/optimiser.c in this line (because ins is NULL): ins = ins-prev ? ins-prev : unit-instructions; Fixed too rev 8227 Cheers, Nick leo
Re: date and time formatting
On May 31, 2005, at 9:51 AM, Rob Kinyon wrote: On 5/31/05, Nathan Gray [EMAIL PROTECTED] wrote: As I am interested in human-readable dates and times, and having found no conclusive discussion on time formatting, I make my recommendation for a syntax (to start discussion, and allow for date formatting to be implemented in pugs): What's wrong with porting DateTime? Rob It's back to the old question of what's in core? Are dates and times something that are used in such a large proportion of programs that they deserve to be shipped in the basic grammar? Or perhaps in the basic set of packages? Perl 5 has an entire swath of modules designed to manipulate dates and times; this suggests that they are (A) commonly used and (B) something that people feel very strongly about the semantics of. --Dks
Re: comprehensive list of perl6 rule tokens
On Sun, May 29, 2005 at 12:52:25PM -0400, Jeff 'japhy' Pinyan wrote: I'm curious if commit and cut capture anything. They don't start with '?', so following the guidelines, it would appear they capture, but that doesn't make sense. Should they be written as ?commit and ?cut, or is the fact that they capture silently ignored because they're not consuming anything? Same thing with null and prior. And with after P and before P. It should be assumed that !after P doesn't capture because it can only capture if P matches, in which case !after P fails. So, what's the deal? I'm not the language designer, but FWIW here is my interpretation. First, we have to remember that capture now means more than just grabbing characters from a string -- it also generates a successful match and a corresponding match object. Thus, even though after, before, commit, cut, and null are zero width assertions, maybe they should still produce a corresponding match object indicating a successful match. This might end up being useful in alternations or other rule structures: m/ [ abc commit def | ab ]/ ; if $commit { say we found 'abcdef'; } m/ [ abc | def null ]/; if $null { say we found 'def'; } I don't *know* that this would be useful, and certainly there are other ways to achieve the same results, but keeping the same capture semantics for zero-length assertions seems to work out okay. Of course, to avoid the generation of the match objects one can use ?commit, ?cut, ?null, etc. I suspect that for the majority of cases the choice of commit vs. ?commit isn't going to make a whole lot of difference, and for the places where it does make a difference it's nice to preserve the interpretation being used by other subrules. Things could be a bit interesting from a performance/optimization perspective; conceivably an optimizer could do a lot better for the common case if we somehow declared that null, commit, cut, etc. never capture. But I think the execution cost of capturing vs. non-capturing in PGE is minimal relative to other considerations, so we're a bit premature to try to optimize there. Overall I think we'll be better off keeping things consistent for programmers at the language level, and then build better/smarter optimizers into the pattern matching engine to handle the common cases. Pm
Re: Parrot makefile on Win32
Nigel Sandever wrote: The parrot makefile has several places where nmake baulks at the length of the expanded command lines. According to p6c[1] there exists nmake 7.10, which works. leo [1] pugs 'make clean' fatal error on ms windows
Re: Bad code generated by imcc optimiser
Leopold Toetsch wrote: Nick Glencross wrote: (I'm reposting this because I'm not sure what happened to the one that I sent to parrotbugs; forgive me if two eventually appear) Folks, There seems to be some problems with -O1 when instructions are optimised at the end of functions. Fixed, thanks for testing. Hmmm... Not seeing any improvement at my end ... In what is semi-related to this, if a deleted instruction (e.g. $I0+=0) is at the end of a function, you get a core dump in imcc/optimiser.c in this line (because ins is NULL): ins = ins-prev ? ins-prev : unit-instructions; Fixed too rev 8227 That ones certainly much happier! Brilliant. Nick
Re: date and time formatting
What's wrong with porting DateTime? It's back to the old question of what's in core? Are dates and times something that are used in such a large proportion of programs that they deserve to be shipped in the basic grammar? Or perhaps in the basic set of packages? Perl 5 has an entire swath of modules designed to manipulate dates and times; this suggests that they are (A) commonly used and (B) something that people feel very strongly about the semantics of. Which still begs the question - why not port DateTime to P6? Why can't installing a module provide new keywords? Rob
Re: date and time formatting
Nathan Gray wrote: possibly as an strftime() pattern. Can we please make sure that strftime() is _not_ OS dependent like the POSIX version is now? -- Rod Adams
Re: date and time formatting
On May 31, 2005, at 1:16 PM, Rob Kinyon wrote: What's wrong with porting DateTime? It's back to the old question of what's in core? Are dates and times something that are used in such a large proportion of programs that they deserve to be shipped in the basic grammar? Or perhaps in the basic set of packages? Perl 5 has an entire swath of modules designed to manipulate dates and times; this suggests that they are (A) commonly used and (B) something that people feel very strongly about the semantics of. Which still begs the question - why not port DateTime to P6? Why can't installing a module provide new keywords? Rob In reverse order: - No reason it can't. Nor did I imply otherwise. - I didn't say we shouldn't port DateTime. My point was simply that, based on the amount of date-related code on CPAN, this is an issue that many people care about quite a bit. We would probably be well served to consider it carefully and decide on what semantics we really want. Maybe DateTime is exactly what everyone wants and all we need to do is port it. On the other hand, there is something to be said for Nathan's approach; isn't it worth discussing? Personally, I've always found date handling to be difficult. The various modules go a long way towards simplifying it, but they require calling functions and methods, which forces one to think in a low-level algorithmic style. It would be great if there was a more intuitive time/date handling model built into the language...the kind of quantum leap in power and intuitiveness that we got from the new Rules engine (as opposed to the old regex engine). Perhaps something like the typed operations that were discussed recently: my ($launch_date = now() + 6 weeks) but time(9am); say We will launch on a $lauch_date.day_of_week, at $launch_date.time_of_day.; say This gives us . $launch_date but hours . hours, including weekends and evenings.; # outstanding_tickets() returns user-written ticket objects; created() returns a time object representing # creation time. The objects stringify to their report. say Remaining issues, oldest first:; say \t $_ for sort { $a.creation().age = $b.creation().age } outstanding_tickets(); # Prints 'Meetings are...is Sunday, June 19.; say Meetings are the third Sunday of each month. The first June meeting is . (month(6).days(0))[2] but format(/dayname, monthname day/); The above examples are just noodlings and are not well thought out, but hopefully they point in the right direction. --Dks
Re: date and time formatting
- I didn't say we shouldn't port DateTime. My point was simply that, based on the amount of date-related code on CPAN, this is an issue that many people care about quite a bit. We would probably be well served to consider it carefully and decide on what semantics we really want. Maybe DateTime is exactly what everyone wants and all we need to do is port it. On the other hand, there is something to be said for Nathan's approach; isn't it worth discussing? What I'm trying to get at isn't that DateTime's API should be preserved. I'm saying that the concept of DateTime should be ported. Core or not core - it doesn't matter. When use'd (or installed), it should override now() (and anyone else we can think of) to return an object that DWIMs, plus provides the interface you've outlined below. Perhaps something like the typed operations that were discussed recently: my ($launch_date = now() + 6 weeks) but time(9am); say We will launch on a $lauch_date.day_of_week, at $launch_date.time_of_day.; say This gives us . $launch_date but hours . hours, including weekends and evenings.; Sure. $launch_date is of type DateTime. It will numify to the seconds-since-the-epoch, stringify to some date string, and provide all the neat-o-keen methods you want it to have. Frankly, I think we're in violent agreement here. I don't think this is something that needs to be built into the language. This is something that should be strongly-recommended for downloading. Kinda like you always expect DBI to be around when you go to a new major client, but it's not core. Well, I always expect DBI to be around ... :-) Rob
Re: date and time formatting
On May 31, 2005, at 2:22 PM, Rob Kinyon wrote: my ($launch_date = now() + 6 weeks) but time(9am); Sure. $launch_date is of type DateTime. It will numify to the seconds-since-the-epoch, stringify to some date string, and provide all the neat-o-keen methods you want it to have. Works for me. Frankly, I think we're in violent agreement here. Sounds like it. I don't really care if it's built in or comes in a module. I do think that date manipulation is common enough that, if it's in a module, the module should come in the basic set. I met a guy once who made his living doing Java programming. I asked him what he liked about Java and he said Nothing. I hate it. I only do it because it pays. He then went on to list the reasons he hated it--high on the list was that Java is not good at date manipulation. Personally, I've done so little Java that I can't really speak to the accuracy of his statements, but the message has stuck with me--date manipulation is important, and needs to be got right. To put it another way--it's one of those hard things that Perl 6 is trying to make easy. --Dks
Re: Parrot makefile on Win32
On Tue, 31 May 2005 07:07:28 -0700, [EMAIL PROTECTED] (Jerry Gay) wrote: On 5/31/05, Nigel Sandever [EMAIL PROTECTED] wrote: The parrot makefile has several places where nmake baulks at the length o= f the expanded command lines. =20 though you weren't explicit, i suspect you're using the ms c++ toolkit to build parrot on win32. some months ago, i ran into the same problem. since i have switched to msvc, i have not ran into any command-line length problems, nor have i read any reports of these problems with cygwin or mingw. jerry, That was the clue-bat I needed. A bug in the pugs makefile where it was looking for 'nmake' rather than 'nmake.exe' caused it to download nmake v1.5. The ordering in my path meant that it, was being found before nmake v7 (or v8). Deleting it, allowed v7 to be found and Parrot now builds correctly. It might be worth mentioning this nmake version dependancy in readme.win32 where it also suggests getting nmake v1.5. ~jerry Thanks for your help. njs.
Re: date and time formatting
On Tue, May 31, 2005 at 01:11:21PM -0500, Rod Adams wrote: Nathan Gray wrote: possibly as an strftime() pattern. Can we please make sure that strftime() is _not_ OS dependent like the POSIX version is now? I don't mind an OS dependent strftime() as long as we have some formatter that is OS independent. I expect that strftime() will eventually fall into disuse as people use the newer, better formatters. -Scott -- Jonathan Scott Duff [EMAIL PROTECTED]
Re: reduce metaoperator on an empty list
On Mon, May 23, 2005 at 08:54:19PM +, [EMAIL PROTECTED] wrote: : : There are actuall two usefull definition for %. The first which Ada calls 'mod' always returns a value 0=XN and yes it has no working value that is an identity. The other which Ada calls 'rem' defined as follows: : : Signed integer division and remainder are defined by the relation: : : A = (A/B)*B + (A rem B) : :where (A rem B) has the sign of A and an absolute value less than the absolute value of B. Signed integer division satisfies the identity: : : (-A)/B = -(A/B) = A/(-B) : : It does have a right side identity of +INF. I think % should behave as Perl 5 has it, especially insofar as it coerces to integer. That doesn't mean we can't have mod and/or rem variants that have other semantics. Infix operators are pretty much in their own namespace anyway, so they won't clobber sub names. Larry
Re: comprehensive list of perl6 rule tokens
On Thu, May 26, 2005 at 11:19:42AM -0500, Patrick R. Michaud wrote: : Do we still have the rule syntax, or was that abandoned in : favor of ?rule ? (I know there are still some remnants of ... : in S05 and A05, but I'm not sure they're intentional.) It's gone, though we're reserving it for something else we haven't thought of yet. :-) Larry
Re: Sub call resolution
On Mon, May 30, 2005 at 08:39:57AM +, Luke Palmer wrote: : Okay, I'd like to set myself straight. Sanity check: : : bar($foo, $baz); # looks for subs (lexical then package), and : falls back to MMD Er, no. : $foo.bar($baz);# looks in ref($foo), then falls back to MMD : : If this is correct, can we simplify the latter to mean MMD only ? : Would there be a more symmetric MMD only form? bar($foo, $baz) is the MMD form. However, MMD is defined to pay attention to lexical scoping, and if the innermost definition of the sub isn't multi, it reverts to ordinary sub dispatch. If the innermost definition is multi, then all multies out to a scope that is not multi are considered. Basically, all sub calls are inherently MMD, but ordinary subs are a degenerate wildcard case that hide any outer definitions. Larry
Keys
Since this is coming back up, and a ref's in order... The way keyed access is supposed to work is this. A key structure is an array of three things: 1) A key 2) A key type 3) A 'used as' type The key can be an integer, string, or PMC, and is, well, the key. The thing we use to go looking up in an aggregate. The key type notes the type of a key -- whether it's an integer, a string, or a PMC. Nothing at *all* fancy, basically a what thing is in the key union slot. The 'used as' type indicates whether this key is to be used to do a by-integer-index (array) access or by-string-index (hash) access. So, code like: $a{'foo'} would generate a key struct that looks like: 'foo' string as-hash while $a['foo'] generates: 'foo' string as-integer and $a{$b} generates $b PMC as-hash and $a{3} generates 3 integer as-hash *If* a PMC supports it, it may complain if the basic type is incorrect (that is, you pass in a string for array access) but generally that's a bad thing -- the PMC should just convert. (All the languages we care about do this, as far as I know) Keys are multidimensional -- that is, we support real multidimensional arrays, hashes, arrays of hashes, hashes of arrays, and so on. That means BASIC code like: A[1,2,3] generates a key that looks like: 1 integer as-integer 2 integer as-integer 3 integer as-integer and perl code like: $a{'a'}[2]{$b} *should* get you a structure like: 'a' string as-hash 2 integer as-integer $b pmc as-hash It is *perfectly* valid to pass in a multidimensional key to a one-dimensional aggregate, or an n+m dimensional key to an n-dimensional aggregatge. In that case the aggregate *must* consume as much of the key as it can, use that to fetch out a PMC, and then make a keyed access call to the resulting PMC with the remainder of the key structure. (Those of you old-timers who remember, this is why the key stuff was done as a singly-linked list once upon a time) This scheme is fairly straightforward and has the advantage of allowing true multidimensional data structures (which we really want for space efficiency) and still handling the more legacy one-dimensional aggregates of references scheme that, say, perl 5 uses. -- Dan --it's like this--- Dan Sugalski even samurai [EMAIL PROTECTED] have teddy bears and even teddy bears get drunk
Re: mod/div
On 2005-05-30 05:15, TSa (Thomas Sandlaß) [EMAIL PROTECTED] wrote: Mark Reed wrote: I would really like to see ($x div $y) be (floor($x/$y)) That is: floor( 8 / (-3) ) == floor( -2. ) == -3 Or do you want -2? and ($x mod $y) be ($x - $x div $y). Hmm, since 8 - (-3) == 11 this definition hardly works. Sorry. As you surmised, I left off a multiplication. ($x mod $y) should be ($x - $y * ($x div $y)). But even with $q = floor( $x / $y ) and $r = $x - $q * $y we get 8 - (-3) * (-3) == -1 where I guess you expect -2. Why would I expect -2? I don't actually have an preconceptions for negative divisors. But after just now taking a second to think about it, I would expect it to generalize such that 0 = abs($r) abs($y), with sgn($r) in {0, sgn($y)}. So having (8 div -3) == -3 and (8 mod -3) == -1 works fine, especially since it's consistent with (-8 div 3) == -3 and (-8 mod 3) == 1, as given by my (corrected) formulae above. Looks like you want some case distinction there on the sign of $x. Absolutely not! My entire goal is to avoid ever having to do something like this: if ($x 0) { $y = formula1($x); } elsif ($x == 0) { $y = formula2($x); } else { $y = formula($x); } At least, not in cases where the intended result is consistent across 0. Lots of date arithmetic falls into this category, and works beautifully with the definitions above. It lets me do things without bounds checking and correct the ranges later, because, e.g., plugging in January -20, 0 AD yields the correct result for December 11, 2 BC. Such calculations break dramatically across 0 if you use the definition found in some C implementations, where (-3 mod 5) == -3. If there is a definition that needs no special casing then it is the euclidean definition that 0 = $r abs $y. In which case, for or your example of 8 == $q * (-3) + $r, $q == -2 and $r == +2? Seems odd to me that just swapping the signs (from -8,3 to 8,-3) yields completely different numbers like that.
Re: comprehensive list of perl6 rule tokens
On Tue, May 31, 2005 at 01:20:57PM -0700, Larry Wall wrote: On Thu, May 26, 2005 at 11:19:42AM -0500, Patrick R. Michaud wrote: : Do we still have the rule syntax, or was that abandoned in : favor of ?rule ? (I know there are still some remnants of ... : in S05 and A05, but I'm not sure they're intentional.) It's gone, though we're reserving it for something else we haven't thought of yet. :-) Excellent. I'll start updating S05 and A05 to match. While we're on the topic, can we also bless +alnum-digit as the official syntax instead of +alnum-digit ? I can make that change as well. And I think I have another post brewing regarding the relationship between character classes and subrules, but will save that for a bit later. Pm
Re: (1,(2,3),4)[2]
On Wed, May 25, 2005 at 07:07:02PM -0400, Uri Guttman wrote: : the only advantage in the above case is the different prececences of = : and == which allows dropping of parens with the latter. i don't : consider that so important a win as to be used often. and they are at : equal huffman levels as the =() is matched in length by ==. There's also the fact that == can bind a lazy list, since we've said (if I recall correctly) that == actually does binding rather than assignment, possibly even to the extent that my $b == foo(); declares $b to be an iterator rather than an array ref. Larry
Re: (1,(2,3),4)[2]
On Tue, May 31, 2005 at 03:42:42PM -0700, Larry Wall wrote: : On Wed, May 25, 2005 at 07:07:02PM -0400, Uri Guttman wrote: : : the only advantage in the above case is the different prececences of = : : and == which allows dropping of parens with the latter. i don't : : consider that so important a win as to be used often. and they are at : : equal huffman levels as the =() is matched in length by ==. : : There's also the fact that == can bind a lazy list, since we've said : (if I recall correctly) that == actually does binding rather than : assignment, possibly even to the extent that : : my $b == foo(); : : declares $b to be an iterator rather than an array ref. Though that would seem to imply that *$x slurpy parameters should work that way too, and that's not how they work right now... Larry
Re: Unicode Operators cheatsheet, please!
Rob Kinyon wrote: I would love to see a document (one per editor) that describes the Unicode characters in use and how to make them. The Set implementation in Pugs uses (at last count) 20 different Unicode characters as operators. I have updated the unicode quickref, and started a Perlmonks discussion node for this to be explored - see http://www.perlmonks.org/index.pl?node_id=462246 Sam.
Devel::cover bug?
I'm looking at a bit of output from Devel::Cover that I imagine has to be a bug. I'll try my best to reproduce the HTML output: stmt branch cond sub time code 221862 100 100 _1613639 next if ($line =~ /^\s*[#!]/ || $line =~ /^\s*$/); 0 0 0 0 0 0 That _ is actually a thin red line (but no text). If it helps, here's a slightly modified version of the html: trtd class=h118/td tddiv class=c3221862/divdiv class=c00/divdiv class=c00/divdiv class=c00/div/td tddiv class=c3 title=T/Fa href=XXX--branch.html#L118100/a/div/td tddiv class=c3a href=XXX--condition.html#L118100/a/div/td tddiv class=c0a href=XXX--subroutine.html#L118/a/div/td tddiv1613639/divdiv0/divdiv0/divdiv0/div/td td class=snext if ($line =~ /^\s*[#!]/ || $line =~ /^\s*$/);/td/tr If you look at the subroutine coverage page, it claims that there is a BEGIN block uncovered at that line. Any insights? -kevin
Re: comprehensive list of perl6 rule tokens
On Thu, May 26, 2005 at 11:19:42AM -0500, Patrick R. Michaud wrote: $rule N indirect rule ::$rulename N indirect symbolic rule @rulesN like '@rules' %rulesN like '%rules' { code } N code produces a rule foo()N subroutine returns rule ( code ) N code must return true or backtracking ensues Here the leading tokens are actually $, ::$, @, %, {, , and (, and I suspect we have ?$, ?::$, ?@, and !$, !::$, !@, etc. counterparts. Oops. After re-reading A05 I would now assume we don't have non-capturing counterparts for $rule, @rules, %rules, ... -- they're already non capturing. From A05: [Update: Only rules of the form ident are captured by default. You can use := to force capture of anything else, or the :keepall adverb to capture everything else.] Somewhere I thought I read that $rule captures to $/{'$rule'}, but I don't find it now, so if A05 holds here, then we don't need ?$, ?@, ?::$, etc. (Whew!) Somehow I much prefer A05's formulation, in that only rules of the form ident capture, and we use aliases or parentheses to capture anything else. Thus one can say that +alpha, -alpha, [aeiou], !alpha, ?alpha, $alpha, @alpha, etc. are all non-capturing constructs. Pm
Re: [PATCH]Loop Improvements
From: Dan Sugalski [EMAIL PROTECTED] Date: Tue, 31 May 2005 12:09:05 -0400 At 10:19 AM +0200 5/31/05, Leopold Toetsch wrote: Curtis Rawls (via RT) wrote: This patch makes improvements to the loop struct. Thanks, applied - r8219 BTW: would you like to take a look at the register allocator? It works but consumes enormous amounts of resources for e.g. Dan's Evil Subs[1]. I've here an IIRC slightly modfied version of Bill's original patch, which I could sync to current Parrot. I've noticed quadratic (or worse) compile speed, too. I have a hairy case of only 1000 lines that takes around 5sec to compile; it includes a 700-line @load sub with 450+ $Pxx variables. It goes around the compute_spilling_costs / order_spilling loop in imc_reg_alloc some 120 times before it decides it's done, but I didn't have the time to look farther. (r8203.) Believe me, speeding up compile times would make Dan a Happy Camper(tm) :) -- Dan Me, too. ;-} -- Bob Rogers http://rgrjr.dyndns.org/
Re: Default invocant of methods
On Fri, May 27, 2005 at 10:59:25PM +0200, Ingo Blechschmidt wrote: : Hi, : : what is the default invocant of methods? : : method blarb ($normal_param) {...} : # Same as : method blarb (Class | ::?CLASS $invocant: $normal_param) {...} : # or : method blarb (::?CLASS $invocant: $normal_param) {...} : # ? : : I prefer the latter, as then one can't accidentally call a instance : method on the class -- i.e. : Foo.blarb # will die. It will almost certainly die anyway the moment you try to do something instancely with it. : You can always specify Class as invocant, if you want to have a class : method. Hmm, well, maybe, provided Class is the parent of all possible class classes, but it's not entirely clear we want to assume that. We could get potentially get other kinds of metaclass and dispatcher classes involved, especially if we've inherited things across languages. At some point you have to trust your dispatcher to hand you things you can work with, and that may involve some kinds of structural or role equivalence rather than just class name equivalence. Hmm, maybe Class is really a role then, and anything that does Class can pretend to be one. : Opinions? From the efficieny viewpoint, I'd rather leave it untyped, and rely on the dispatcher to do my type checking. Of course, there are times you'd like the compiler to know that the type of $?SELF is consistent with the current class, but that's a different matter than run-time type checking, which an explicit type tends to imply. Larry
Re: Undef issues
On Tue, May 24, 2005 at 10:53:59PM +1000, Stuart Cook wrote: : I'm not sure whether this behaviour is supposed to be changing. It is. I think we decided to make the value undef, and the function undefine(). (But these days most values of undef really ought to be constructed and returned (or thrown) using fail().) Larry
returns and context
How do I specify the signature of a context-sensitive function? sub foo() returns (what?) { return want ~~ Scalar ?? cheap_integer_result :: List_of_Sheep; } If it were two subs, one would is returns Int and the other List of Sheep. The draft S29 uses things like Int|List to express this kind of thing but that looks weird to me (how would you return a typed junction?). S06 and E06 don't raise this issue. -- Gaal Yahas [EMAIL PROTECTED] http://gaal.livejournal.com/
Re: construction clarification
Carl Franks wrote: I have a class that normally takes a list of named arguments. I also want to be able to handle a single argument. class Foo { multi method new (Class $class: Str $date) { return $class.bless(date = $date); } submethod BUILD ($.date, $.time, $.offset) { # some error checking here } } my $foo = Foo.new('2005-05-30'); # Is this the correct way to handle my scenario? It's *a* correct way. But redundant in this particular case. The universal new() would handle the one-argument call exactly the same as your overloaded new() does. Presumably, however, the one-argument variant would do something else as well. My explicit 'new' method should only handle the case of a single argument - otherwise the 'new' method inherited from Class will handle a list of named arguments. Correct. My explicit BUILD submethod is called, regardless of which 'new' method is called, correct? Yes. It's invoked by bless(). Damian
Re: Declarations of constants
Adam Kennedy wrote: Forgive my ignorance here, but for all of these different ways of doing constants, will they all optimize (including partial evaluation/currying) at compile/build/init/run-time? my $gravity is constant = 10; # One significant figure sub time_to_ground ($height, $accel) { ...acceleration math... } my $time = time_to_ground( 500, $gravity ); ... thus simplifying internally to my $time = 1234; No. But you could get the effect by explicitly asking for time_to_ground() to be called at compile-time: my $gravity is constant = 10; # One significant figure macro time_to_ground ($height, $accel) { ...acceleration math... } my $time = time_to_ground( 500, $gravity ); Damian
Re: returns and context
Gaal Yahas wrote: How do I specify the signature of a context-sensitive function? sub foo() returns (what?) { return want ~~ Scalar ?? cheap_integer_result :: List_of_Sheep; } If it were two subs, one would is returns Int and the other List of Sheep. The draft S29 uses things like Int|List to express this kind of thing but that looks weird to me (how would you return a typed junction?). S06 and E06 don't raise this issue. Being that I'm the one who wrote it that way, it doesn't look at all weird to me to do it that way. =) I suspect a typed junction would look like : Junction of Int|Str. -- Rod Adams
Re: reduce metaoperator on an empty list
All this discussion of identity defaults for reductions has been very interesting and enlightening. But it seems to me that the simplest correct behaviour for reductions is: 2+ args: interpolate specified operator 1 arg: return that arg 0 args: fail (i.e. thrown or unthrown exception depending on use fatal) Then, as Brad previously reminded us all, to cover the possibility of empty arg lists, you just prepend the desired identity value: $sum = [+] 0, @values; $prod = [*] 1, @values; $prob = [*] 0, @probs; or else, as Stuart observed, postpend them as a default: $sum = ([+] @values err 0); $prod = ([*] @values err 1); $prob = ([*] @probs err 0); Damian
Re: reduce metaoperator on an empty list
Damian Conway wrote: 0 args: fail (i.e. thrown or unthrown exception depending on use fatal) ... $sum = ([+] @values err 0); $prod = ([*] @values err 1); $prob = ([*] @probs err 0); Just wanted to check, if I've said use fatal: will that err 0 DWIM, or will the fatalness win? Would I need to write
Re: reduce metaoperator on an empty list
Dave Whipp wrote: Damian Conway wrote: 0 args: fail (i.e. thrown or unthrown exception depending on use fatal) ... $sum = ([+] @values err 0); $prod = ([*] @values err 1); $prob = ([*] @probs err 0); Just wanted to check, if I've said use fatal: will that err 0 DWIM, That depends what you mean. ;-) Under use fatal you'll get an exception if you don't provide any args. or will the fatalness win? The fatalness will win. Would I need to write Yes. :-) And what you'd need to write would be: $sum = (try{ [+] @values } err 0); Damian
Re: loop/do {...} while EXPR;
On Mon, May 30, 2005 at 01:42:40PM +, Luke Palmer wrote: : Because do {...} is a part of the language, while or no while. Perl 6 : is supposed to die if you say do {...} while, which isn't implemented : in pugs yet. In particular, we'd like do {...} while to die because do {...} is now defined to be the once loop, and you can't put two different loop specifiers on the same block. (Bare blocks are no longer once loops as they are in Perl 5. That functionality has moved to do.) Larry
Re: construction clarification
On Mon, May 30, 2005 at 05:00:26PM +0100, Carl Franks wrote: : I have a class that normally takes a list of named arguments. : I also want to be able to handle a single argument. : : class Foo { : multi method new (Class $class: Str $date) { : return $class.bless(date = $date); : } : : submethod BUILD ($.date, $.time, $.offset) { : # some error checking here : } : } : : my $foo = Foo.new('2005-05-30'); : : # : Is this the correct way to handle my scenario? I think you probably want a multi sub there. In the current plan, multi method is an MMD dispatch that occurs *after* dispatch to the class. (Though it's possible we changed that and I've just forgotten...) : My explicit 'new' method should only handle the case of : a single argument - otherwise the 'new' method : inherited from Class will handle a list of named : arguments. Saying multi sub new (Class $class, Str $date) {...} should have that effect, provided you call it as new(Foo,'2005-05-30'). However, when called as Foo.new('2005-05-30'), all the multi subs defined in the class hierarchy add themselves to the dispatch list as if they were ordinary single-invocant methods, with additional invocants treated as tie-breakers in the case that there are multiple multi-subs in a single class. Or to put it another way, all class-based instances of multi sub behave like multi method when invoked via SMD. It dispatches first to the class, then looks to see if there are multiple methods of that name within the class. This is probably not what you want in this case, unfortunately. We have specified that there's some kind of pragmatic way to turn Foo.new() into MMD from the get-go, but that seems a bit crude. So maybe that kind of dispatch needs to be reformulated a bit. Perhaps Foo.new() should be forced to ordinary MMD any time any parent class defines multi sub new, so that all invocants are considered. Or maybe Foo.new() is still not quite ordinary MMD in that it only considers that subset of multis defined in Foo or parent classes of Foo. If that dispatch fails it retries under ordinary MMD, including methods defined outside of the classes in question. (Or another way to say that might be that such non-class multis are always ordered after all the class multis when invoked as Foo.new('2005-05-30'), unlike with new(Foo,'2005-05-30'), which pays no attention to class boundaries.) : My explicit BUILD submethod is called, regardless : of which 'new' method is called, correct? Yes, as long as the constructor in question calls the .bless built-in, which always BUILDALL. (Though you could, of course, also redefine BUILDALL evilly to bypass calling the correct BUILDs. But don't do that.) Larry
Re: reduce metaoperator on an empty list
Damian Conway wrote: And what you'd need to write would be: $sum = (try{ [+] @values } err 0); The err ... idiom seems too useful to have it break in this case. Afterall, the purpose of err 0 is to tell the stupid computer that I know what to do with the empty-array scenario. Feels like fine grained control over fatalness is needed (and not just per-function). For example use fatal :void_context_only would be nice, but wouldn't help in this case. This needs use fatal :void_or_assign.
Re: reduce metaoperator on an empty list
Dave Whipp wrote: Damian Conway wrote: And what you'd need to write would be: $sum = (try{ [+] @values } err 0); The err ... idiom seems too useful to have it break in this case. Afterall, the purpose of err 0 is to tell the stupid computer that I know what to do with the empty-array scenario. Feels like fine grained control over fatalness is needed (and not just per-function). For example use fatal :void_context_only would be nice, but wouldn't help in this case. This needs use fatal :void_or_assign. What it probably needs is: use fatal :untested That is, die unless the failed result is in a boolean or definedean context. This might even be a more reasonably dwimmy default, with 'use fatal :always' being required to get always throw the exception. Damian
Re: reduce metaoperator on an empty list
Dave Whipp wrote: Damian Conway wrote: And what you'd need to write would be: $sum = (try{ [+] @values } err 0); The err ... idiom seems too useful to have it break in this case. Afterall, the purpose of err 0 is to tell the stupid computer that I know what to do with the empty-array scenario. Feels like fine grained control over fatalness is needed (and not just per-function). For example use fatal :void_context_only would be nice, but wouldn't help in this case. This needs use fatal :void_or_assign. Seems to me that Cerr should have an implied Ctry{...} on it's lhs. Unless we spell that Cerror. -- Rod Adams
re: Keys
The 'used as' type indicates whether this key is to be used to do a by-integer-index (array) access or by-string-index (hash) access. Why not extend this to properties, too? foo['hello'] becomes 'hello' string as-offset foo{'hello'} becomes 'hello' string as-hash foo.hello becomes 'hello' string as-property __ Do you Yahoo!? Yahoo! Mail - You care about security. So do we. http://promotions.yahoo.com/new_mail
Re: reduce metaoperator on an empty list
Damian Conway skribis 2005-06-01 10:44 (+1000): 2+ args: interpolate specified operator 1 arg: return that arg 0 args: fail (i.e. thrown or unthrown exception depending on use fatal) Following this logic, does join( , @foo) with [EMAIL PROTECTED] being 0 fail too? I dislike this, and would prefer [op] with no elements to simply return whatever () returns: an empty list in list context, undef in scalar context. Juerd -- http://convolution.nl/maak_juerd_blij.html http://convolution.nl/make_juerd_happy.html http://convolution.nl/gajigu_juerd_n.html
Re: reduce metaoperator on an empty list
Juerd asked: 2+ args: interpolate specified operator 1 arg: return that arg 0 args: fail (i.e. thrown or unthrown exception depending on use fatal) Following this logic, does join( , @foo) with [EMAIL PROTECTED] being 0 fail too? No. It returns empty string. You could think of Cjoin as being implemented: sub join (Str $sep, [EMAIL PROTECTED]) { reduce { $^a ~ $sep ~ $^b } , @list } Just as Csum is probably implemented: sub sum ([EMAIL PROTECTED]) { [+] 0, @list } I dislike this, and would prefer [op] with no elements to simply return whatever () returns: an empty list in list context, undef in scalar context. I'd have assumed that empty list in list context, undef in scalar context *is* what Cfail returns when Cuse fatal isn't in effect. Damian
Perl 6 Summary for 2005-05-24 through 2005-05-31
Perl 6 Summary for 2005-05-24 through 2005-05-31 All~ Welcome to another Perl 6 summary, brought to you by Aliya's new friends, Masha Nannifer and Philippe, and my own secret running joke. Without further ado, I bring you Perl 6 Compiler. Perl 6 Compiler method chaining Alex Gutteridge discovered that he couldn't chain attribute access like $bowl.fish.eyes.say; in Pugs. Later he provided his example in test form (in case anyone wanted to add it). Maybe they were added to the test suite, maybe not: Warnock applies. http://xrl.us/f95k Pugs link issues on Debian Sid BÁRTHÁZI András was having trouble making Pugs work on Debian Sid with perl 5 support. Autrijus provided helpful pointers. I assume from his final silence that the final pointer worked. http://xrl.us/f95m Pugs.AST.* compilation Samuel Bronson wanted to speed up the compilation of Pugs.AST.* modules by turning off optimizations. Autrijus told him that this was a core module that needed it speed, and optimizations would stay. http://xrl.us/f95n Pugs.Types export list Samuel Bronson added an export list to Pugs.Types. Autrijus happily applied it and send him a commit bit. http://xrl.us/f95o export withArgs from Main Samuel Bronson added an export to Main. Samuel Bronson happily applied it himself this time. http://xrl.us/f95p out-of-date hs-plugins Vadim was having trouble compiling Pugs with Parrot support. Autrijus helped him fix his problem, and there was much rejoicing. http://xrl.us/f95q chomp problem Jens Rieks found a problem with chomp and submitted a test. Warnock applies. http://xrl.us/f95s Pugs makefile issue Grégoire Péan noticed that pugs was creating a useless Pugs.exe.bat. Autrijus asked if he would be willing to investigate a patch. He responded that he would put it in his queue. http://xrl.us/f95t loop or do Gerd Pokorra wondered why do { ... } was in Pugs reasoning that loop { ... } while was the correct thing. Luke Palmer explained that do { ... } was part of the with or without a postfix while . http://xrl.us/f95u PxPerl 5.8.6.2 with Pugs 6.2.5 and Parrot 0.2.0 Grégoire Péan announced that the release of PxPerl 5.8.6.2 which includes Pugs 6.2.5 and Parrot 0.2.0. This means that windows folk can test Pugs and Parrot without having to fight with compilers. http://xrl.us/f95v BUILD errors Carl Franks was confused by that handling of a named argument to a constructor. He asked for confirmation but none was provided. Perhaps this poor summary save him. http://xrl.us/f95w whitespace and function calls David D Zuhn didn't know that whitespace between and function call and its parentheses was forbidden. Carl told him that and about the .() variant which allows whitespace. http://xrl.us/f95x Pug's make cean issues LONG commands Carl Franks noticed that make clean issued a command so long that it broke his nmake. Fortunately he had a really old nmake and updating fixed the problem. http://xrl.us/f95y Parrot thr_windows.h with MinGW François Perrad provided a patch fixing two compilation problems in thr_windows.h. Warnock applies. http://xrl.us/f95z Parrot Slides? Adam Preble posted a request for slides and notes on Parrot and Perl 6 for a presentation he was working on. Many people provided links in various languages. I usually steal from Dan's presentations when I need something like this... http://xrl.us/f952 Problems with Perl 5.6.1 François Perrad had a problem building Parrot with MinGW and Perl 5.6.1. The problem was related to windows and its binary vs text distinction. This problem will also crop up if you ever try to seek on files in windows. Not that I have ever lost several days debugging that problem. http://xrl.us/f953 ordered hash thoughts Leo posted his thoughts on a modification to ordered hash as adding a new element by index breaks the string hashing part of it. Dan suggested that the ordered hash just pitch exceptions in the bad cases as it was designed to be lightweight and fast. http://xrl.us/f954 subrules tests Dino Morelli provided a patch adding tests for subrules to PGE. Warnock applies. http://xrl.us/f955 python on parrot Bloves inquired as to the state of python on parrot. The phrasing of the question itself provided some confusion. Michal Wallace provided a link to pirate, hoping it would help. http://xrl.us/f956 Resizable*Array defeats list.c Slowly but steadily my {Fixed,Resizable}typeArray PMCs are defeating the less consistent array implementations. Leo offered the job of slaying list.c to any interested partied. Jerry Gay expressed interest. http://xrl.us/f957
RE: reduce metaoperator on an empty list
-Original Message- From: Damian Conway [mailto:[EMAIL PROTECTED] Sent: Tuesday, May 31, 2005 11:14 PM To: perl6-language@perl.org Subject: Re: reduce metaoperator on an empty list Juerd asked: 2+ args: interpolate specified operator 1 arg: return that arg 0 args: fail (i.e. thrown or unthrown exception depending on use fatal) Following this logic, does join( , @foo) with [EMAIL PROTECTED] being 0 fail too? No. It returns empty string. You could think of Cjoin as being implemented: sub join (Str $sep, [EMAIL PROTECTED]) { reduce { $^a ~ $sep ~ $^b } , @list } Just as Csum is probably implemented: sub sum ([EMAIL PROTECTED]) { [+] 0, @list } If this were the case, then join '~', 'a', 'b', 'c' would equal '~a~b~c' instead of 'a~b~c' Joe Gottman
Re: [PATCH]Loop Improvements
At 10:19 AM +0200 5/31/05, Leopold Toetsch wrote: Curtis Rawls (via RT) wrote: This patch makes improvements to the loop struct. Thanks, applied - r8219 BTW: would you like to take a look at the register allocator? It works but consumes enormous amounts of resources for e.g. Dan's Evil Subs[1]. I've here an IIRC slightly modfied version of Bill's original patch, which I could sync to current Parrot. Yeah, I'd like to take a crack or two at it. Could someone(s) send me some tests, such as Dan's Evil code? And also any in-progress patches? Thanks! -Curtis Rawls
Re: date and time formatting
Rob Kinyon wrote: What I'm trying to get at isn't that DateTime's API should be preserved. I'm saying that the concept of DateTime should be ported. Core or not core - it doesn't matter. When use'd (or installed), it should override now() (and anyone else we can think of) to return an object that DWIMs, plus provides the interface you've outlined below. I've made a start on this. See ext/Date in pugs. I don't think that your views are necessarily contrary. The biggest reason I didn't use DateTime was that I found it awkward for the common case; most of the time I just want to stuff in an ISO8601 date. I also don't like implicit normalisation to seconds underneath the hood when I'm doing basic date calculations, and the way that the DateTime base class is inherantly based on the Gregorian calendar. The Date and Duration roles are extremely minimal; see http://svn.openfoundry.org/pugs/ext/Date/lib/Date.pm http://svn.openfoundry.org/pugs/ext/Date/lib/Duration.pm The major API is described at: http://svn.openfoundry.org/pugs/ext/Date/lib/Date/Gregorian.pod This module is supposed to be somewhere between DateTime and Class::Date, with built-in ISO-8601 support (as it's the standard ;)). With a bit of luck, all Date implementation can share this `Date' Role, and Gregorian calendar modules share the `Date::Gregorian' Role, so that the multitude of implementations that crop up will be mutually exchangable, and the simple case fast, efficient and useful. Sam.
Re: returns and context
Rod Adams wrote: How do I specify the signature of a context-sensitive function? sub foo() returns (what?) { return want ~~ Scalar ?? cheap_integer_result :: List_of_Sheep; } I suspect a typed junction would look like : Junction of Int|Str. Not quite. AIUI that means a Junction of which the members are Int or Str. This is how I've been writing it: sub foo() returns Scalar|List { return want ~~ Scalar ?? cheap_integer_result :: List_of_Sheep; } I think the default return type of unlabeled subs would be: returns Void|Scalar|List but of course $?SELF =:= none(@Larry) ;) Sam.
Re: r8223 - HLL support 4
Cool. This means I don't have to do a lookup everytime I want to use one of my own types (per type per sub). Tcl will be patched shortly to take advantage. Leopold Toetsch wrote: The first steps for HLL language and type support are in. You can now dynamically load a HLL _group PMC library by just including a .HLL line in PASM/PIR, e.g. .HLL Tcl, tcl_group ... $P0 = new .TclInt # Integer constant Note that $P0 = new TclInt also seems to work (no dot) The .HLL pragma registers at compile time the given HLL language name within src/hll.c and loads the given library with Parrot_load_lib(). Please note that this does not yet work for .pbc files as the HLL isn't stored in the PBC yet (this will come soon). See also t/dynclass/foo.t for 2 examples. Have fun, leo
Re: Perl 6 Summary... p6rules
Thank you for the summary, Matt I have a correction, though: subrules tests Dino Morelli provided a patch adding tests for subrules to PGE. Warnock applies. http://xrl.us/f955 This and my other two patches to p6rules tests (RT #35950, 35971, 35994) have not yet been applied. -Dino -- .~.Dino Morelli /V\email: [EMAIL PROTECTED] /( )\ weblog: http://categorically.net/d/blog/ ^^-^^ preferred distro: Debian GNU/Linux http://www.debian.org
Re: returns and context
Sam Vilain wrote: Rod Adams wrote: How do I specify the signature of a context-sensitive function? sub foo() returns (what?) { return want ~~ Scalar ?? cheap_integer_result :: List_of_Sheep; } I suspect a typed junction would look like : Junction of Int|Str. Not quite. AIUI that means a Junction of which the members are Int or Str. Yep, which is how I interpreted the question inside the parens inside the paragraph, completely ignoring the question in the code block, since Gaal answered it himself. -- Rod Adams
Re: reduce metaoperator on an empty list
Joe Gottman pointed out: No. It returns empty string. You could think of Cjoin as being implemented: sub join (Str $sep, [EMAIL PROTECTED]) { reduce { $^a ~ $sep ~ $^b } , @list } If this were the case, then join '~', 'a', 'b', 'c' would equal '~a~b~c' instead of 'a~b~c' Good point. Thanks. Make that: sub join (Str $sep, [EMAIL PROTECTED]) { reduce { $^a ~ $sep ~ $^b } @list || } Presuming (of course) that my earlier plea that || should preserve context across both operands is granted. ;-) Damian
Re: Perl 6 Summary... p6rules
On Tue, May 31, 2005 at 11:58:12PM -0400, Dino Morelli wrote: Thank you for the summary, Matt I have a correction, though: subrules tests Dino Morelli provided a patch adding tests for subrules to PGE. Warnock applies. http://xrl.us/f955 This and my other two patches to p6rules tests (RT #35950, 35971, 35994) have not yet been applied. My apologies for taking so long to apply these patches; I've been out of town for much of the past week and barely keeping up with email. Also, since 35971 is a bit of a big change I wanted to review it a bit -- it'll happen within the next twelve hours. I *really* appreciate the tests -- they've been very helpful and useful. Pm
Re: r8223 - HLL support 4
Done. Thanks! William Coleda wrote: Cool. This means I don't have to do a lookup everytime I want to use one of my own types (per type per sub). Tcl will be patched shortly to take advantage. Leopold Toetsch wrote: The first steps for HLL language and type support are in. You can now dynamically load a HLL _group PMC library by just including a .HLL line in PASM/PIR, e.g. .HLL Tcl, tcl_group ... $P0 = new .TclInt # Integer constant Note that $P0 = new TclInt also seems to work (no dot) The .HLL pragma registers at compile time the given HLL language name within src/hll.c and loads the given library with Parrot_load_lib(). Please note that this does not yet work for .pbc files as the HLL isn't stored in the PBC yet (this will come soon). See also t/dynclass/foo.t for 2 examples. Have fun, leo