[cap-talk] small notes re: waterken

Karp, Alan H alan.karp at hp.com
Wed Mar 2 14:58:13 PST 2011


Tyler Close wrote:

> For concrete types, such as String,
> there's no way to create an alternate implementation that behaves like
> a promise. So you have to instead use an object of type
> Promise<String>.

One thing I tried was defining an interface type for each concrete type, e.g., StringHolder, IntegerHolder, etc.  The tradeoff comes when you need to use the value in some way, e.g., 

IntegerHolder c = new IntegerHolder(a.get() + b.get())

or even better

IntegerHolder c = new IntegerHolder(a.plus(b))

because a and b can be promises.

Ya pays yer money and ya makes yer choice.

________________________
Alan Karp
Principal Scientist
Virus Safe Computing Initiative
Hewlett-Packard Laboratories
1501 Page Mill Road
Palo Alto, CA 94304
(650) 857-3967, fax (650) 857-7029
http://www.hpl.hp.com/personal/Alan_Karp





More information about the cap-talk mailing list