Re: [PATCH] gitweb: Fix @git_base_url_list usage

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Junio C Hamano <junkio@xxxxxxx> writes:

> Why on earth do you want to use wantarray for something like
> this?
>
> It's not like you are implementinging any fancy DWIM magic.

Side note.  I really hate it when people abuse wantarray.

I can think of only two valid reasons (well, perhaps three but
the last one is a logical consequence of the first two) to use
wantarray.  They are:

 (1) The information you are giving back the caller is list of
     things in nature, but there is a natural representation for
     that list as a single scalar, and that representation is
     not the last element of the list.  You would want to help
     the caller by DWIMmery.

     Perl's built-in localtime() is an excellent example for
     wanting to do something like this.  It returns broken-down
     "struct tm" in list context, but returns string ctime(3) in
     scalar context.

 (2) You want to avoid complex computations when the caller does
     not need full return values from you.  A good example is
     found in perlfunc.pod:

        return unless defined wantarray;	# don't bother doing more
        my @a = complex_calculation();
        return wantarray ? @a : "@a";

 (3) You are emulating Perl's built-in function that DWIMs for
     one of the above reasons, usually (1).


-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]