[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]

Re: [perl #62412] sqrt without EXPR and Math::Complex always 0



Rafael Garcia-Suarez wrote:
> 2009/1/16 Nicholas Clark <nick@ccl4.org>:
>> On Fri, Jan 16, 2009 at 07:58:00AM -0500, Jarkko Hietaniemi wrote:
>>> Abigail wrote:
>>>> On Fri, Jan 16, 2009 at 11:33:08AM +0100, Steffen Mueller wrote:
>>>>> Hi,
>>>>>
>>>>> Abigail abigail-at-abigail.be |newsgroups6| wrote:
>>>>>> That will not pick up any lexical $_. It would if you'd used a '_' prototype:
>>>>>>
>>>>>>    sub sqrt (_) {
>>>>>>        my ($z) = @_;
>>>>>>        ...
>>>>> doh, of course. Thanks for catching that. If I recall correctly, the _
>>>>> prototype can't be backported to 5.8 and earlier, right?
>>>>
>>>> Indeed. Both the '_' prototype and lexical $_ are new in 5.10.
>>> Which means without BEGIN + eval games that can't be in M::C.
>> I don't think that an eval is needed - simply assign one of the alternatives
>> to *Math::Complex::sqrt
>>
>> Or alternatively, a Corelist_pm.PL that has the two alternatives, and
>> Makefile.PL extracts.
>>
>> (Hmm. Without XS, I can't see any way to change the prototype of a function
>> at run time.)
> 
> Scalar::Util::set_prototype() ?

Okay, call me dim, but how do I write an interface that (either accepts
an explicit argument, or uses the $_ and) works with the new lexical $_,
and that works both nicely in pre-5.10 and 5.10?  In pre-5.10 I cannot
say sub ... (_) without hiding it in an eval.



Follow-Ups from:
Abigail <abigail@abigail.be>
References to:
Steffen Mueller <wyp3rlx02@sneakemail.com>
Abigail <abigail@abigail.be>
Steffen Mueller <wyp3rlx02@sneakemail.com>
Abigail <abigail@abigail.be>
Jarkko Hietaniemi <jhi@iki.fi>
Nicholas Clark <nick@ccl4.org>
"Rafael Garcia-Suarez" <rgarciasuarez@gmail.com>

[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]