undef.chars?

2 views
Skip to first unread message

Ingo Blechschmidt

unread,
Aug 4, 2005, 6:25:28 PM8/4/05
to perl6-l...@perl.org
Hi,

(found in the Pugs testsuite.)

my $undef = undef;
say $undef.chars? # 0? undef? die?
say chars $undef; # 0? undef? die?

I'd opt for "undef.chars" to be an error ("no such method") and "chars
undef" to return 0 (with a warning printed to STDERR^W$*ERR).

Opinions?


--Ingo

--
Linux, the choice of a GNU | When cryptography is outlawed, bayl bhgynjf
generation on a dual AMD | jvyy unir cevinpl!
Athlon! |

Luke Palmer

unread,
Aug 4, 2005, 6:54:23 PM8/4/05
to Ingo Blechschmidt, perl6-l...@perl.org
On 8/4/05, Ingo Blechschmidt <ibl...@web.de> wrote:
> Hi,
>
> (found in the Pugs testsuite.)
>
> my $undef = undef;
> say $undef.chars? # 0? undef? die?
> say chars $undef; # 0? undef? die?
>
> I'd opt for "undef.chars" to be an error ("no such method") and "chars
> undef" to return 0 (with a warning printed to STDERR^W$*ERR).

Well, I think that "chars $undef" should be exactly equivalent to
"$undef.chars". In fact, I think it is: "chars $undef" is just the
indirect object form.

So perhaps "method not found" errors "fail" instead of "die".

Luke

Brent 'Dax' Royal-Gordon

unread,
Aug 5, 2005, 1:48:49 AM8/5/05
to Luke Palmer, Ingo Blechschmidt, perl6-l...@perl.org
Luke Palmer <lrpa...@gmail.com> wrote:
> On 8/4/05, Ingo Blechschmidt <ibl...@web.de> wrote:
> > my $undef = undef;
> > say $undef.chars? # 0? undef? die?
> > say chars $undef; # 0? undef? die?
> >
> > I'd opt for "undef.chars" to be an error ("no such method") and "chars
> > undef" to return 0 (with a warning printed to STDERR^W$*ERR).
>
> Well, I think that "chars $undef" should be exactly equivalent to
> "$undef.chars". In fact, I think it is: "chars $undef" is just the
> indirect object form.

Didn't $Larry rule that method calls on undef return undef, for the
same reason array and hash subscripting does?

--
Brent 'Dax' Royal-Gordon <br...@brentdax.com>
Perl and Parrot hacker

Larry Wall

unread,
Aug 5, 2005, 12:08:50 PM8/5/05
to perl6-l...@perl.org
On Thu, Aug 04, 2005 at 10:48:49PM -0700, Brent 'Dax' Royal-Gordon wrote:
: Luke Palmer <lrpa...@gmail.com> wrote:
: > On 8/4/05, Ingo Blechschmidt <ibl...@web.de> wrote:
: > > my $undef = undef;
: > > say $undef.chars? # 0? undef? die?
: > > say chars $undef; # 0? undef? die?
: > >
: > > I'd opt for "undef.chars" to be an error ("no such method") and "chars
: > > undef" to return 0 (with a warning printed to STDERR^W$*ERR).
: >
: > Well, I think that "chars $undef" should be exactly equivalent to
: > "$undef.chars". In fact, I think it is: "chars $undef" is just the
: > indirect object form.
:
: Didn't $Larry rule that method calls on undef return undef, for the
: same reason array and hash subscripting does?

Um, by default, that's exactly what fail does. I don't think it's
a problem for it to die under "use fatal", since that's saying you
prefer an exception model in general.

Larry

Reply all
Reply to author
Forward
0 new messages