The Artima Developer Community
Sponsored Link

Java Buzz Forum
Caller context and list.add(..).add(..).add(..)

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
dion

Posts: 5028
Nickname: dion
Registered: Feb, 2003

Dion Almaer is the Editor-in-Chief for TheServerSide.com, and is an enterprise Java evangelist
Caller context and list.add(..).add(..).add(..) Posted: Apr 12, 2005 10:25 AM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by dion.
Original Post: Caller context and list.add(..).add(..).add(..)
Feed Title: techno.blog(Dion)
Feed URL: http://feeds.feedburner.com/dion
Feed Description: blogging about life the universe and everything tech
Latest Java Buzz Posts
Latest Java Buzz Posts by dion
Latest Posts From techno.blog(Dion)

Advertisement

One of the first things that bugged me about Java when I first started to use it was a small thing. Why didn't add() return the list (or Vector back then) so I could chain the calls together.

I wanted to be able to:

Vector v = new Vector().add("foo").add("bar);

The same goes for having chained set* methods:

foo.setA(a).setB(b)

We see this used, especially in certain packages such as Hibernate.

One feature that I liked in Perl was the ability to know about the callers context:

my $scalar = @list; # or function which returns a list

is very different to:

my ($element) = @list; # or function which returns a list

Sometimes I would love to do the same in this world and say "If the caller of my set method wants the object back, give it, else we are in void world and that is fine too".

Of course, I don't think this would happen :)

Another way to make me a little more happy would be to give me named parameters, but that doesn't give me the same power.

Read: Caller context and list.add(..).add(..).add(..)

Topic: Wikibook The J2ME Platform from rough draft to alpha release Previous Topic   Next Topic Topic: Sangamo’s technology (ZFP) for efficient, permanent correction of disease-causing gene...

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use