Prove that using a range operator in a loop does not use additional memory

后端 未结 3 1157
野的像风
野的像风 2021-01-02 11:08

The current documentation for the Range operator .. states that it will not burn up memory for counting loops:

... The range operator is useful for wr

3条回答
  •  庸人自扰
    2021-01-02 12:14

    The last time perlop says this

    Be aware that under the current implementation, a temporary array is created, so you'll burn a lot of memory if you write something like this:

    is in version 5.4_68.

    In 5.4_69 (released on 29 June 1998) it changes to being very close to the current version

    In the current implementation, no temporary array is created when the range operator is used as the expression in C loops, but older versions of Perl might burn a lot of memory when you write something like this:

    But I can't find the change mentioned in a perldelta anywhere!

    Anyway, we're talking about a sixteen-year-old fix,

提交回复
热议问题