View Single Post
Old 03-28-2022, 03:19 PM   #5
sai'ke
Human being with feelings
 
sai'ke's Avatar
 
Join Date: Aug 2009
Location: NL
Posts: 1,458
Default

Quote:
Originally Posted by Justin View Post
Hmm, it would probably be possible to add to EEL2 a keyword with usage of something like:
Code:
switch(x, 
  0: code,
  1: code,
  2: code,
 [ default_code]);
the caveat would be that the 0/1/2 values would need to be constant values. Probably would be most useful if x was rounded to the nearest integer, too?
Sounds great to me! Would the code blocks in that case be allowed to be multi-line if enclosed by parentheses (the way souk21 suggests), or would they have to be single lines?

And yeah, I was assuming that the cases would have to be fixed, but they would be for the typical algorithm selection use case.

And yes on the rounding. Though I'm unsure whether nearest or truncation is more desirable. From other languages, I'd usually expect the latter, but I think you should probably pick what you think is most in line with what is typical in JSFX. For the use cases I have in mind it wouldn't make a difference which one you'd pick I think.
__________________
[Tracker Plugin: Thread|Github|Reapack] | [Routing Plugin: Thread|Reapack] | [More JSFX: Thread|Descriptions|Reapack]

Last edited by sai'ke; 03-28-2022 at 03:25 PM.
sai'ke is offline   Reply With Quote