1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
class:: EnvironmentRedirect
summary:: base class for environment redirects
categories:: JITLib>Environments, Collections>Unordered, Live Coding
related:: Classes/Environment
description::
Environment that redirects access (strong::put::) and assignment (strong::at::). It is used as a base class for redirecting Environments. For example uses, see link::Classes/LazyEnvir:: and link::Classes/ProxySpace::.
ClassMethods::
method::new
Create new environment redirect, if envir is given, it is used as a basis.
subsection:: replacing Environment class methods
EnvironmentRedirect implements some of the interface of link::Classes/Environment::
method::push, pop, make, use
InstanceMethods::
method::envir
return or replace the source environment
code::
e = LazyEnvir.new;
e.put(\x, 9);
e.envir; // look into the envir itself: for a LazyEnvir it contains Maybe as placeholders
::
subsection::redirecting objects
Overriding these methods, one can redirect where objects go when they are assigned to the space. This is done for example in link::Classes/LazyEnvir:: and link::Classes/ProxySpace::.
method::at, put, localPut, removeAt
method::dispatch
A function or object that is called when the environment is modified. The key and the changed object are passed as arguments.
code::
e = LazyEnvir.new;
e.dispatch = { |key, val| [key, val].postln };
e.put(\x, 9);
::
method::add
add an association
subsection:: replacing Environment instance methods
EnvironmentRedirect implements some of the interface of link::Classes/Environment::, which it can replace where needed.
method:: push, pop, clear, choose
method:: make, use
method:: do, keysValuesDo, sortedKeysValuesDo
method:: keysValuesArrayDo
method:: findKeyForValue
method:: know
method:: doesNotUnderstand
section::Networking
EnvironmentRedirect and its subclasses can be used to dispatch assignment over a network. To do this, a dispatch function can be supplied - see Public in strong::JITLibExtensions:: quark.
|