[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: [PATCH] Made commit-email.pl work on both Windows and Unix systems.

From: Max Bowsher <maxb_at_ukf.net>
Date: 2005-01-26 16:07:39 CET

John Peacock wrote:
> Max Bowsher wrote:
>>>>> +# This package exists just to delete the temporary directory.
>>>>> +package Temp::Delete;
>>>>> +
>>>>> +sub new
>>>>> +{
>>>>> + bless {}, shift;
>>>>> +}
>>>>
>>>>
>>>> Is the "shift" doing anything useful?
>>>
>>>
>>> Ahh, you caught me trying to reuse someone else's code without total
>>> grokking. I will find out for sure if shift is needed, or just rip it
>>> all out in favor of removing the File::Temp requirement and having the
>>> user simply configure a variable that points to the preferred temporary
>>> directory location.
>>
>>
>> !!!
>>
>> It would be a bit of a waste to chuck all that code over 1 tiny word!
>>
>> I'm pretty sure that "bless {};" is sufficient.
>>
>
> No, there is a definite point to the two-parameter form of bless().
> Though
> the canonical way to write that is usually:
>
> sub new
> {
> my $proto = shift;
> my $class = ref($proto) || $proto;
>
> return bless (), $class;
> }
>
> The contents of $proto are either going to be an object of the same type,
> if
> the caller was $obj->new(), or it is going to be a string containing the
> name
> of the class this sub is being called by (not necessarily the same class
> as
> the package, since this could be an inherited method). The second line
> determines
> which is which. If you don't provide a class to bless(), it will bless
> the
> object into the current package, which isn't the right thing with
> inherited
> classes.
> However, in this specific case, there is no concern about subclassing I
> think,
> so the single parameter form of bless() is sufficient.
>
> HTH

Indeed it does, thanks for the excellent clarification.

Max.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Wed Jan 26 16:11:30 2005

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.