My favorites | Sign in
Project Home Wiki Issues Source
READ-ONLY: This project has been archived. For more information see this post.
Search
for
  Advanced search   Search tips   Subscriptions
Issue 26: Allow for safe method chaining by providing magic dummy objects
1 person starred this issue and may be notified of changes. Back to list
Status:  Fixed
Owner:  daniel.d...@gmail.com
Closed:  Jun 2009
Cc:  funnyso...@gmail.com


 
Reported by daniel.d...@gmail.com, Jun 26, 2009
Consider the following situation

$orders = $dbrh -> orders->get(\@orderids); # Might return null
$order = $orders->next; # might return false instead of a record

say "Status ",      $order->status; # might be a null ref
say "Source name ", $order->source->name; # doubly so


There are at least three places where this code could fail due to null
references.

Instead of returning false to indicate no record(s) found, return a magic
object. This object should use overload to return a false value in scalar
context, but still allow the above code to work and prevent null ref errors.

Jun 26, 2009
#1 daniel.d...@gmail.com
First attempt committed to head
Status: Fixed

Powered by Google Project Hosting