Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should EnvironmentRedirect call dispatch for removeAt? #5922

Open
jamshark70 opened this issue Nov 29, 2022 · 1 comment · May be fixed by #5923
Open

Should EnvironmentRedirect call dispatch for removeAt? #5922

jamshark70 opened this issue Nov 29, 2022 · 1 comment · May be fixed by #5923
Labels

Comments

@jamshark70
Copy link
Contributor

EnvironmentRedirect help claims 'dispatch' is "A function or object that is called when the environment is modified."

However the behavior is inconsistent:

e = EnvironmentRedirect.new;

e.dispatch = { |... args| args.debug("e dispatch") };

e[\a] = 1;  // e dispatch: [ a, 1 ]

e.removeAt(\a)  // no post

At removeAt, the environment has been modified but the function was not called.

This could be resolved as follows:

	removeAt { arg key;
		var result = envir.removeAt(key);
		dispatch.value(key, nil);
		^result
	}

(One question is whether we would then need a localRemoveAt method mirroring localPut.)

telephon added a commit to telephon/supercollider that referenced this issue Dec 1, 2022
This fixes supercollider#5922

- call dispatch on removeAt (because the object changed)
- return object on removeAt (this is standard in collections)
- add localRemoveAt for removing without dispatch
@telephon telephon linked a pull request Dec 1, 2022 that will close this issue
4 tasks
@telephon
Copy link
Member

telephon commented Dec 1, 2022

I wonder whether the dispatch should be called also on clear.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants