Discuss Scratch

Zappy1333
Scratcher
100+ posts

Non void functions

In scratch, if you make a block, it can use arguments, but it cannot return a value.

Example:

set [name] to [generate_name()]

I thin this would be a very useful feature because although there are ways to do this, it requires more blocks

Thankyou- Zappy1333

Supporters:

gregory9
RalphMath
hppavilion

Last edited by Zappy1333 (Jan. 4, 2015 11:12:15)

DemCupcakesYo
Scratcher
100+ posts

Non void functions

I'm sorry, but I don't understand. Could you please explain?

-DemCupcakesYo

If you support, it should be +1. If you don't, it should be +0, not -1. If you half-support, it should be +1/2 or +0.5, not +0. You can't subtract from the supporters.

My browser / operating system: Windows 7, Chrome 36.0.1985.125, Flash 14.0 (release 0)

Zappy1333
Scratcher
100+ posts

Non void functions

DemCupcakesYo wrote:

I'm sorry, but I don't understand. Could you please explain?
What I mean is, when you make a block, it can return a variable that can be set inside the define block

Here is a link I found about functions

It's the alternative of doing this:
define RandomBlock
set (return value::motion) to (pick random (1) to (10))


when green flag clicked
RandomBlock
set (x::motion) to (return value::motion)


because instead you could do this:

define RandomBlock
return (pick random (1) to (10))


when green flag clicked
set (x::motion) to ({RandomBlock :: looks})

Last edited by Zappy1333 (Jan. 4, 2015 11:18:57)

gregory9
Scratcher
100+ posts

Non void functions

Support.

Use DuckDuckGo instead of Google, Bing, or Yahoo

Check out Coursacado, and SBX Share!

I am gw90 on GitHub
stickfiregames
Scratcher
1000+ posts

Non void functions

This already suggests custom reporters and booleans.

define(function(arg1 :: custom-arg) (arg2 :: custom-arg) :: custom) :: custom hat
::custom cstart
...
{return (... :: grey) :: custom cap} :: custom cend cap

Last edited by stickfiregames (Dec. 7, 2014 14:09:25)











If you can read this, my signature cubeupload has been eaten by an evil kumquat!




or you just used Inspect Element, you hacker

;
theonlygusti
Scratcher
1000+ posts

Non void functions

Has already been suggested … a lot.

The ST have already pretty much implemented this anyways.

lalala3
Scratcher
100+ posts

Non void functions

theonlygusti wrote:

Has already been suggested … a lot.

The ST have already pretty much implemented this anyways.
Pretty sure they haven't. Please explain.

Oh yeah, I'd also like to add that “has already been suggested” means that you should go over there and add your support, not that you should let the issue drop.

Last edited by lalala3 (Dec. 9, 2014 23:33:49)


Zro716
Scratcher
1000+ posts

Non void functions

theonlygusti wrote:

The ST have already pretty much implemented this anyways.
citation needed

As a long time Scratcher, I have found new meaning to the name “Scratch”: for me, it means to “scratch that itch”, to come back again and again to realize new ideas in this toy language, even when I'm capable of creating my projects in real programming languages years later. It's a friend that helped me to pursue programming and get me to enjoy its fruit. I'm certain many others who have walked this path as well have grown fond of its importance in their life.
Cyoce
Scratcher
500+ posts

Non void functions

theonlygusti wrote:

Has already been suggested … a lot.

The ST have already pretty much implemented this anyways.
How has the ST implemented this? Where? If it has, I support the ST making it a lot more accessible.
MegaApuTurkUltra
Scratcher
1000+ posts

Non void functions

Zro716 wrote:

theonlygusti wrote:

The ST have already pretty much implemented this anyways.
citation needed

$(".box-head")[0].textContent = "committing AT crimes since $whenever"
RalphMath
New to Scratch
27 posts

Non void functions

I strongly support this and not just because it would help Scratch programming. IMHO the best argument is that value returning functions are central to both programming and more generally mathematics. Without it, Scratch is not allowing what's certainly a central idea of all algorithmic systems to be explored.

A possible way to do this might be to just have a simple “return” control block, i.e.
return [ ]
It would both set the value of the block for the calling block and act as a “stop” for the custom block. It could also be used for a non-value returning block to terminate, the value wouldn't be needed in this case. This also has the advantage of looking like most other programming languages.

define Raise (base) to (exp)
if <<(base) < [0]> and <<(exp) mod [0]> > [0]>> then
return[] // imaginary
end
if <<(base) < [0]> and (((exp) mod [2]) = [1])> then // odd power of negative number
return(([e^ v] of (([ln v] of ([abs v] of (base))) * (exp))) * [-1])
else // even power of any number
return([e^ v] of (([ln v] of ([abs v] of (base))) * (exp)))
end
RalphMath
New to Scratch
27 posts

Non void functions

To use the above:

set [value v] to (Raise [-2] to (power))

or maybe this would be clearer:

set [value v] to (call (Raise [-2] to (power)))
Zappy1333
Scratcher
100+ posts

Non void functions

hppavilion
Scratcher
100+ posts

Non void functions

Support
And I STILL want to know where this has been implemented, if it apparently has.
ChocolatePi
Scratcher
1000+ posts

Non void functions

Zappy1333 wrote:

Bump
I believe this is working on being implemented. I saw a ST member post it on something.
Birdlegs
Scratcher
1000+ posts

Non void functions

This really makes too much sense.

Get a sweet lick of my new game right here! It's a tasty one!

Powered by DjangoBB