Loose ends: Optional
forax at univ-mlv.fr
Sun Jun 2 14:51:59 PDT 2013
On 06/02/2013 09:50 PM, Brian Goetz wrote:
>> They are harmful, by example, flatMap use a function that returns an Optional,
>> if people use the same function in a stream, the result is collections of Optional
> I think now we're finally coming to your real objection -- the moral hazard of "if we give people Optional, they might misuse it, so let's not give it to them, or at the very least, let's cripple it."
cripple it ?
Again, what I say is that if we define Optional has a collection of zero
or more element with a method filter, map and flatMap,
we send the wrong message to people.
Is Optional crippled if we consider that it's just an object that
represent a value or no value ?
I don't think so.
>> something we said we want to avoid.
> It is something we want to avoid -- I will certainly avoid it in my code, and criticize any code I see using this (or any of ten million other bad programming techniques.) The world is full of useful tools that that interact dangerously, such as bleach and ammonia or toasters and bathtubs.
Wrong example, I don't know in US but in France you can not have a power
outlet too close to a bathlub :)
That's exactly what we are talking about.
> We're not going to outlaw any of these just because mixing them is dangerous.
But you can don't add these 3 methods because they send the wrong message.
More information about the lambda-libs-spec-observers