[swift-users] Need better name, want to hide generator
Dmitri Gribenko
gribozavr at gmail.com
Sat Dec 19 00:50:10 CST 2015
On Fri, Dec 18, 2015 at 1:22 PM, Erica Sadun via swift-users <
swift-users at swift.org> wrote:
> 2. Is there a way to internalize the generator and not make it public? I'd
> ideally like to hide all details except the fact that this is a sequence of
> (Int, Int)
>
You can use AnySequence and AnyGenerator, but they come at a cost of
dynamic dispatch for every call. In this case, if you want this component
to be suitable for performance-critical code, I would suggest to avoid them
for now.
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>*/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20151218/2decd539/attachment.html>
More information about the swift-users
mailing list