RFluff
April 28, 2020, 7:40am
1
I’m trying to adapt one of the PLx help pages example by removing some lookup indirection. Alas it doesn’t seem to work as expected
~b = [1, 2, 3];
r = PLn(PLseq(\b, cutItems: false)).asStream;
r.nextN(2); // -> [nil, nil]
With PL
or Pn
instead of PLn
it works “fine”… well at least it doesn’t return nil
right away, but of course there’s immediate replacement with those if ~b
is changed.
This seems to be an incosistency, thanks for the report. I’d need more free time to look into it - which I haven’t right now …
However for the moment you can do this:
~b = [1, 2, 3];
~p = PLseq(\b);
r = PLn(\p).asStream;
r.nextN(2); // -> [1, 2]
RFluff
April 28, 2020, 10:42am
3
The problem is that PLn always does a lookup for its item
, so it doesn’t seem to accept an object other than a symbol for item
:
PLn : Pn {
var <>item, <>repeats, <>envir;
*new { |item, repeats = inf, envir = \current|
^super.newCopyArgs(
Plazy({ envir.miSC_getEnvir[item] }), // <- always lookup
PL(repeats, repeats, 1, envir)
)
}
storeArgs { ^[item, repeats, envir] }
}