Discuss Scratch

kenny2scratch
Scratcher
500+ posts

First-class procedures and custom reporters

Omg why are you bumping this it’s basically accepted…
may lord have mercy on the necroposter’s souls
Jonathan50
Scratcher
1000+ posts

First-class procedures and custom reporters

Did I miss something? I'm 90% percent sure it was never accepted
kenny2scratch
Scratcher
500+ posts

First-class procedures and custom reporters

It’s in Backlog on GitHub for 3.0 - I might have been mistaken if you meant add this to 2.0.
Jonathan50
Scratcher
1000+ posts

First-class procedures and custom reporters

kenny2scratch wrote:

It’s in Backlog on GitHub for 3.0 - I might have been mistaken if you meant add this to 2.0.
Oh, cool! I looked and I found custom reporters, but not first-class procedures.
kenny2scratch
Scratcher
500+ posts

First-class procedures and custom reporters

Hmm. I don’t think that would really flow with how Scratch works - do people really get passing the function itself as an argument instead of the result of the function? (I barely do even though I have worked with Python for about 7 years.) We don’t have first-class lists either - because they don’t go well either.

So I guess custom reporters are accepted, and no support for first-class procedures.
Blaze349
Scratcher
1000+ posts

First-class procedures and custom reporters

kenny2scratch wrote:

Hmm. I don’t think that would really flow with how Scratch works - do people really get passing the function itself as an argument instead of the result of the function? (I barely do even though I have worked with Python for about 7 years.) We don’t have first-class lists either - because they don’t go well either.

So I guess custom reporters are accepted, and no support for first-class procedures.
They aren't…
donotforgetmycode
Scratcher
1000+ posts

First-class procedures and custom reporters

Lambdas, functions and procedures are the same words written in different ways.
Jonathan50
Scratcher
1000+ posts

First-class procedures and custom reporters

donotforgetmycode wrote:

Lambdas, functions and procedures are the same words written in different ways.
No they aren't, they're different words and have different meanings
Randomness-TV
Scratcher
100+ posts

First-class procedures and custom reporters

My head just did WHAT?
No Support, too confusing
birdoftheday
Scratcher
500+ posts

First-class procedures and custom reporters

To a baby, walking is too confusing. But they soon learn it's something they cannot do without.
rdococ
Scratcher
1000+ posts

First-class procedures and custom reporters

birdoftheday wrote:

To a baby, walking is too confusing. But they soon learn it's something they cannot do without.
We should get rid of walking - crawling can already get us everywhere, why do we need to use only 2 legs? /s



Anyway, back on topic, I think this would be clearer to the newer among us (I'd put it in [img] tags, but it said “Bad image URL”).
Then, to run it:
run stored script (var) :: custom
birdoftheday
Scratcher
500+ posts

First-class procedures and custom reporters

Or you can remove “stored script” and also allow blocks to be put there without a variable (w/ rings)

I.e. What I mean is, that block you posted is a bit like if the add block were like this


([v1 v] + [v2 v] ::operators)

In the sense that if you ever wanted to add any numbers you'd first have to assign them to variables and use the variables which is exactly what “first class” isn't.

A good way to think of first class blocks is like ring blocks. Imagine if “repeat” were defined like this
define repeat (n) (script)
if <(n) = [0]> then
stop [this script v]
end
run (script) ::control
repeat ((n) - [1]) (script)

Using this idea you'd be able to do exactly that, along with hundreds of more possibilities.

Last edited by birdoftheday (Aug. 14, 2017 13:22:33)

rdococ
Scratcher
1000+ posts

First-class procedures and custom reporters

birdoftheday wrote:

Or you can remove “stored script” and also allow blocks to be put there without a variable (w/ rings)
Yeah, but I doubt that one that's too confusing to newer Scratchers will be implemented (I'm not exactly sure what you mean, actually, so correct me if you meant something else).

A good compromise might be in the form of a “on-the-spot define” reporter, with parameters like the inputs in the define hat. Since newer Scratchers (at least the ones who could even benefit from this) already know what the “define” hat block is, I think we should introduce first-class functions similarly. An example can be found here.

Last edited by rdococ (Aug. 14, 2017 13:27:42)

birdoftheday
Scratcher
500+ posts

First-class procedures and custom reporters

rdococ wrote:

birdoftheday wrote:

Or you can remove “stored script” and also allow blocks to be put there without a variable (w/ rings)
Yeah, but I doubt that one that's too confusing to newer Scratchers will be implemented (I'm not exactly sure what you mean, actually, so correct me if you meant something else).

A good compromise might be in the form of a “on-the-spot define” reporter, with parameters like the inputs in the define hat. Since newer Scratchers (at least the ones who could even benefit from this) already know what the “define” hat block is, I think we should introduce first-class functions similarly.
Edited my post above
rdococ
Scratcher
1000+ posts

First-class procedures and custom reporters

birdoftheday wrote:

Or you can remove “stored script” and also allow blocks to be put there without a variable (w/ rings)

I.e. What I mean is, that block you posted is a bit like if the add block were like this


([v1 v] + [v2 v] ::operators)

In the sense that if you ever wanted to add any numbers you'd first have to assign them to variables and use the variables which is exactly what “first class” isn't.

A good way to think of first class blocks is like ring blocks. Imagine if “repeat” were defined like this
define repeat (n) (script)
if <(n) = [0]> then
stop [this script v]
end
run (script) ::control
repeat ((n) - [1]) (script)

Using this idea you'd be able to do exactly that, along with hundreds of more possibilities.
What's stopping you from putting the “stored script”/“on the spot define” into block inputs or running it directly? It's just a reporter; like the Snap! rings.
birdoftheday
Scratcher
500+ posts

First-class procedures and custom reporters

If your proposed on the spot define block looks something like this

(the block (((2) * (2)):: grey ring) ::operators

then it's exactly what I'm talking about. I just didn't see your post while making that last one.
rdococ
Scratcher
1000+ posts

First-class procedures and custom reporters

birdoftheday wrote:

If your proposed on the spot define block looks something like this

(the block (((2) * (2)):: grey ring) ::operators

then it's exactly what I'm talking about. I just didn't see your post while making that last one.
Again, that's equivalent to placing a “report ((2) * (2))” block in a “stored script” block - when you call it, it'll still return 2*2=4. I don't see how my idea makes the functions any less first-class than the rings do.

EDIT: I'm also operating under the assumption that Scratch 3.0 will have custom reporters - which this suggestion is partly about, anyway.

Last edited by rdococ (Aug. 14, 2017 13:40:01)

birdoftheday
Scratcher
500+ posts

First-class procedures and custom reporters

So it's more like this, then?
(the block ({report ((2) * (2)) ::control}::grey ring)::operators reporter

Last edited by birdoftheday (Aug. 14, 2017 14:22:40)

sathvikrias
Scratcher
500+ posts

First-class procedures and custom reporters

birdoftheday wrote:

So it's more like this, then?
(the block ({report ((2) * (2)) ::control}::grey ring)::operators reporter
yes! HUGE BUMP
support, because it is not very complicated.
minecraftprox101
Scratcher
500+ posts

First-class procedures and custom reporters

Hi there! It looks like this topic is a duplicate. Please continue the discussion in that topic, so it all stays in one place, rather than scattered across the forums. In the future, I recommend that you search for duplicates. Thanks!


Message generated with leahcimto's duplicate message generator


EDIT: This is Sort of a Duplicate.

Last edited by minecraftprox101 (March 23, 2021 13:40:58)

Powered by DjangoBB