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: Typed undef
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
 
Austin Hastings  
View profile  
 More options Apr 23 2004, 1:33 pm
Newsgroups: perl.perl6.language
From: Austin_Hasti...@Yahoo.com (Austin Hastings)
Date: Fri, 23 Apr 2004 13:33:48 -0400
Local: Fri, Apr 23 2004 1:33 pm
Subject: A12: Typed undef
Mention is made of a typed undef in A12:

<A12>
which doesn't quite work, because $spot is undefined. What probably happens
is that the my cheats and puts a version of undef in there that knows it
should dispatch to the Dog class if you call .self:new() on it. Anyway,
we'll make it work one way or another, so that it becomes the equivalent of:
</A12>

I want to point out this is a pretty good idea overall, not as just some
"magic" behavior. Specifically, if I say:

  my Dog $spot;

I should then be able to call class methods of Dog via $spot without further
initialization:

  print defined($spot);   # FALSE
  $rover = $spot.new;

  @breeds = $spot.list_breeds;

This is, as pointed out, just sugar for Dog::new and Dog::list_breeds, but
it brings up the spectre of undef invocants:

  class C {
    method ctor {...}
    method foo returns C {...; return undef; ...}
    method bar returns C {...; return undef; ...}
    method baz {...}
  }

  my C $c .= ctor; # $c is defined and all is well.

  $c->foo->bar->baz; # If foo or bar fails, what happens?

There are potentially two flavors of undef:

  undef

  undef but class = C

Given that the foo and bar methods are declared to return C, should the
'return undef' code emit a 'pure' undef, or a undef-of-type-C?

And if so, should it be legal to have an undef invocant? A typed-undef
invocant?

This sort of wanders towards the question: Is undef a value, or a
meta-value? That is, can a UDT rely on scalar undef as part of its range (a
la NaN/Inf in the numbers space) or must undef be considered part of the
Perl domain, "you're not a Thingy yet."

(The mapping of undef <-> SQL's NULL comes to mind.)

=Austin


 
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.