Thread overview |
---|
August 29, 2016 Does D have anything like the generators of Python and some other languages? | ||||
---|---|---|---|---|
| ||||
Hi group, Does D have anything like the generators of Python and some other languages? Thanks. |
August 29, 2016 Re: Does D have anything like the generators of Python and some other languages? | ||||
---|---|---|---|---|
| ||||
Posted in reply to A D dev | On Monday, 29 August 2016 at 21:24:52 UTC, A D dev wrote: > > Hi group, > > Does D have anything like the generators of Python and some other languages? > > Thanks. Ranges serve some of the purposes that generators are often used for: http://dlang.org/phobos/std_range.html But you can of course make true coroutine-based generators with fibres: http://dlang.org/phobos/core_thread.html#.Fiber "fibre" is basically a synonym of "coroutine". |
August 29, 2016 Re: Does D have anything like the generators of Python and some other languages? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Cauterite | On Monday, 29 August 2016 at 21:28:15 UTC, Cauterite wrote:
> Ranges serve some of the purposes that generators are often used for: http://dlang.org/phobos/std_range.html
>
> But you can of course make true coroutine-based generators with fibres: http://dlang.org/phobos/core_thread.html#.Fiber
Thanks. Both sound interesting. Will check.
|
August 29, 2016 Re: Does D have anything like the generators of Python and some other languages? | ||||
---|---|---|---|---|
| ||||
Posted in reply to A D dev | On 08/29/2016 02:50 PM, A D dev wrote: > On Monday, 29 August 2016 at 21:28:15 UTC, Cauterite wrote: >> Ranges serve some of the purposes that generators are often used for: >> http://dlang.org/phobos/std_range.html >> >> But you can of course make true coroutine-based generators with >> fibres: http://dlang.org/phobos/core_thread.html#.Fiber > > Thanks. Both sound interesting. Will check. > Here is an example of a generator fiber: http://ddili.org/ders/d.en/fibers.html#ix_fibers.Generator,%20std.concurrency Ali |
August 29, 2016 Re: Does D have anything like the generators of Python and some other languages? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ali Çehreli | On Monday, 29 August 2016 at 22:03:35 UTC, Ali Çehreli wrote:
> Here is an example of a generator fiber:
Thanks, will take a look.
|
August 30, 2016 Re: Does D have anything like the generators of Python and some other languages? | ||||
---|---|---|---|---|
| ||||
Posted in reply to A D dev | On Monday, 29 August 2016 at 21:24:52 UTC, A D dev wrote: > > Hi group, > > Does D have anything like the generators of Python and some other languages? > > Thanks. There's a Generator class in std.concurrency. I haven't used Python all that much so I can't say for certain whether it is the same or not. https://dlang.org/phobos/std_concurrency.html#.Generator |
August 30, 2016 Re: Does D have anything like the generators of Python and some other languages? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Meta | On Tuesday, 30 August 2016 at 00:57:05 UTC, Meta wrote: > There's a Generator class in std.concurrency. I haven't used > https://dlang.org/phobos/std_concurrency.html#.Generator Thanks, Meta. |
Copyright © 1999-2021 by the D Language Foundation