> Le 3 janv. 2016 à 01:58, Kevin Ballard <[email protected]> a écrit :
> 
>>> seq.generate().next() may not be nice, but no one can get fooled by it.
>> 
>> Well, for one thing, because it doesn't work. […]
> 
> Exactly. If `seq.generate().next()` worked, I'd be perfectly happy with that. 
> […]

Right.

> Le 3 janv. 2016 à 06:50, Brent Royal-Gordon <[email protected]> a écrit :
> 
>> If I don’t sound sympathetic, it’s because nobody has shown a use-case for 
>> this functionality, and until I see one I am going to have a hard time 
>> believing there’s a problem worth solving.  If you want to make the case 
>> that we need something like this, please show me why. 
> 
> Didn't this thread start off with a use case?
> 
>       seq.lazy.filter(predicate).first                // is not actually 
> lazy, and Swift provides no good way to do this
> 
> One way to fix this is to add `first` to `SequenceType`, but it feels strange 
> for a property to potentially consume part of the sequence. `buffered` 
> ultimately has the same problem. By representing this as a function, it at 
> least looks like something that might have side effects.

Out of honesty, here is another use case: `database.fetch(…).first`.

Since this is not possible today, database APIs have to expose another 
`fetchFirst()` (fetchOne, pluck, whatever) method, that uses a temporary 
generator on the sequence returned by the fetch() method.

If sequence.first would exist, the database API would not have to define this 
extra method.

Gwendal

_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to