Discuss Scratch
- Discussion Forums
- » Suggestions
- » Fruitful functions! (Function reporters)
- AwesomeManJesse
- Scratcher
48 posts
Fruitful functions! (Function reporters)
As it is right now, custom blocks a.k.a. functions are void (don’t produce a result) unless explicitly programmed to set a variable to the result, and must be defined before that result is used. eg:
So if fruitful (reporter) functions (functions that produce a result) were implemented, it could look more like this:
And for this purpose, there should be temporary variables that only exist within the function.
Feedback please!
when I receive [what’s that length v]
get length of [word]::custom stack // I’m aware that there is a reporter for the length of a text input, this is just an example
say (join [the length of that is] (length)) for (2) secs
define get length of (word)
. . .
So if fruitful (reporter) functions (functions that produce a result) were implemented, it could look more like this:
when I receive [what’s that length v]
say (join [the length of that is] (length of [word]::custom)) for (2) secs
define (length of (word::custom-arg)::custom)
do {
. . .
} return (length)::custom
And for this purpose, there should be temporary variables that only exist within the function.
Feedback please!
Last edited by AwesomeManJesse (May 17, 2019 02:43:18)
Hi! It's me, AwesomeManJesse (aka AMJ). I like programming!
Also scratchblocks formatting on the forums is pretty fun too
I like helping out when I can, so leave a comment on my profile if you need help with something that I've done before / look like I'm able to do!
If I haven't done it before, I would gladly give it a go anyways!
- awesome5185
- Scratcher
1000+ posts
Fruitful functions! (Function reporters)
Sorry I'm a little confused. The ‘variables’ inside the custom blocks are already tempory.
Regards,
awesome5185
; Santa Claus and Mrs Claus wanted to get a devorce. However, being in the north pole, there was no one there to help them do that. So they used a semi colon instead; they are great for seperating two independent clauses.
- AwesomeManJesse
- Scratcher
48 posts
Fruitful functions! (Function reporters)
Sorry if I was unclear. Sorry I'm a little confused.
Do you mean the arguments passed to the custom block? Because yes, they are temporary. The ‘variables’ inside the custom blocks are already tempory.
I mean the variables used within the custom block to produce the output, eg.
define (function of (argument::custom-arg))
do {
set [temporary v] to (. . .)
} return (temporary)::custom
It depends on the implementation, the variables don't have to be temporary.
Actually, now that I think about it, it wouldn't make sense to have temporary variables within the definition (in most cases) after all.
Depends what the people think!
Last edited by AwesomeManJesse (May 17, 2019 07:40:08)
Hi! It's me, AwesomeManJesse (aka AMJ). I like programming!
Also scratchblocks formatting on the forums is pretty fun too
I like helping out when I can, so leave a comment on my profile if you need help with something that I've done before / look like I'm able to do!
If I haven't done it before, I would gladly give it a go anyways!
- Paddle2See
- Scratch Team
1000+ posts
Fruitful functions! (Function reporters)
It looks like this is a duplicate topic of this one over here so I'll close it to keep the conversation all in one place.
Please use the existing topic in the link above.
Please use the existing topic in the link above.
Scratch Team Member, kayak and pickleball enthusiast, cat caregiver.
This is my forum signature! On a forum post, it is okay for Scratchers to advertise in their forum signature. The signature is the stuff that shows up below the horizontal line on the post. It will show up on every post I make.
(credit to Za-Chary)
;
- Discussion Forums
- » Suggestions
- » Fruitful functions! (Function reporters)