On Wed, Jan 01, 2020 at 03:30:44PM +0100, Marc Chantreux wrote:
>why is this ? return is the perl yield. the only difference is that the
>"exhausted" situation is on your own. so basically:
>
> def count_from(x):
> while True:
> yield x
> x = x + 1
>
> naturals = count_from(0)
> print(next(naturals))
> print(next(naturals))
> print(next(naturals))
> print(next(naturals))
>
>is written in perl
>
> use experimental 'signatures';
> use feature 'say';
>
> sub count_from ($x) { sub { $x++ } }
> sub NEXT ($generator) { $generator->() }
> my $naturals = count_from 0;
>
> say NEXT $naturals;
> say NEXT $naturals;
> say NEXT $naturals;
> say NEXT $naturals;
>
>* perl were about unix culture, mailing lists and so on: they setup a
> confortable cocoon to work together and this cocoon became an echo
> chamber when the other communities started to use third party services
> like stack overflow.
https://github.com/drathier/stack-overflow-import
>* the python community was unfair comparing the langages (using ugly
> perl code and nice python counterparts). instead of taking time to
> explain all the biases, perl community repetedly asserted that the
> authors of those article were incompetents and gone away.
Not sure about anyone else, but comparing the Python vs Perl example you
gave above, I would still say Python is the nicer-looking language.
No comments:
Post a Comment