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

Feature request: Optional non-output from `expr` #784

Open
danfuzz opened this issue Nov 13, 2019 · 8 comments
Open

Feature request: Optional non-output from `expr` #784

danfuzz opened this issue Nov 13, 2019 · 8 comments
Labels

Comments

@danfuzz
Copy link

@danfuzz danfuzz commented Nov 13, 2019

Sometimes I use an expr — or just one sub-expression — for its side effects and don't care about an output. It would be nice if there were a way to syntactically indicate that, e.g. with a prefix word on an expression such as void (which is what JavaScript uses for this purpose, approximately), so that the resulting expr object has no outlet corresponding to the sub-expression in question.

@porres

This comment has been minimized.

Copy link
Contributor

@porres porres commented Nov 13, 2019

I think that's unnecessarily complicating

@Spacechild1

This comment has been minimized.

Copy link
Contributor

@Spacechild1 Spacechild1 commented Nov 14, 2019

I don't see the necessity, either

@danfuzz

This comment has been minimized.

Copy link
Author

@danfuzz danfuzz commented Nov 14, 2019

FWIW, I want to e.g. have seven or eight sub-expressions of which all but one are used only for side effects. Rather than have to carefully count to pick the right outlet, and worry about changing it should I rearrange the code in my expr, I'd love it if I could just end up with only the one outlet I want.

@Spacechild1

This comment has been minimized.

Copy link
Contributor

@Spacechild1 Spacechild1 commented Nov 14, 2019

Sometimes I use an expr — or just one sub-expression — for its side effects and don't care about an output.

then it's not an expression and you should use some other language construct.

@danfuzz

This comment has been minimized.

Copy link
Author

@danfuzz danfuzz commented Nov 14, 2019

then it's not an expression and you should use some other language construct.

I think it's a bit misguided to argue about this based on the strict mathematical definition of the word "expression." If that were the crux of the matter, I wouldn't expect expr to have the possibility of side effects in the first place.

The expr language already admits side effects, and it's natural to want to use them (at least to this novice Pd programmer). It's not a stretch to want to use a subexpression just for the side effects, and it's also natural to not want to end up with a messy patch with unused outlets.

FWIW here's one of the use cases that motivated my feature request (no others currently in published code, but I know I had a 5-subexpression expr at one point, with only one useful output): https://github.com/danfuzz/fuzz-synth/blob/master/Infiknob/vanilla/change-plus.pd

@Spacechild1

This comment has been minimized.

Copy link
Contributor

@Spacechild1 Spacechild1 commented Nov 14, 2019

The expr language already admits side effects, and it's natural to want to use them (at least to this novice Pd programmer). It's not a stretch to want to use a subexpression just for the side effects

you're right that it's possible to use [expr] only for certain side-effects, but I'd say it's not very idiomatic. anyway, if you don't want to count outlets, just don't put all your expressions into a single [expr] object...

@porres

This comment has been minimized.

Copy link
Contributor

@porres porres commented Nov 14, 2019

it's also natural to not want to end up with a messy patch with unused outlets.

FWIW here's one of the use cases that motivated my feature request (no others currently in published code, but I know I had a 5-subexpression expr at one point, with only one useful output): https://github.com/danfuzz/fuzz-synth/blob/master/Infiknob/vanilla/change-plus.pd

Well, I have to say I have quite messier patches with about 9 outputs from expr and not really using all of them. So yeah, I got the point right away, but as I see it, it's just not too much of a hassle. Trust me, I guess no one else abuses [expr] more than I do. I helped a lot with [expr] and wrote its help file, made all the examples. Anyway, in my opinion, it's just unnecessarily complicating to make this overhaul just for this feature.

@porres

This comment has been minimized.

Copy link
Contributor

@porres porres commented Nov 14, 2019

I also found your change-plus abstraction too unnecessarily complicated. This is how I would do it. It's much more simplified, and you also get much more useless outlets from [expr].

Screen Shot 2019-11-14 at 13 06 09


code:

#N canvas 437 63 584 638 12;
#X text 56 15 Copyright 2019 Dan Bornstein danfuzz@milk.com. Licensed
AS IS and WITHOUT WARRANTY under the Apache License , Version 2.0.
Details: http://www.apache.org/licenses/LICENSE-2.0, f 65;
#X text 54 85 Exactly like change , except that the default initial
value is "none" (not 0) and it responds to a set-none message by
resetting the value to "none." A "none" value is never output and is
considered not-equal to any actual input.;
#X obj 79 182 inlet;
#X obj 79 585 outlet;
#X obj 231 475 select 1;
#X obj 425 351 value none$0;
#X obj 318 351 value value$0;
#X obj 79 217 route bang set set-none float;
#X obj 79 550 v value$0;
#X obj 371 242 pdcontrol;
#X msg 371 215 args;
#X obj 371 185 loadbang;
#X msg 425 325 1;
#X obj 371 275 route float bang;
#X obj 307 475 v change$0;
#X obj 231 400 expr change$0 ; value$0 = $f1 ; none$0 = 0 ; change$0
= none$0 || ($f1 != value$0);
#X connect 2 0 7 0;
#X connect 4 0 8 0;
#X connect 7 0 8 0;
#X connect 7 1 6 0;
#X connect 7 2 12 0;
#X connect 7 3 15 0;
#X connect 8 0 3 0;
#X connect 9 0 13 0;
#X connect 10 0 9 0;
#X connect 11 0 10 0;
#X connect 12 0 5 0;
#X connect 13 0 6 0;
#X connect 13 1 12 0;
#X connect 15 0 4 0;

@umlaeute umlaeute added the feature label Nov 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.