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

Quick questions: multi submethod and undef.method

Thread Next
From:
Ingo Blechschmidt
Date:
June 5, 2005 13:25
Subject:
Quick questions: multi submethod and undef.method
Message ID:
d7vmn1$vnl$1@sea.gmane.org
Hi,

two quick questions:


Are multi submethods allowed?


  my $x = undef;
  my $y = $x.some_method;
  # $y now contains an unthrown exception object, saying that undef
  # doesn't .can("some_method"), right?
  say $y; # Only now it dies, correct?

This is important if you have a sub which may either return a custom
object or undef:
  my $x = sub_which_returns_an_object_or_undef();
  my $y = $x.some_method;

One builtin example is "caller":
  my $x = caller(5555);  # undef if there's no such stack frame
  my $y = $x.line;       # unthrown exception object


--Ingo

-- 
Linux, the choice of a GNU | Elliptic paraboloids for sale.  
generation on a dual AMD   | 
Athlon!                    | 


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