RE: array/hash manipulation [was :what's with 'with'?]
Sterin, Ilya [EMAIL PROTECTED] wrote: Just one question, how would merge behave on two different sized arrays. @a = (1..5); @b = (1..10); merge(@a, @b); ##Would return (1,1,2,2,3,3,4,4,5,5,?? Would it stop on the shortest array. Couldn't quite find such explanation in the RFC. I don't think I specified this in the RFC, since I remember having some debates with Damian and others about it that weren't resolved. Now that I've had a chance to think about this some more, I think the correct behaviour is for the shorter list to reset to the start and continue. It is this behaviour that is the source of J and APL's broadcasting flexibility. For details see: http://www.jsoftware.com/primer/agreement.htm -- Jeremy Howard [EMAIL PROTECTED]
RE: array/hash manipulation [was :what's with 'with'?]
-Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Saturday, July 21, 2001 5:50 AM To: Sterin, Ilya; 'raptor '; Perl 6 Language Subject: RE: array/hash manipulation [was :what's with 'with'?] Sterin, Ilya [EMAIL PROTECTED] wrote: Just one question, how would merge behave on two different sized arrays. @a = (1..5); @b = (1..10); merge(@a, @b); ##Would return (1,1,2,2,3,3,4,4,5,5,?? Would it stop on the shortest array. Couldn't quite find such explanation in the RFC. I don't think I specified this in the RFC, since I remember having some debates with Damian and others about it that weren't resolved. Now that I've had a chance to think about this some more, I think the correct behaviour is for the shorter list to reset to the start and continue. That would be one possible way, but when comparing two array of different lengths, I guess I would expect undef to compare to the elements of the longest array that bypassed the length of the shortest array, but that wouldn't be a problem, just extra code to undef all elements of the shortes array to equal the length of the longest array. $shor_arr[$_] = undef for (($#long_arr - $#shor_arr)..$#long_arr); But now I am trying to figure out, if you are not comparing elements of the array and for example if you need to loop through 3 arrays at the same time, but you need to know, whithin the loop, when the shortest array's last element is reached, how would that be accomplished within the loop if the array would just be reset and continue until the longest end is reached? Ilya It is this behaviour that is the source of J and APL's broadcasting flexibility. For details see: http://www.jsoftware.com/primer/agreement.htm -- Jeremy Howard [EMAIL PROTECTED]
RE: array/hash manipulation [was :what's with 'with'?]
-Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Saturday, July 21, 2001 5:50 AM To: Sterin, Ilya; 'raptor '; Perl 6 Language Subject: RE: array/hash manipulation [was :what's with 'with'?] Sterin, Ilya [EMAIL PROTECTED] wrote: Just one question, how would merge behave on two different sized arrays. @a = (1..5); @b = (1..10); merge(@a, @b); ##Would return (1,1,2,2,3,3,4,4,5,5,?? Would it stop on the shortest array. Couldn't quite find such explanation in the RFC. I don't think I specified this in the RFC, since I remember having some debates with Damian and others about it that weren't resolved. Now that I've had a chance to think about this some more, I think the correct behaviour is for the shorter list to reset to the start and continue. That would be one possible way, but when comparing two array of different lengths, I guess I would expect undef to compare to the elements of the longest array that bypassed the length of the shortest array, but that wouldn't be a problem, just extra code to undef all elements of the shortes array to equal the length of the longest array. $shor_arr[$_] = undef for (($#long_arr - $#shor_arr)..$#long_arr); But now I am trying to figure out, if you are not comparing elements of the array and for example if you need to loop through 3 arrays at the same time, but you need to know, whithin the loop, when the shortest array's last element is reached, how would that be accomplished within the loop if the array would just be reset and continue until the longest end is reached? Ilya It is this behaviour that is the source of J and APL's broadcasting flexibility. For details see: http://www.jsoftware.com/primer/agreement.htm -- Jeremy Howard [EMAIL PROTECTED]
as long as we are discussing 'nice to have's...
First topic: I discovered today that I had forgotten to put 'use strict' at the top of one of my modules...it was in the script that _used_ the module, but not in the module itself. Putting it in instantly caught several annoying bugs that I'd been trying to track down. It would be nice if there was a use strict 'recursive'; option that you could set in a script or module (package, whatever) which would force all the modules it used to operate under strict. Perhaps we could even extend it to (something like): use strict 'recursive:except' qw(DBI, CGI, MyFoo); I don't care about the syntax, as long as it's clear what's intended (which I hope this is). ( PS As often happens with Perl, it may well be that this already exists and I've just never run across it. If so, I will happily RTFM if someone will just point me to the appropriate part of the FM. ) Second topic: The debugger API PDD that I submitted a couple of days ago suggested that we incorporate a profiler into the core. What do people think of this idea? Dave
Re: as long as we are discussing 'nice to have's...
The debugger API PDD that I submitted a couple of days ago suggested that we incorporate a profiler into the core. What do people think of this idea? I think that with a clean API, many third-party profilers could and would be created. I am skeptical of the value of putting it in the core, when a well-designed API would exist specifically with the end of getting some of that work out of the porter's pockets, and instead allow the World to develop their own, much as it currently happens with Java.
Re: as long as we are discussing 'nice to have's...
On Sat, Jul 21, 2001 at 02:47:43PM -0700, Dave Storrs wrote: I discovered today that I had forgotten to put 'use strict' at the top of one of my modules...it was in the script that _used_ the module, but not in the module itself. Putting it in instantly caught several annoying bugs that I'd been trying to track down. A better way might be something which simply detects if you forgot to use strict. Stick that in your Makefile.PL and it will scan your libraries everytime and report back stupid mistakes. I'm working on something like that, just having a little trouble nailing down how to detect 'use strict' from the B compiler. It's possible, I know that much. It would be nice if there was a use strict 'recursive'; option that you could set in a script or module (package, whatever) which would force all the modules it used to operate under strict. HUGE MASSIVE PROBLEM HERE! This might be useful if *all* the modules you use and *all* the modules which are then used are *all* under your control and that none of them are have elected to *not* use strict for some reason (like Exporter, which would be silly to use strict 'refs'). Otherwise, you're just causing unnecessary bugs. Attempting to apply blanket compile-time style requirements recursively runs into massive problems like this. It's all or nothing. Taint mode currently has the same problem, its all or nothing. You turn on taint, and every single module you use has to behave. This might be good for security, but it makes it really, really hard to use for all practical purposes. The basic problem is any sort of Cuse strict recursive boils down I am going to enforce my style upon every piece of code I run into, whether or not I wrote it and that rapidly gets nasty. Taint has this same problem, but it's supposed to be paranoid. strict isn't. Second topic: The debugger API PDD that I submitted a couple of days ago suggested that we incorporate a profiler into the core. What do people think of this idea? You mean like Devel::DProf, the profiler that's already in the core? ;) And is this new debugger API like the current debugger API, DB.pm? (Actually, I hope it isn't. Just making sure you're aware of what's already there.) -- Michael G Schwern [EMAIL PROTECTED] http://www.pobox.com/~schwern/ Perl6 Quality Assurance [EMAIL PROTECTED] Kwalitee Is Job One
pragma adverbs/attributes
use strict 'recursive'; If this is not yet done and is deemed a good idea, I'd add that it seems to me to be equally applicable to perl 5. Further, considering the more general [pragma] 'recursive'; I can imagine pragma adverbs / attributes. I searched p5p and p6all for things like pragma attributes (and recursive pragma) and didn't find anything relevant. It would seem natural (if not already going to be valid in p6) to allow something like: use foo :bar :quux; which clearly echoes: use foo qw( :bar :quux ); Perhaps pragma attributes could be used to make some common cases and highly visible uses of qw() rather prettier. Perhaps not. Regardless of the latter point, I could imagine: :recursive :excl :incl etc. I could further imagine a metapragma that makes these attributes available and used: use pragma 'adverbs'; Or maybe this functionality is added to: use attributes; I have no idea if any of this stuff would need to be in the perl compiler core. I can see a generic recursive pragma attribute being problematic if used anywhere but the file fed to perl, because then it becomes rather difficult to tell which pragma are in effect when looking at some source. (Otoh, for plain use strict, this seems pretty irrelevant.)