[30524] in Perl-Users-Digest
Perl-Users Digest, Issue: 1767 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Aug 4 18:10:08 2008
Date: Mon, 4 Aug 2008 15:09:08 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Mon, 4 Aug 2008 Volume: 11 Number: 1767
Today's topics:
bidding advice for a contract <cartercc@gmail.com>
Re: bidding advice for a contract <joost@zeekat.nl>
Re: bidding advice for a contract <cartercc@gmail.com>
Re: bidding advice for a contract sln@netherlands.com
Re: CLPM - a help group? sln@netherlands.com
Re: Extracting bits out of huge numbers sln@netherlands.com
Re: Extracting bits out of huge numbers sln@netherlands.com
Re: FAQ 4.2 Why is int() broken? <hjp-usenet2@hjp.at>
Re: FAQ 4.2 Why is int() broken? <szrRE@szromanMO.comVE>
Re: FAQ 4.2 Why is int() broken? <hjp-usenet2@hjp.at>
Re: FAQ 4.61 How can I always keep my hash sorted? <tzz@lifelogs.com>
Re: having some trouble with character substitution/reg <ben@morrow.me.uk>
Re: highly restrictive sub-classing <ben@morrow.me.uk>
Re: Is there a way to spawn a program from perl that is <ced@blv-sam-01.ca.boeing.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 4 Aug 2008 11:48:43 -0700 (PDT)
From: cartercc <cartercc@gmail.com>
Subject: bidding advice for a contract
Message-Id: <be0f3724-5970-4288-81a0-94d62fc8a717@m44g2000hsc.googlegroups.com>
I have been solicited to make a bid for a database project. The
company is small but has been around for 20 years or so, and the owner
has made a name in EE. The people (potential clients) are not idiots,
and the company is a highly regarded company with a long history that
manufactures electronic components for aircraft, missles, etc., and
deals with NASA, the USAF, DARPA, as well as defense contractors. I
want to do the work, not only because I could use the money, but
because of the reputation of the company.
They have specified a database to track (1) purchasing, (2)
manufacturing, (3) inventory control, (4) user specified enhancements,
and (5) full documentation, and have specified a contract end date of
September 24, 2008 by whch all work would be finished and the project
would be delivered. They will not have their requirements
specification until August 13, and based on my previous conversations,
their requirements documents will probably be less than a page in
length with very general, ambiguous specifications.
They haven't decided whether to used Access on Windows or a networked
enabled application with MySQL on Linux, but they want it to integrate
with their existing software. Unfortunately, their existing software
doesn't seem to be open source and they don't know whether thay can
furnish any sort of API to tie into their existing applications. I
probably won't know what to integrate with until I actually am awarded
the contract, so I am ignorant at this point.
They want a fixed price bid. (Did I mention that?)
I intend to furnish a fixed price bid based on their specification,
detailing the tables and queries, the user interfaces, and the modules
I expect to build according to their specifications. I know that this
probably will not last the first week, but I don't want to be locked
in to a low price because of the failure of the client to detail all
the requirements up front.
$100/table
$50/query
$200/interface
$500/module
Is there a better way to handle this? I really would like the work,
but I don't want to lock myself in to an impossible position. Does
anyone have a form contract that I could look at that provides
appropriate protections?
Thanks, CC.
------------------------------
Date: Mon, 04 Aug 2008 21:37:59 +0200
From: Joost Diepenmaat <joost@zeekat.nl>
Subject: Re: bidding advice for a contract
Message-Id: <87prood10o.fsf@zeekat.nl>
cartercc <cartercc@gmail.com> writes:
[ ... ] lots of specifics snipped
> They haven't decided whether to used Access on Windows or a networked
> enabled application with MySQL on Linux, but they want it to integrate
> with their existing software. Unfortunately, their existing software
> doesn't seem to be open source and they don't know whether thay can
> furnish any sort of API to tie into their existing applications. I
> probably won't know what to integrate with until I actually am awarded
> the contract, so I am ignorant at this point.
>
> They want a fixed price bid. (Did I mention that?)
Don't decide on a fixed price now.
> I intend to furnish a fixed price bid based on their specification,
> detailing the tables and queries, the user interfaces, and the modules
> I expect to build according to their specifications. I know that this
> probably will not last the first week, but I don't want to be locked
> in to a low price because of the failure of the client to detail all
> the requirements up front.
>
> $100/table
> $50/query
> $200/interface
> $500/module
>
> Is there a better way to handle this? I really would like the work,
> but I don't want to lock myself in to an impossible position. Does
> anyone have a form contract that I could look at that provides
> appropriate protections?
There are fairly standard non-disclosure contracts for this kind of
thing, I guess.
Anyway, this kind of project will probably take quite a bit of time to
investigate before you can give a decent estimate. Get a
non-disclosure contract, sign it, give them a couple of hours of
investigation time. If it takes more than a day to figure out
(especially if the total project won't take more than a week or so)
make them pay for the rest of the time spent investigation.
All of this is assuming they're actually trustworthy. Your description
sound fishy.
--
Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/
------------------------------
Date: Mon, 4 Aug 2008 14:36:32 -0700 (PDT)
From: cartercc <cartercc@gmail.com>
Subject: Re: bidding advice for a contract
Message-Id: <504bf20f-0af6-45a5-87c1-9752540b0e8a@e53g2000hsa.googlegroups.com>
On Aug 4, 3:37 pm, Joost Diepenmaat <jo...@zeekat.nl> wrote:
> > They want a fixed price bid. (Did I mention that?)
>
> Don't decide on a fixed price now.
You and I both know that this is bidding on a pig in a poke, but they
are used to giving fixed price bids and this is what they want. I have
spent about two hours with them, and they are totally closed to the
idea of paying by the hour or component.
> Anyway, this kind of project will probably take quite a bit of time to
> investigate before you can give a decent estimate. Get a
> non-disclosure contract, sign it, give them a couple of hours of
> investigation time. If it takes more than a day to figure out
> (especially if the total project won't take more than a week or so)
> make them pay for the rest of the time spent investigation.
>
> All of this is assuming they're actually trustworthy. Your description
> sound fishy.
This is a big player in a small but critical industry. There aren't
many who build electronics to put into aircraft, missles, spacecraft,
and bombs, which is why I don't want to mention names.
We both know what's going to happen, but I am strongly motivated to
give them what they need and I want to be able to do it reasonably and
legitimately.
Thanks for your input.
CC
------------------------------
Date: Mon, 04 Aug 2008 21:40:56 GMT
From: sln@netherlands.com
Subject: Re: bidding advice for a contract
Message-Id: <fpte941f5rqakt0fldtrqnuenuhm59nthn@4ax.com>
On Mon, 4 Aug 2008 14:36:32 -0700 (PDT), cartercc <cartercc@gmail.com> wrote:
>On Aug 4, 3:37 pm, Joost Diepenmaat <jo...@zeekat.nl> wrote:
>> > They want a fixed price bid. (Did I mention that?)
>>
>> Don't decide on a fixed price now.
>
>You and I both know that this is bidding on a pig in a poke, but they
>are used to giving fixed price bids and this is what they want. I have
>spent about two hours with them, and they are totally closed to the
>idea of paying by the hour or component.
>
>> Anyway, this kind of project will probably take quite a bit of time to
>> investigate before you can give a decent estimate. Get a
>> non-disclosure contract, sign it, give them a couple of hours of
>> investigation time. If it takes more than a day to figure out
>> (especially if the total project won't take more than a week or so)
>> make them pay for the rest of the time spent investigation.
>>
>> All of this is assuming they're actually trustworthy. Your description
>> sound fishy.
>
>This is a big player in a small but critical industry. There aren't
>many who build electronics to put into aircraft, missles, spacecraft,
>and bombs, which is why I don't want to mention names.
>
>We both know what's going to happen, but I am strongly motivated to
>give them what they need and I want to be able to do it reasonably and
>legitimately.
>
>Thanks for your input.
>
>CC
Raytheon
I can do it for twice the price, twice the guarantee..
sln
------------------------------
Date: Mon, 04 Aug 2008 20:32:51 GMT
From: sln@netherlands.com
Subject: Re: CLPM - a help group?
Message-Id: <dgpe945ee06tgb9g00i7ngnolfba2qlfen@4ax.com>
On Sat, 02 Aug 2008 18:09:47 -0500, brian d foy <brian.d.foy@gmail.com> wrote:
>In article <icg994pb2vv6t2dc5j5a725lhiv8a0tg6t@4ax.com>,
><sln@netherlands.com> wrote:
>
>> Whats the charter of this newsgroup?
>> Is it strictly Q&A?
>
>I've never seen an official charter for this group, but it certainly
>isn't a help desk. It's for general discussion of Perl. That might be
>questions, answers, essays, or whatever else people decide to post.
>
>People post the thoughtful stuff in blogs now, so you don't see much of
>that in usenet anymore.
>
>> Am I posting to the wrong group? Just what is this group for?
>
>It depends on what you are trying to acheive. If you're looking to
>learn perl, you probably want to move over to learn.perl.org and look
>at its discussion lists.
>
>If you want detailed discussions of the gory details of Perl, you might
>try PerlMonks.
>
>If you are interested in topical discussion of narrow topics, look at
>the Perl mailing lists to see if one meets your needs:
>http://lists.cpan.org/
>
>If you're looking for something else, tell us what it is and somebody
>might be able to point you in the right direction.
>
>clpm is what it is, despite what anyone tries to make it. If that works
>for you, great. If it doesn't, there's not much chance of making it
>into something else.
>
>Good luck :)
Thank You!
This seems like the perfect place for me.
I will use this group as a repository to dump large scale code into.
How far back are the posts saved?
sln
------------------------------
Date: Mon, 04 Aug 2008 19:38:54 GMT
From: sln@netherlands.com
Subject: Re: Extracting bits out of huge numbers
Message-Id: <5lme945c78s6svro70npg5itcu883t77vu@4ax.com>
On Tue, 29 Jul 2008 05:28:56 -0700 (PDT), hofer <blabla@dungeon.de> wrote:
>Hi,
>
>I'd like to work with huge integers (> 64 bit precision)
>
>Thus I can't use ordinary perl integers.
>
>I thought Math::BigInt wouldn't be a too bad choice.
>
>
>It's easy enough go create BigInts.
>my $a = Math::BigInt->new("0x7777666655544443333222211110000");
>my $b = Math::BigInt->new("0x1111111111111111111111111111111");
>
>Calculating with them is also fine:
>$a->badd($b); # $a = $a + $b
>
>
>Now I would like to extract certain bits out of this huge number:
>
>Example Bits 16 bis 12 should result in 0b00001 == 0x1 == 1
> Bits 17 bis 12 should result in 0b100001 == 0x21 == 33
>
>
>
>So far I see two ways of doing this conversion.
>
>However I'm not really appealed by either solution.
>
>Do you know anything faster / better or even another CPAN module?
>
># extract bits out of binary string
>sub extbits { #
> my ($val,$msb,$lsb) = @_; # $val must be Math::BigInt;
> my $asbinstr = $val->as_bin(); # nun als binaer string
> my $withoutprefix = substr($asbinstr,2); # fuehrendes '0b'
>entfernen
> my $substr = substr($withoutprefix,-$msb-1,$msb-$lsb+1); # den
>substring extrahieren
> $substr = 0 if $substr eq ""; # sollte mindestens einen character
>enthalten
> my $result = Mat::BigInt->new("0b".$substr); # zurueck in
>Math::BigInt verwandeln
> return $result;
>} #
>
># extract bits via shifts operations follwed by a bit wise and
>sub extbits { #/*{{{*/
> my ($val,$msb,$lsb) = @_; # $val must be Math::BigInt;
> my $mask = Math::BigInt->new(1); # create a 1
> $mask->blsft($msb-$lsb+1); # 2 ^ (number of bits to extract)
> $mask->bsub(1); # now we have a mask
> my $tmp = $val->copy->brsft($lsb); # shift input value to the
>right
> return $tmp->band($mask);
>} #/*}}}*/
>
>
>
>Thanks in advance for any other suggestions
>like rewriting the function to accelerate it or using another module.
>
>
>bye
>
>
>H
0x7777666655544443333222211110000
Hex Bits Bytes
------------------------------------
7777666 64 8 (really: 63 7)
65554444 64 8
33332222 64 8
11110000 64 8
------------------------------------
Total 256 32
0x1111111111111111111111111111111
Hex Bits Bytes
------------------------------------
1111111 64 8 (really: 63 7)
11111111 64 8
11111111 64 8
11111111 64 8
------------------------------------
Total 256 32
I count 256 bits here. This is strange.
In reality, there is no use in having integers that
specific unless you need unique identifiers.
In the case of that many individuals, and I can only
think on a macro level here, it would be the amount
of stars in the universe. In that case, I believe it
still falls short, not sure.
On the atomic level, and you mention "precision", probably
this is a misnomer as a macro, there is no measurement below
sub-micron (1/10), a simple 6 decimal places.
I don't know but there are other possiblilites here though.
Like, in a weird way, you are somehow running a piramyd simulation,
statistics, where every digit counts, jacking up all intermediate
calculations to whole numbers until the final result.
Regardless, you need to do work on and have a big matissa, so to speak.
The Calculator program under windows is very interresting, you may
want to take a look at it.
There is a function (enable advanced scientific) x^y.
If you put in 2^100 you get 1267650600228229401496703205376.
That would be 100 bits on my 32 bit integer machine.
Apparently "BigInt" means it, but is it so hard to do?
Why don't you do your own?
Binary math is simple, you don't need 100 bit registers to do it.
That module simply uses the available machine register width, the
wider the better, to simulate extended integer arithmatic.
On the hardware side, if my data register were 16 bit, I would use 8x8 bit
chunks for calculations, 32 bit, 16x16, 64 bit, 32x32, etc..
Doesen't matter how big the width is of the input. I'm sure this is
nothing new, this is a simulation, intermediate results, the way it
was before 80 bit data registers in floating point chips doing similar
things by example.
For example, if my machine were 32 bit integer data width registers,
I would create an array of 16 bit integers large enough to represent
the largest number of bits needed in the calculation.
Doesen't matter how big the array is.
The logical binary math progresses upward, from one 16 bit frame to the next,
until the resultant array is populated.
So it is possible to do binary calculations for as much as you have memory
to create an array of integers. I haven't calculate 2^4,000,000 but I assume
its very large array.
Concerning retreiveing bits of that very large number, how hard would it
be to shift the frame, knowing its size, to the index of the array, of the
bits in question? Not hard at all, its simple, and that bit number will fit
into a 32 bit register. Its quick. If bits are on adjacent frames, algorithmacally
its easy.
Remember, this does not use strings at all. Integer arithmatic is the easiest
thing in the world. But your not doing trig are you...
This would be trivial... So I suggest you roll your own. I won't do it, although
I could.
--
256 bit example (from above) ADDITION, 16 bit Frame pseudocode:
@a = (0x0000,0x0777,0x7666,0x6555,0x4444,0x3333,0x2222,0x1111,0x0000);
@b = (0x0000,0x1111,0x1111,0x1111,0x1111,0x1111,0x1111,0x1111,0x1111);
@c = ();
In this case you would work the array frame (index) from the largest to smallest.
In reality, the array's should be reversed, but thats details when thier populated.
Do the frame calculation, carry over remainder to next frame, continue, populate
array @c.
Given the frame size, its trivial to find a sequential series of bits, even if overlapping
frames.
Let me know if this sounds about right.
sln
------------------------------
Date: Mon, 04 Aug 2008 20:13:50 GMT
From: sln@netherlands.com
Subject: Re: Extracting bits out of huge numbers
Message-Id: <7loe949npitl2vpvbbistoidmqn7poksv9@4ax.com>
On Mon, 04 Aug 2008 19:38:54 GMT, sln@netherlands.com wrote:
>On Tue, 29 Jul 2008 05:28:56 -0700 (PDT), hofer <blabla@dungeon.de> wrote:
>
>>Hi,
>>
>On the atomic level, and you mention "precision", probably
>this is a misnomer as a macro, there is no measurement below
>sub-micron (1/10), a simple 6 decimal places.
>
To clarify... that can be manufactured.
sln
------------------------------
Date: Mon, 4 Aug 2008 21:25:41 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: FAQ 4.2 Why is int() broken?
Message-Id: <slrng9eltl.3p4.hjp-usenet2@hrunkner.hjp.at>
On 2008-08-04 16:42, szr <szrRE@szromanMO.comVE> wrote:
> Peter J. Holzer wrote:
>> On 2008-08-01 21:00, szr <szrRE@szromanMO.comVE> wrote:
>>>
>
>> If the calculator displays 12 digits, it can display 0.999999999999
>> exactly, but it needs to round 0.9999999999999: Since the first
>> digit to be omitted is "9" it needs to be rounded up, so the
>> rounded value is 1.0. But the value which is stored is still the
>> correct value 0.9999999999999.
>
> Yeah, I think that's pretty much what it does.
[...]
>>> Either that or it uses a threshold algorithm like I described (either
>>> way the 89 seems to handle this far better than the 86.)
>>
>> I don't think there's a threshold algorithm. Your example didn't show
>> one and it wouldn't work anyway.
>
> By "threshold", I meant the threshold where a calculator considers a
> repetitive number to be infinitely-repetitive and act accordingly:
It doesn't do this.
>
> On a TI-86:
>
> _____________________
> .333333333333*3
> .999999999999
> .3333333333333*3
> 1
> _____________________
Ok. Now I really give up. Just a few lines above you seemed to accept my
explanation that this is simple rounding. Now you give the the same
example again ...
EOD.
hp
------------------------------
Date: Mon, 4 Aug 2008 13:01:56 -0700
From: "szr" <szrRE@szromanMO.comVE>
Subject: Re: FAQ 4.2 Why is int() broken?
Message-Id: <g77n7k0gm4@news4.newsguy.com>
Peter J. Holzer wrote:
> On 2008-08-04 16:42, szr <szrRE@szromanMO.comVE> wrote:
>> Peter J. Holzer wrote:
>>> On 2008-08-01 21:00, szr <szrRE@szromanMO.comVE> wrote:
>>>>
>>
>>> If the calculator displays 12 digits, it can display 0.999999999999
>>> exactly, but it needs to round 0.9999999999999: Since the first
>>> digit to be omitted is "9" it needs to be rounded up, so the
>>> rounded value is 1.0. But the value which is stored is still the
>>> correct value 0.9999999999999.
>>
>> Yeah, I think that's pretty much what it does.
> [...]
>>>> Either that or it uses a threshold algorithm like I described
>>>> (either way the 89 seems to handle this far better than the 86.)
>>>
>>> I don't think there's a threshold algorithm. Your example didn't
>>> show one and it wouldn't work anyway.
>>
>> By "threshold", I meant the threshold where a calculator considers a
>> repetitive number to be infinitely-repetitive and act accordingly:
>
> It doesn't do this.
>
>>
>> On a TI-86:
>>
>> _____________________
>> .333333333333*3
>> .999999999999
>> .3333333333333*3
>> 1
>> _____________________
>
> Ok. Now I really give up. Just a few lines above you seemed to accept
> my explanation that this is simple rounding. Now you give the the same
> example again ...
I think you misunderstood what I was saying and you over snipped and
lost some of the context. I understand what you said about rounding when
it comes to binary FP math, but it doesn't seem to be the case with the
TI-86 and you asked what I meant by "threshold and I simple answered.
Why are you so quick to assume this is not the case and that you are
automatically correct?
--
szr
------------------------------
Date: Mon, 4 Aug 2008 22:36:32 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: FAQ 4.2 Why is int() broken?
Message-Id: <slrng9eq2g.456.hjp-usenet2@hrunkner.hjp.at>
On 2008-08-04 20:01, szr <szrRE@szromanMO.comVE> wrote:
> Peter J. Holzer wrote:
>> Ok. Now I really give up. Just a few lines above you seemed to accept
>> my explanation that this is simple rounding. Now you give the the same
>> example again ...
>
> I think you misunderstood what I was saying and you over snipped and
> lost some of the context. I understand what you said about rounding when
> it comes to binary FP math, but it doesn't seem to be the case with the
> TI-86
Why do you think that this doesn't seem to be the case?
> and you asked what I meant by "threshold and I simple answered.
> Why are you so quick to assume this is not the case and that you are
> automatically correct?
Because
a) it is the most simple explanation.
b) the evidence you produced matches perfectly
c) you haven't provides even a glint of an idea how it could be
different, much less any evidence that it really is different.
hp
------------------------------
Date: Mon, 04 Aug 2008 14:34:39 -0500
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: FAQ 4.61 How can I always keep my hash sorted?
Message-Id: <86hca0zi9c.fsf@lifelogs.com>
On Sun, 03 Aug 2008 23:03:46 GMT Jürgen Exner <jurgenex@hotmail.com> wrote:
JE> Of course you can sort all keys or all values or whatever after you put
JE> those into a list/array. But you cannot sort a hash because a hash
JE> opposite to an array or list does not have a sequence on its members.
JE> If you want a sorted hash, then you don't want a hash but some other
JE> data structure.
It's funny, however, that Perl pretends a hash is a list in many places,
e.g.
%hash = ( 1 => 2 );
I'm sure this is a little confusing to beginners.
If there was a useful order for a hash, it would be the insertion order,
since that's not available in any other way (unless, of course, you keep
track of it manually inside each value).
Ted
------------------------------
Date: Mon, 4 Aug 2008 19:24:18 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: having some trouble with character substitution/regX
Message-Id: <i3ujm5-qjo.ln1@osiris.mauzo.dyndns.org>
Quoth pauls <pauls@nospam.off>:
> I have a file that includes some directory paths and I want to use PERL
> to change the file paths
>
> I want to substitute this line of text:
>
> .include '/doob/fred/bicmos/rev8/models/2010.11.07/hop/'
>
> with this line of text:
>
> .include 'D:/spi_models/TI/Hspice/'
>
> and thought I would use the following code to do the job:
>
>
> if (/include/)
> {
> s'/doob/fred/bicmos/rev8/models/2010.11.07/hop/'D:/spi_models/Tee/Hspice/';
> }
Note that '.' is special in regular expressions. If you want to match a
literal string, the safest way is to use \Q:
s'\Q/doob/.../hop/'...';
You haven't posted a complete program. If I create a file doob
containing
.include '/doob/fred/bicmos/rev8/models/2010.11.07/hop/'
and then run
% perl -pe'if (/include/) {
s!/doob/fred/bicmos/rev8/models/2010.11.07/hop/!D:/spi_models/Tee/Hspice/!;
}' doob
I get the output
.include 'D:/spi_models/Tee/Hspice/'
as expected, so there must be something wrong with your program
somewhere else.
Ben
--
For the last month, a large number of PSNs in the Arpa[Inter-]net have been
reporting symptoms of congestion ... These reports have been accompanied by an
increasing number of user complaints ... As of June,... the Arpanet contained
47 nodes and 63 links. [ftp://rtfm.mit.edu/pub/arpaprob.txt] * ben@morrow.me.uk
------------------------------
Date: Mon, 4 Aug 2008 19:10:02 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: highly restrictive sub-classing
Message-Id: <q8tjm5-5bo.ln1@osiris.mauzo.dyndns.org>
Quoth xhoster@gmail.com:
> I have a lot of scripts that use a memory-hungry module, but most of them
> use only a small subset of that module's features, and it should be
> possible to implement that subset in a more memory efficient way.
>
> I want to "subclass" the memory hungry module. Many of the methods, ones
> which are rarely used and can't be made memory efficient, will not be
> implemented in the subclass.
A better idea, I would say, would be to make the split the other way:
put the common, cheap methods in the superclass, and have the subclass
inherit them and add more, expensive, methods. Of course, if the
expensive class is not your code this is probably not possible.
> I could define subs in the subclass for each such method, invoking croak or
> die so the call doesn't get dispatched up the @ISA list. But I want the
> default to lie the other way around, methods are unimplemented unless other
> specified.
>
> I guess I could walk the superclass's symbol table, automatically defining
> a croaking sub for every subroutine in that symbol table unless they are in
> my "implemented" list. But that seems rather hackish. Is there a better
> way to do that?
That would be a bad idea. For one thing, you haven't considered methods
the superclass inherits from elsewhere; for another, you haven't
considered AUTOLOAD. Now, these may not be issues in your case, but if
they become so you will get rather strange bugs.
> Other options would be to *not* put the superclass in @ISA, and manually
> redispatch calls to the superclass when that is the proper thing to do,
> with unimplemented ones getting exceptions from Perl rather than explicit
> ones. Is there some pitfall in doing this?
Not really: it's called 'delegation', and is a perfectly respectable way
of reusing code. You would need to keep around (or otherwise be able to
produce on demand) an object of the expensive class, to invoke the
methods on: once you've done that, you can use Class::HasA to perform
the delegation automatically. It would probably be best to override
->isa to say that you *are*, in fact, a 'superclass'.
You could also have something like
sub AUTOLOAD {
$_[0]->isa(__PACKAGE__)
or croak "Undefined subroutine $AUTOLOAD called";
(my $meth = $AUTOLOAD) =~ s/.*:://;
if ($_[0]->_delegate->can($meth)) {
croak "->$meth is not implemented in this light-weight version";
}
else {
croak "Can't locate object method '$meth' via package " .
__PACKAGE__;
}
}
to distinguish methods you have chosen not to implement from methods
that would never have existed.
> Or I could just do a complete code-fork and have the two modules completely
> unrelated other than happening to have many method names in common.
This situation (two classes that don't inherit from each other, but have
many methods with the same names and semantics) is what defines a
'role': depending on how much time you want to put into this, you could
look at some of the role-related modules on CPAN. The most complete, of
course, is Moose, which provides a full Perl 6-ish object model for
Perl 5; but it is both rather heavy and rather complicated to learn.
Ben
--
I've seen things you people wouldn't believe: attack ships on fire off
the shoulder of Orion; I watched C-beams glitter in the dark near the
Tannhauser Gate. All these moments will be lost, in time, like tears in rain.
Time to die. ben@morrow.me.uk
------------------------------
Date: Mon, 4 Aug 2008 12:14:10 -0700 (PDT)
From: "comp.lang.c++" <ced@blv-sam-01.ca.boeing.com>
Subject: Re: Is there a way to spawn a program from perl that is independent?
Message-Id: <273fc291-8342-408c-9304-59ae290c6c37@p31g2000prf.googlegroups.com>
On Aug 4, 5:44 am, "Peter J. Holzer" <hjp-usen...@hjp.at> wrote:
> On 2008-08-04 04:16, comp.lang.c++ <c...@blv-sam-01.ca.boeing.com> wrote:
>
> > In Unix, you could background the other script in
> > a subshell:
>
> > 0 == system "(/path/to/other_script &)"
> > or die "system failed: $?";
>
> > But getting the return status of the backgrounded
> > task would be messy
>
> If you use open with mode '-|' or '|-' it isn't messy at all: close
> returns the return status. It also avoids the additional shell. You need
> to take care about the input or output, which may add some
> complications.
>
True. I was just guessing from the OP's description "throw off
another
script and go on with its business", he just wanted a "spawn and
forget"
type background action. (with no interaction and possibly no concern
about status as well),
--
Charles DeRykus
Charles DeRykus
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V11 Issue 1767
***************************************