Making it happen
Archive for November, 2006
Amazon’s Human-Driven Web Service
Nov 2nd
I’ve read of this long time ago – go check it out if you didn’t.
read (photo);
photoContainsHuman = callMechanicalTurk(photo);
if (photoContainsHuman == TRUE){
Java: Return multiple values
Nov 2nd
This has been in discussion since 1999, however the comitee responsible for new language features hasn’t accepted anything to make our life easier.
Consider you want to return an integer array and a String array. Obiously they can’t be returned using a single return statement, however as the array address is not passed by reference you can’t allocate the arrays inside the function and fill them.
A workaround would be to get the sizes first, allocate arrays and pass them – still not possible because you can’t return two sizes. Adding two functions to independently return each size solves the problem – but you’ve added two supplementary functions and, still, this may involve doing useless queries or computations.
Another workaround is to return an Object array with the two arrays in it. The casts would be somewhat ugly but it works fine.
The conclusion is that it’s useless to design a simple and clean language if you have to write ugly or inefficient code for realtively simple tasks.
