Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: Re: Re: Re: Re: Re: Re: Re: Re: •Re: Re: Re: Re: Re: Re: What should be returned in scalar context? (best practice)

by sauoq (Abbot)
on Dec 23, 2003 at 08:29 UTC ( [id://316578]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: Re: Re: Re: Re: Re: Re: •Re: Re: Re: Re: Re: Re: What should be returned in scalar context? (best practice)
in thread What should be returned in scalar context?

This node falls below the community's threshold of quality. You may see it by logging in.
  • Comment on Re: Re: Re: Re: Re: Re: Re: Re: Re: •Re: Re: Re: Re: Re: Re: What should be returned in scalar context? (best practice)

Replies are listed 'Best First'.
Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: •Re: Re: Re: Re: Re: Re: What should be returned in scalar context? (best practice)
by Juerd (Abbot) on Dec 23, 2003 at 10:22 UTC

    (about terms and language)

    My lack of understanding of the English language is showing. I was confusing 'jargon' and 'terms'.

    Well, it seems to confuse you at any rate. But that doesn't make it wrong.

    Indeed, my confusion does not make it wrong. Its inaccuracy does.

    As others have already pointed out, some very well known people including the Camel triumvirate have used this phrasing.

    And as I have replied, BrowserUk quoted obsolete documentation and stuff that hasn't got anything to do with what we're talking about. See my answer to his list of fake sources here.

    Your arguments are not convincing.

    That much is obvious. But this is your error, not mine.

    Juerd # { site => 'juerd.nl', plp_site => 'plp.juerd.nl', do_not_use => 'spamtrap' }

    A reply falls below the community's threshold of quality. You may see it by logging in.
Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: •Re: Re: Re: Re: Re: Re: What should be returned in scalar context? (best practice)
by !1 (Hermit) on Dec 23, 2003 at 09:53 UTC

    How about a middle ground? Document that the subroutine's return acts like an array on the RHS. Yay.

      Document that the subroutine's return acts like an array on the RHS.

      You have to be specific even then. It doesn't act like an array on the RHS of the push operator, or the RHS of the chomp operator, or the RHS of a (\@) prototype sub, or the RHS of the \ operator.

      "Acts the way an array does at the RHS of the assignment operator" versus "Returns a list of foos in list context, the number of foos in scalar context". Tough choice :)

      Juerd # { site => 'juerd.nl', plp_site => 'plp.juerd.nl', do_not_use => 'spamtrap' }

        The point isn't, and has never been (in this thread), about the absolute technically and semantically correct way to document:

        sub foo { my @array = (1,5,9); return @array; }

        But some have argued that not only is it technically incorrect to say 'returns an array', but that it is confusing and misleading. It is perfectly reasonable and understandable to document what the return expression of a routine is; and the behavior of that expression (and thus the resulting return value) is perfectly inferrable: size of the array in scalar context, and the contents of the array in list context. Why should I continually re-document this basic Perl rule whenever my return expression is an array, when simply saying 'returns an array' says it all? People might enjoy quibbling about it, but they aren't the least bit confused by it.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://316578]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2024-04-18 00:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found