Feb. 5th, 2007

gusl: (Default)
PL people,

I'd like to have a language that allows a double assignment like this:

radius * angle =  convert (x,y);

which assigns two local variables 'radius' and 'angle' to the (double) return value of convert.


The declaration for the 'convert' function is as follows:
double * double convert (double x, double y){
 return makeRadius(x,y) * makeAngle(x,y);
}

(We need a better choice than '*', since that usually means multiplication)


You could also have call-dispatching on the output type, not just the input types. If you had two functions named 'convert' with the same input types, you would call the one that matches the type of the variable you're assigning to.

This would be a useful pattern, and if I had it, I would write fewer functions with side-effects (which in Java is often necessary for efficiency purposes).


* having small functions
* having no functions with side-effects
* efficiency
In Java, you have to pick 2.

February 2020

S M T W T F S
      1
2345678
9101112131415
16171819202122
23242526272829

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags