View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide

yield vs. embedInStream

a ={{
	Pseq([1234.5], 2).embedInStream
	});{ });

here is an example that shows how an inval is passed into the stream:

f =  Prout({ arg inval;
                inval  = Prout({ arg in;
                       in = in.put(in.size.rand, 3).yield // yield returns the new inval
                }).embedInStream(inval) // embedInStream also returns the new inval

e = f.asStream;{[0,0,0,0,0,0]).postln; });

This means that the array that is passed in is modified further and further.
Usually an Event is passed as inval, often a copy of the Event.default - if one uses an EventStream, the default event is copied each time it is evaluated.

This copy is not a deep copy of the event, it contains the same elements
as the original. As a result, any event that is contained in the event is identical:

e =;
x =;
e.put(\subevent,  x);

f = e.copy;
e[\subevent] === f[\subevent]; // returns true

As a result, the parent and proto fields of an event, which are used for lookup
if a key has no match, are identical.

Event.default.parent === Event.default.parent; // returns true

this makes EventStreams more efficient and allows referential changes that are transparently passed to children.

Links to this Page