You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@perl.apache.org by Stas Bekman <st...@stason.org> on 2004/04/13 03:52:09 UTC
[mp2] foo_set() returning previous value
I'm reviewing parts of the API and I have second thoughts about this
return-the-prev-value-on-set feature. While it's nice and perlish, it's not
always efficient. If the user doesn't care what was the previous value and
just wants to set a new value, we shouldn't enforce on her the overhead of
making another call to get the previous vallue. In certain cases it can be
quite expensive. Granted we could have exempted those cases, but then we will
have an inconsistent API. In the core perl it doesn't cost much to return the
previously set value, since it's readily available and doesn't require special
code.
So I propose that we return nothing on $socket->opt_set() call and adjust
other APIs and devise new ones using this guideline.
What do you think?
__________________________________________________________________
Stas Bekman JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org http://ticketmaster.com
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org
Re: [mp2] foo_set() returning previous value
Posted by Stas Bekman <st...@stason.org>.
Joe Schaefer wrote:
> Stas Bekman <st...@stason.org> writes:
>
>
>>I'm reviewing parts of the API and I have second thoughts about this
>>return-the-prev-value-on-set feature. While it's nice and perlish, it's not
>>always efficient. If the user doesn't care what was the previous value
>>and just wants to set a new value, we shouldn't enforce on her the
>>overhead of making another call to get the previous vallue.
>
>
> Then I suggest you test for GIMME==G_VOID and drop the return
> value in a void context. That way no existing code is affected
> and the (presumably) common case is optimized.
The idea is good, but not applicable in our API, since we return undef if the
operation has failed, there is never a void context. (unless you choose not to
check the return status).
__________________________________________________________________
Stas Bekman JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org http://ticketmaster.com
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org
Re: [mp2] foo_set() returning previous value
Posted by Joe Schaefer <jo...@sunstarsys.com>.
Stas Bekman <st...@stason.org> writes:
> I'm reviewing parts of the API and I have second thoughts about this
> return-the-prev-value-on-set feature. While it's nice and perlish, it's not
> always efficient. If the user doesn't care what was the previous value
> and just wants to set a new value, we shouldn't enforce on her the
> overhead of making another call to get the previous vallue.
Then I suggest you test for GIMME==G_VOID and drop the return
value in a void context. That way no existing code is affected
and the (presumably) common case is optimized.
--
Joe Schaefer
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org