Discuss Scratch
- Discussion Forums
- » Suggestions
- » add variadic functions/list inputs into Scratch
- SonicFanX123_321
- Scratcher
1000+ posts
add variadic functions/list inputs into Scratch
1. what is a variadic function?
variadic functions are… well… functions.. but its not an ordinary function.. well, it is, but it can accept any number of parameters.
2. how would Scratch implement variadic functions?
Snap! has variadic functions.
see those arrows? those allow you to add and remove inputs–those are variadic functions.
now, most functions would have at least 1 input, but as with the join block in Snap! no inputs are necessary.
in Lua (at least RbxLua, which is based on Lua 5.1), this is how a complete Snap! join block can be created:
in Scratch, im thinking we could implement this into some blocks where reasonable, such as the aforementioned join block.
for adding that into custom blocks (which is impossible in Snap!), im thinking 2 ways: the Lua way, the checkbox way, and the button way.
3. the Lua way
4. the checkbox way
5. the button way
6. result
all of which would result in
(no inputs, must press arrow to add an input, else returns empty value)
7. thoughts
id personally think this is a good option, and it would probably serve a lot of uses, like making a join block that automatically adds spaces after entries without clutter:
also, you would be able to add more than 1 variadic input into a block:
so, what are your thoughts?
variadic functions are… well… functions.. but its not an ordinary function.. well, it is, but it can accept any number of parameters.
2. how would Scratch implement variadic functions?
Snap! has variadic functions.
see those arrows? those allow you to add and remove inputs–those are variadic functions.
now, most functions would have at least 1 input, but as with the join block in Snap! no inputs are necessary.
in Lua (at least RbxLua, which is based on Lua 5.1), this is how a complete Snap! join block can be created:
function join(...) local args = {...} local result = "" for i, v in ipairs(args) do result = result + args[i] -- wait(0.1) -- actually i dont think this is necessary, i think this is only true for while true loops, so its better to just comment it out. end return result --[[ so that you could go for example: local helloWorld = join("hello ","world") that wouldn't give out an error, but if we removed the Return, it would error out. ]]-- end
in Scratch, im thinking we could implement this into some blocks where reasonable, such as the aforementioned join block.
for adding that into custom blocks (which is impossible in Snap!), im thinking 2 ways: the Lua way, the checkbox way, and the button way.
3. the Lua way
4. the checkbox way
5. the button way
6. result
all of which would result in
(no inputs, must press arrow to add an input, else returns empty value)
7. thoughts
id personally think this is a good option, and it would probably serve a lot of uses, like making a join block that automatically adds spaces after entries without clutter:
also, you would be able to add more than 1 variadic input into a block:
so, what are your thoughts?
Last edited by SonicFanX123_321 (Aug. 17, 2021 04:21:32)
- mitdk
- Scratcher
1000+ posts
add variadic functions/list inputs into Scratch
I support, this would be really helpful in blocks like the join block, instead of having to do a million jons, all i have to do is add some inputs
Last edited by mitdk (Aug. 16, 2021 18:50:59)
- ScolderCreations
- Scratcher
1000+ posts
add variadic functions/list inputs into Scratch
I don't think that's the best name you could use, maybe list inputs would be better?
- 1492864
- Scratcher
500+ posts
add variadic functions/list inputs into Scratch
Converted to Scratchblocks
(join [][]@delInput@addInput::operators)
[scratchblocks]
(join [][]@delInput@addInput::operators)
[/scratchblocks]
Scratcheth f'rum us'r | 1 year on Scratcheth | 750+ posts| Inching to 1000 posts, 1 posteth at a timeth
Mine own most did view projecteth | Mine own most did love and fav'd projecteth | Latest projecteth |
Highlight h're and shift+down to readeth the rest.
The most did suggest suggestion:
Dark mode
- NanoRook
- Scratcher
1000+ posts
add variadic functions/list inputs into Scratch
This is a duplicate topic, just give me a min while i find the link.
If you have nothing to actually add to the discussion, just wait to make your post until you find the link.
Anyways, yeah, this seems like a neat idea. Like Scolder said it would need a better name, but I would really like to see functions in Scratch expanded more.
I LOVE BEING PURPLE!!!! JOIN THE PURPLE COALITION TODAY IF YOU ALSO LOVE BEING PURPLE. PURPLE IS THE NEW BLUE! PURPLE IS THE SUPERIOR NAVBAR COLOR! YYYEAAHHHHH BABY!!!!
- Quantum-Cat
- Scratcher
1000+ posts
add variadic functions/list inputs into Scratch
Support. This would reduce the clutter that comes from scripts that are made to achieve this.
I think it should be the button way; it is simple to understand (perhaps you could change the name so it fits scratch) and will enable you to add multiple variadic inputs. for adding that into custom blocks (which is impossible in Snap!), im thinking 2 ways: the Lua way, the checkbox way, and the button way.
Notice: Everything below the solid grey line (↑↑) above is my signature and appears on every post I make. Here, it is okay for you to advertise
your projects and other creations. To create your own, scroll to the bottom of the Discussion Home page and select “change your signature”.
I aplogise if I seem a bit too serious on the forums, but I am always open to feedback on my profile.
Past PPTBF Curator || Forum Helper (TFH) || Some Python, HTML and C
————————————————————————————
————————————————————————————
Quantum-Cat
- SonicFanX123_321
- Scratcher
1000+ posts
add variadic functions/list inputs into Scratch
thanks, was trying to figure out how to add these in but didnt find it Converted to Scratchblocks(join [][]@delInput@addInput::operators)[scratchblocks]
(join [][]@delInput@addInput::operators)
[/scratchblocks]
- SonicFanX123_321
- Scratcher
1000+ posts
add variadic functions/list inputs into Scratch
hmm… yeah, itd seem better, id think youd name them the same as in Snap I don't think that's the best name you could use, maybe list inputs would be better?!, but i dont know what you call them there, so lets just stick to list inputs.
- SonicFanX123_321
- Scratcher
1000+ posts
add variadic functions/list inputs into Scratch
yeah, its super useful I support, this would be really helpful in blocks like the join block, instead of having to do a million joins, all i have to do is add some inputs
the name me and perhaps you could change the name so it fits scratch@ScolderCreations decided on so far is list inputs
yeah, it would be easier to understand if you didn't know what a variadic function was I think it should be the button way
yeah, you really cant do much with custom blocks, like you cant return values from it yet… Anyways, yeah, this seems like a neat idea. Like Scolder said it would need a better name, but I would really like to see functions in Scratch expanded more.
- PixelYoshi
- Scratcher
100+ posts
add variadic functions/list inputs into Scratch
how would this work in custom blocks, though? currently, custom inputs work like variables set within the block, so if this was implemented, how would the code figure out which input to use with the variable? example:
define do something (input)how many times would this repeat the code? you can't have multiple “input” blocks because of the possibility for infinite inputs, so i don't think this would work at all. however, on blocks like the join block, it would be much more efficient than stacking a bunch of join blocks.
repeat (input)
... ::grey
end
do something (2)(4) @delInput@addInput ::custom
Last edited by PixelYoshi (Aug. 17, 2021 04:41:40)
- SonicFanX123_321
- Scratcher
1000+ posts
add variadic functions/list inputs into Scratch
hmm, maybe just the first input, and ignore all of the others? how many times would this repeat the code?
- PkmnQ
- Scratcher
1000+ posts
add variadic functions/list inputs into Scratch
There's also a suggestion that suggests to add these variadic inputs to already existing blocks. I think that's a good suggestion, so of course I'd think of this one as a good one too. I think the button way is the best.
Last edited by PkmnQ (Aug. 17, 2021 12:27:03)
This is an account that exists.
Here, have a useful link:
The Official List of Rejected Suggestions by Za-Chary
- ScolderCreations
- Scratcher
1000+ posts
add variadic functions/list inputs into Scratch
Of course, you would be able to put a list reporter inside one of the inputs, and it would add the values of the list.
- PixelYoshi
- Scratcher
100+ posts
add variadic functions/list inputs into Scratch
that would be the same as just one input, so it might be best to just use this in existing reporters and booleans.hmm, maybe just the first input, and ignore all of the others? how many times would this repeat the code?
- SonicFanX123_321
- Scratcher
1000+ posts
add variadic functions/list inputs into Scratch
whyd you have that though, anyway?that would be the same as just one input, so it might be best to just use this in existing reporters and booleans.hmm, maybe just the first input, and ignore all of the others? how many times would this repeat the code?
- SonicFanX123_321
- Scratcher
1000+ posts
add variadic functions/list inputs into Scratch
bump
u u
m m
p p
u u
m m
p p
- Discussion Forums
- » Suggestions
- » add variadic functions/list inputs into Scratch