[swift-evolution] Add an ifPresent function to Optional
Dmitri Gribenko
gribozavr at gmail.com
Mon Mar 14 17:39:34 CDT 2016
On Mon, Mar 14, 2016 at 3:37 PM, Erica Sadun <erica at ericasadun.com> wrote:
> On Mar 14, 2016, at 4:33 PM, Dmitri Gribenko <gribozavr at gmail.com> wrote:
>>
>> On Mon, Mar 14, 2016 at 1:28 PM, Erica Sadun via swift-evolution
>> <swift-evolution at swift.org> wrote:
>>>
>>>> On Mar 14, 2016, at 2:18 PM, Daniel Vollmer via swift-evolution <swift-evolution at swift.org> wrote:
>>>>
>>>> Hi,
>>>>
>>>>> On 13 Mar 2016, at 18:04, Erica Sadun via swift-evolution <swift-evolution at swift.org> wrote:
>>>>>
>>>>> I am in favour of making optionals consistently act like 1-item-max collections.
>>>>
>>>> Why stop there? Why not make all non-optionals collections of one?
>>>
>>> I don't quite see what advantage would that have. Could you elaborate?
>>
>> I think that's exactly Daniel's point, that it would be absurd to do so.
>>
>> Dmitri
>
> Would you support removing map and flapMap from optionals then?
No. My argument is that map on collections and on optionals are two
completely different things. They unify on a level that does not
exist in Swift (higher-kinded types). We could name Optional.map()
differently, and that would be a separate decision from renaming
Collection.map(), but we used the name `map` primarily because of
precedent, not because there is a HKT notion of these two operations
being the same.
Dmitri
--
main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
(j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com>*/
More information about the swift-evolution
mailing list