Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion A12: Required Named Parameters Strike Back!
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
John Siracusa  
View profile  
 More options Apr 20 2004, 11:48 am
Newsgroups: perl.perl6.language
From: sirac...@mindspring.com (John Siracusa)
Date: Tue, 20 Apr 2004 10:51:53 -0400
Local: Tues, Apr 20 2004 10:51 am
Subject: Re: A12: Required Named Parameters Strike Back!
On 4/20/04 10:42 AM, Dan Sugalski wrote:

> At 9:50 AM -0400 4/20/04, John Siracusa wrote:
>> On 4/19/04 7:16 PM, Larry Wall wrote:
>>> Well, no, we're still stuck at run-time validation of that.  In the case
>>>  of methods you can't really do anything else anyway, generally speaking.

>> Why is that?

> Because at compile time all you have is a generic thing, a (possibly
> indirectly accessed) method name, and a list of parameters. There's
> no good way to tell which method will ultimately be called, and
> validating against all declared methods of that name won't get you
> anything useful there since the result's likely going to be pretty
> contradictory.

Hm, so how would the "is required" trait that Damian posted work?  Would it
simply be shorthand for a run-time check that I don't have to write myself?
I was under the impression that it would work the way I described earlier:

    sub foo(+$a is required, +$b is required) { ... }

    foo();          # compile-time error!
    foo(1, 2);      # compile-time error!
    foo(a => 1, 2); # compile-time error!
    foo(a => 1);    # compile-time error!

    foo(a => 5, b => 7); # ok
    foo(b => 1, a => 2); # ok

It really is a shame about the inability to do it at compile-time with
methods, but shorthand for a run-time check in that case would be welcome
too :)

-John


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.