On Wed, May 10, 2006 at 05:39:33PM -0400, John Siracusa wrote:
> On 5/10/06, Jesse Brown <[EMAIL PROTECTED]> wrote:
> >I guess the question I should ask is:  Why NOT return the newly created
> >objects?
> 
> I just like to know the reasoning before I change the API :)  The code
> examples are exactly what I was looking for, thanks.  The only thing I
> remain unsure of is the scalar context return value.  I don't like it
> returning the number of items unless there's a good reason for it.  It
> seems like that info is already available elsewhere.  The other
> alternatives are:

True, it shouldn't be undertaken lightly without good reason.

Re: the scalar context return value - IS it available elsewhere? (the number of 
items added in that call) - total number of items, yes, but new ones?

It would also be useful in that it would return boolean false if there were no 
items in the list, which seems sane? 

> 
> * Return a reference to an array of added objects
> * Return the first added object.
> 
> Hm, I'm not sure I like those much either.  What I'm worried about is this:
> 
>    $widget = $o->add_widgets($some_widget);
> 
> The only way that works is if add_widgets() returns the first added
> object when called in scalar context.  But that's a pretty odd
> behavior.  Opinions?

I agree on the last one being odd (though somewhat DWYIM?). Doing my ($widget) 
= $o->add_widgets(etc), seems to make enough sense? Returns a reference to a 
list seems ok too, though how would you handle the case of 0 new items being 
added? (say, for instance:)

use MyObject;
my $o = MyObject->new ( name => foo );

# Do some thing that MIGHT collect a bunch of new widgets
my @widgets;

if ( ! $o->add_widget(@widgets) ) {
        die "No widgets added! (none found?)";
}

Of course I'm not saying doing it that way is SANE (should always see if you 
have widgets to add first before trying to add them), but it seems that you 
would want to either raise a fatal exception (probably not?), or return false.

What do you think?

> 
> -John
> 
> 
> -------------------------------------------------------
> Using Tomcat but need to do more? Need to support web services, security?
> Get stuff done quickly with pre-integrated technology to make your job 
> easier
> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid0709&bid&3057&dat1642
> _______________________________________________
> Rose-db-object mailing list
> Rose-db-object@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/rose-db-object






-----------------------------------------------------------
This message may contain confidential and/or privileged 
information. This information is intended to be read only
by the individual or entity to whom it is addressed. If
you are not the intended recipient, you are on notice that
any review, disclosure, copying, distribution or use of
the contents of this message is strictly prohibited. If
you have received this message in error, please notify the
sender immediately and delete or destroy any copy of this
message.



-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid0709&bid&3057&dat1642
_______________________________________________
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object

Reply via email to