[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Generators (iterators) for Gnu Emacs
From: |
Michael Heerdegen |
Subject: |
Re: Generators (iterators) for Gnu Emacs |
Date: |
Fri, 05 Dec 2014 19:01:27 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) |
Stefan Monnier <address@hidden> writes:
> A few comments below.
Thanks. Still using the term "generator" to avoid confusion, though I'm
going to rename the thing to "iterator".
> It's great to see that you haven't needed anything else than `gen-next'.
> I'd have expected a `gen-done-p' test to be needed/handy every once in
> a while.
Dunno if that would be useful, I never missed it, but it should be
trivial to introduce.
> I guess a `gen-cons' would be more efficient than this
> (gen-append (gen-from-elts value) ...).
I'm not sure implementing `gen-cons' is a good idea. Generators are not
built from conses - but having `gen-cons' would allow to build generator
pseudo lists. This package is about introducing a different concept.
Plus, using `gen-cons' as a building block of generators would create
deeply nested lambdas that would soon hit `max-lisp-eval-depth' when
requesting elements. Avoiding recursion, which Emacs is not good at, is
crucial allover in this package.
Pushing to generators should not be needed repeatedly - if you think you
want this, use lists. In the above case, it is just coincidence that
the first generator has only one element. And I don't think efficiency
is an issue here. If you think it is I will rewrite that code, but
avoiding a `gen-cons'.
> > (defmacro gen-delay-expr (expression)
>
> Have you made use of this? I'm not sure it really fits. I mean,
> technically it works, but I'm not completely sure if pretending it's
> a generator is a clever idea or not.
I defined it because I need it in `gen-cache', and because it wasn't
existing yet in Emacs. Do you think delay-expression should be defined
somewhere else in Emacs? Then I would be happy to use it for
`gen-cache'.
Thanks,
Michael.
- Re: Generators (iterators) for Gnu Emacs, (continued)
- Re: Generators (iterators) for Gnu Emacs, David Kastrup, 2014/12/05
- Re: Generators (iterators) for Gnu Emacs, Stefan Monnier, 2014/12/05
- Re: Generators (iterators) for Gnu Emacs, Michael Heerdegen, 2014/12/05
- Re: Generators (iterators) for Gnu Emacs, Stefan Monnier, 2014/12/05
- Re: Generators (iterators) for Gnu Emacs, Michael Heerdegen, 2014/12/05
- Re: Generators (iterators) for Gnu Emacs, Stefan Monnier, 2014/12/05
Re: Generators (iterators) for Gnu Emacs,
Michael Heerdegen <=
Re: Generators (iterators) for Gnu Emacs, Thierry Volpiatto, 2014/12/05
- Re: Generators (iterators) for Gnu Emacs, Stefan Monnier, 2014/12/05
- Re: Generators (iterators) for Gnu Emacs, Michael Heerdegen, 2014/12/05
- Re: Generators (iterators) for Gnu Emacs, Stefan Monnier, 2014/12/05
- Re: Generators (iterators) for Gnu Emacs, Daniel Colascione, 2014/12/05
- Re: Generators (iterators) for Gnu Emacs, Michael Heerdegen, 2014/12/05
- Re: Generators (iterators) for Gnu Emacs, Michael Heerdegen, 2014/12/05
- Re: Generators (iterators) for Gnu Emacs, Stefan Monnier, 2014/12/05