Discuss Scratch

r1j7r
Teacher
1 post

Custom Blocks with a Return Value

Many languages use procedures with return values.
Similar to the way
pickrandomto10
is a built in procedure with a return value, it would be nice to be able to use a custom block in this way.
Then, call to the procedure could be used in a
setto
command or in a
*0
operation or any other way that a value can be used in a program.

This language is often used in the AP Computer Science Principles course for students who have no prior programming experience, and part of the requirements of that course are a knowledge of return values.
A good way to handle that in scratch would be to make an option for the procedure to have an output value and the resulting block call becomes and oval rather than a puzzle piece.
This also prevents the bad programming practice of changing global variable values within a procedure.
medians
Scratcher
1000+ posts

Custom Blocks with a Return Value

gdfsgdfsgdfg
Scratcher
1000+ posts

Custom Blocks with a Return Value

medians wrote:

SIGH..
https://scratch.mit.edu/discuss/topic/20661

the op is talking about

r1j7r wrote:

Many languages use procedures with return values.
Similar to the way
pickrandomto10
is a built in procedure with a return value, it would be nice to be able to use a custom block in this way.
Then, call to the procedure could be used in a
setto
command or in a
*0
operation or any other way that a value can be used in a program.

This language is often used in the AP Computer Science Principles course for students who have no prior programming experience, and part of the requirements of that course are a knowledge of return values.
A good way to handle that in scratch would be to make an option for the procedure to have an output value and the resulting block call becomes and oval rather than a puzzle piece.
This also prevents the bad programming practice of changing global variable values within a procedure.
blablablahello
Scratcher
1000+ posts

Custom Blocks with a Return Value

gdfsgdfsgdfg wrote:

medians wrote:

SIGH..
https://scratch.mit.edu/discuss/topic/20661

the op is talking about

r1j7r wrote:

Many languages use procedures with return values.
Similar to the way
pickrandomto10
is a built in procedure with a return value, it would be nice to be able to use a custom block in this way.
Then, call to the procedure could be used in a
setto
command or in a
*0
operation or any other way that a value can be used in a program.

This language is often used in the AP Computer Science Principles course for students who have no prior programming experience, and part of the requirements of that course are a knowledge of return values.
A good way to handle that in scratch would be to make an option for the procedure to have an output value and the resulting block call becomes and oval rather than a puzzle piece.
This also prevents the bad programming practice of changing global variable values within a procedure.
“#1: CUSTOM REPORTER BLOCKS”

im preeeetty sure thats literally this (although they do give extra reasons thats good)
medians
Scratcher
1000+ posts

Custom Blocks with a Return Value

gdfsgdfsgdfg wrote:

medians wrote:

SIGH..
https://scratch.mit.edu/discuss/topic/20661

the op is talking about
long quote
Yes I know, which is the same thing as better custom blocks. By procedures they mean custom blocks.
owlover2010
Scratcher
100+ posts

Custom Blocks with a Return Value

Support! Snap! works this way and I think Scratch should too. It wouldn't make any changes to existing projects.
medians
Scratcher
1000+ posts

Custom Blocks with a Return Value

Powered by DjangoBB