branches , switches control inputs

Official support for: loomer.co.uk
Post Reply New Topic
RELATED
PRODUCTS

Post

Sometimes it's confusing
Switches only accept numeric inputs (0,1,2,3,etc..) because they can have mulitple inputs/outputs , but why don't they accepts true/false which would be equivalent to 0-1 , this would make sense if the switch is set to only two inputs/outputs ?

Branches on the other hand accept both numeric(0,1 only ) and true false ..( restricted to only 2 inputs, outputs ) , but in the info module there is no information that it can also accept 0-1
Eyeball exchanging
Soul calibrating ..frequencies

Post

Anything that accepts a true/false boolean type will accept any type, as they are treated as truthy or falsy and implicitly converted to boolean. Essentially the following things are falsy, (and by omission everything not lissed is truthy)
- boolean false
- numeric 0
- an empty array
- an empty tuple
- an empty string
- an empty map
- the `undefined` object.

As for switches accepting booleans, yes, I believe I can see the logic in treating booleans as numbers 0 or 1 everywhere. Let me look into it, but I think that actually makes a lot of sense. I guess I'll allow only a single implicit conversion for the time being, as otherwise I think all these conversion would leave a hole in the type system. To clarify: if an inlet accepts a number, a boolean should be implicitly converted to 0 or 1, but an empty array will not be implicitly converted to a boolean and then implicitly converted to a number. For those cases, there are explicit conversion modules if need be.

Thanks for the suggestion!
Architect, the modular MIDI toolkit, beta now available for macOS, Windows, and Linux.

Post

Actually, I've had a look through the code and there are some places where boolean types are treated as 0 and 1, so absolutely it makes sense to do this throughout.
Architect, the modular MIDI toolkit, beta now available for macOS, Windows, and Linux.

Post Reply

Return to “Loomer”