Re: NaN semantics
BTW, I was thinking once that numeral literals like 4k or 10G (meaning 4*2**10, 10*2**30) would be very nice. What do you think? I think the meaning of the suffices are sufficiently vague as to make me uncomfortable supporting them. Is 1K 1024 or 1000? I can make a good case for both, and that's never a good sign. There's always the possibility of supporting SI's binary prefixes ;) http://physics.nist.gov/cuu/Units/binary.html -- Trond Michelsen
Re: Multiple classifications of an object
On Mon, Jun 25, 2001 at 12:47:41PM -0700, David Whipp wrote: What's wrong with multiple inheritance? You have to create a whole load of extra classes whose only purpose is to define a list of superclasses. Compare: This sounds a lot like the case I had with a buzzword type=cheesycontent-syndication/buzzword system I'm working on. Basically, I wanted to create a Feed-object that inherits from any Fetch-class and any Parse-class. Something like this: bless $obj1, qw/Fetch::LWP Parse::HTML/; bless $obj2, qw/Fetch::POP3 Parse::CSV/; but then I realized that since the Fetch and Parse-classes never diddled with $self, I didn't need inheritance at all. Delegation was more than good enough in my case. I ended up with something like this (simplified a bit): package Feed; sub new { my $class = shift; my %args = @_; my $f = $args{FETCH}-new; my $p = $args{PARSE}-new; bless {FETCH = $f, PARSE = $p} = $class; } sub fetch { my $self = shift; return $self-{FETCH}-fetch(@_); } sub parse { my $self = shift; return $self-{PARSE}-parse(@_); } sub cleanup { my $self = shift; $self-{FETCH}-cleanup(@_); $self-{PARSE}-cleanup(@_); } etc.. which works very well. The downside is of course that I need to make a small stub for every single function I want to delegate. Since it's only a few function I need from the classes, it's not a big problem. If you have 50 functions in each class, it could be a hassle. I haven't given it much thought, but I imagine the cleanup-method could be difficoult to implement with inheritance. I don't know if delegation is the solution in your case though. And I certainly can't claim that it is the solution in every multibless case. But it worked for me :) -- Trond Michelsen
Re: Larry's Apocalypse 1
On Mon, Apr 09, 2001 at 10:03:31AM -0400, Dan Sugalski wrote: While I don't know if Larry will mandate it, I would like this code: open PAGE, "http://www.perl.org"; while (PAGE) { print $_; } to dump the HTML for the main page of www.perl.org to get dumped to stdout. Well, this seems innocent enough, but how far do you want to stretch it? Should this work? use lib "http://my.site.org/lib"; If not; why? (except security issues) what about if (-r "http://www.perl.com/") {...} or if (-M "http://www.perl.com/" -M "http://www.python.org/") {...} should opendir (FTP, "ftp://sunsite.uio.no/"); work as expected? Should URLs behave as much like regular files/directories as possible, or should they be limited to a small set of operations (like open()). -- Trond Michelsen
Re: Schwartzian Transform
On Mon, Mar 26, 2001 at 03:36:08PM -0500, Dan Sugalski wrote: because that would require the PSI::ESP module which isn't working yet. Not at all. Simon's example looks like a simple case of memoization. The cache only needs to be maintained for the duration of the sort, and it alleviates the need for complicated map{} operations. The only issue there is whether memoization is appropriate. It could be argued that it isn't (it certainly isn't with perl 5) though I for one I realize that memoization isn't something you want to do on functions that may return different results with the same input. However I'm a bit curious of when these functions are useful in sort(), and in particular when you _really_ need every comparison to be unmemoized. sort {rand($a) = rand($b)} @nums; Is it really desirable to get different results from rand() on every single comparison? Will the above generate a more random list than this? map { $_-[0] } sort { $a-[1] = $b-[1] } map { [$_, rand($_)] } @nums; -- Trond Michelsen
Re: RFC 355 (v1) Leave $[ alone.
On Sat, Sep 30, 2000 at 09:56:43PM +0100, Nicholas Clark wrote: Does this not imply that $[ should become lexically scoped? Or the function of $[ becomes per-array. (What would be the syntax to read and set it? pos @array? it seems to be syntactically legal but undef both as rval and lval) What about using $[array = 1? That way $[array is the first index of an array, while $#array (of course) still is the last. -- Trond Michelsen