public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: merlyn@stonehenge•com (Randal L. Schwartz)
To: Junio C Hamano <junkio@cox•net>
Cc: Jakub Narebski <jnareb@gmail•com>, git@vger•kernel.org
Subject: Re: [PATCH] gitweb:  Make git_get_refs_list do work of  git_get_references
Date: 16 Sep 2006 18:40:22 -0700	[thread overview]
Message-ID: <864pv7tgmx.fsf@blue.stonehenge.com> (raw)
In-Reply-To: <7vodtf8eym.fsf@assigned-by-dhcp.cox.net>

>>>>> "Junio" == Junio C Hamano <junkio@cox•net> writes:

Junio> Jakub Narebski <jnareb@gmail•com> writes:
>> Make git_get_refs_list do also work of git_get_references, to avoid
>> calling git-peek-remote twice. It now returns either list of refs as
>> before in scalar context, or references hash and list of refs in list
>> context.

Junio> I do not think we want to have too many functions that return
Junio> different things depending on contexts.  Forcing callers to
Junio> remember what the function does in which context is bad.

That's even an inaccurate description, so an expert in Perl (I've
known a few) would just scratch his head.

You cannot ever ever return a list in a scalar context.  Ever.  Never ever.

You can return an array ref that *contains* a list of references, sure.
Perhaps that's what you mean, as in:

  return [$ref1, $ref2, $ref3, $ref4]; # scalar return

But to be sloppy about the terminology confuses me.  For example,
I can't tell from your description if you mean the list-value return is:

  return \%some_hash, $ref1, $ref2, $ref3, $ref4; # list return: N items

Or, reverse engineering your sloppiness on the other description, you
*MIGHT* mean:

  return \%some_hash, [$ref1, $ref2, $ref3, $ref4]; # list return: 2 items

Perl5 does *no* implicit referencing/dereferencing (just like C).  So yes,
being precise with your language is necessary.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge•com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

  reply	other threads:[~2006-09-17  1:40 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-09-17  0:26 [PATCH] gitweb: Make git_get_refs_list do work of git_get_references Jakub Narebski
2006-09-17  0:37 ` [PATCH 1/2] gitweb: Always use git-peek-remote in git_get_references Jakub Narebski
2006-09-17  1:22 ` [PATCH] gitweb: Make git_get_refs_list do work of git_get_references Junio C Hamano
2006-09-17  1:40   ` Randal L. Schwartz [this message]
2006-09-17  2:12     ` Junio C Hamano
2006-09-17  2:17       ` Randal L. Schwartz
2006-09-17  2:29       ` Junio C Hamano
     [not found] ` <200609171057.56467.jnareb@gmail.com>
     [not found]   ` <7vfyeq6dn3.fsf@assigned-by-dhcp.cox.net>
2006-09-17 10:00     ` [PATCH 2/2 (take 2)] " Jakub Narebski
2006-09-17 10:02       ` Jakub Narebski
2006-09-17 10:06         ` Jakub Narebski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=864pv7tgmx.fsf@blue.stonehenge.com \
    --to=merlyn@stonehenge$(echo .)com \
    --cc=git@vger$(echo .)kernel.org \
    --cc=jnareb@gmail$(echo .)com \
    --cc=junkio@cox$(echo .)net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox