develooper Front page | perl.perl6.language | Postings from May 2005

Argument Type Checking

Thread Next
From:
Joshua Gatcomb
Date:
May 19, 2005 12:28
Subject:
Argument Type Checking
Message ID:
941eab8405051912284cf481@mail.gmail.com
All:
I was hoping the following would give me an outright error

sub foo (Int $bar) {
    say $bar;
}
foo('hello');

I seem to recall, probably incorrectly, that one of the differences
with int, Int, and no type declaration at all is that one would
happily autoconvert for you, 1 would autoconvert but forget it ever
happened, and 1 would be an outright failure.

Ok - so could someone set me straight?
What should that code snippet do?  Would it do anything different if
Int had been int?

Cheers,
Joshua Gatcomb
a.k.a. L~R

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About