[concurrency-interest] Ops type names

Gregg Wonderly gergg at cox.net
Tue Jan 15 16:25:38 EST 2008


Joshua Bloch wrote:
> Gregg,
>  
> Hmmm... the onInt and withInt don't really feel right to me.  If people 
> don't like intOp (or intFn), then I think we should go with David's 
> inclination (intToInt).

I'm just thinking out loud here...  The main focus is that these are operations 
on one type that produce another type.  Thus the doubleToInt etc names feel 
good.  The use of intToInt seems okay, but perhaps doubleToDouble is just a lot 
of typing and becomes a bit verbose.  The use of overloading in java allows the 
parameterization to change but not the return type, so we are motivated by that 
to come up with unique names such as intToDouble and shortToDouble because we 
can't do

	double op( int s );
	double op( short s );

I'm not sure where overloading sits in all of these discussions.  My previous 
suggestion was about a prefix, but perhaps a suffix notation is better, as in

	double doubleFor( int s );
	double doubleFor( short s );

or

	double doubleFrom( int s );
	double doubleFrom( short s );

or

	double doubleOn( int s );
	double doubleOn( short s );

or even just using the single name that Josh suggested for all of the result 
type operations by relying on overloading to resolve the implementation.

	double doubleOp( int s );
	double doubleOp( short s );

There are other suffixes besides 'For' and 'From', such as 'With', 'Of' etc.  I 
have some casual attraction to the 'On' form because I think of the sentence "I 
want a double value, resulting from an operation on ...".

Probably you have gone over this viewpoint already, so sorry for repeating if 
so.  Just trying to think about how to get to simple names that are effective, 
but not overwhelming to draw into conversation.

Gregg Wonderly


More information about the Concurrency-interest mailing list