Discuss Scratch

DaEpikDude
Scratcher
1000+ posts

Why no for loops?

Most people who've used other programming languages probably know about for loops.
How come Scratch doesn't have them yet?
I understand you can work it around with a variable, but that applies to all languages.
Why not make it the first list C block?
for each (item) in [list v] {
...
}::list //Not sure about the colour of the "item" reporter
The “item” would be duplicated when you interact with it (think custom block arguments).
Before you go and say “but there's a workaround”, that doesn't stop other languages from having them, despite being able to use while loops.
I know Scratch isn't “other languages”, but this makes it really easy to interact with everything in a list.

And all the world over, each nation's the same,
They've simply no notion of playing the game.
They argue with umpires, they cheer when they've won,
And they practice beforehand, which ruins the fun!
FancyFoxy
Scratcher
500+ posts

Why no for loops?

I support this. This is one of those blocks that you will see again in other languages. Why not here?

THIS IS MY SIGNATURE. THIS MEANS IT IS AN AUTOMATIC MESSAGE THAT APPEARS AT THE BOTTOM OF ALL MY POSTS.
Hi! I'm FancyFoxy! I create animations and games that were never, EVER meant to be taken seriously.
FancyFoxy Heroes and #Thanksgiving are some of my latest projects, check them out!
Wahsp
Scratcher
1000+ posts

Why no for loops?

FancyFoxy wrote:

I support this. This is one of those blocks that you will see again in other languages. Why not here?
Because America!
No? Sorry

Anyway I give full support as well.

(also it's not important but when I was making the text grey I spelled it with an a because also america) I'll leave

​I am Wahsp
______________________________________________________

Formerly pretty active on the forums, probably mostly retired now…
If you see one of my posts send me a hello!
______________________________________________________
PkmnQ
Scratcher
1000+ posts

Why no for loops?

DaEpikDude wrote:

Most people who've used other programming languages probably know about for loops.
How come Scratch doesn't have them yet?
I understand you can work it around with a variable, but that applies to all languages.
Why not make it the first list C block?
for each (item) in [list v] {
...
}::list //Not sure about the colour of the "item" reporter
The “item” would be duplicated when you interact with it (think custom block arguments).
Before you go and say “but there's a workaround”, that doesn't stop other languages from having them, despite being able to use while loops.
I know Scratch isn't “other languages”, but this makes it really easy to interact with everything in a list.
While it is consistent, the name isn't good.

This is an account that exists.

Here, have a useful link:
The Official List of Rejected Suggestions by Za-Chary

DaEpikDude
Scratcher
1000+ posts

Why no for loops?

PkmnQ wrote:

DaEpikDude wrote:

Most people who've used other programming languages probably know about for loops.
How come Scratch doesn't have them yet?
I understand you can work it around with a variable, but that applies to all languages.
Why not make it the first list C block?
for each (item) in [list v] {
...
}::list //Not sure about the colour of the "item" reporter
The “item” would be duplicated when you interact with it (think custom block arguments).
Before you go and say “but there's a workaround”, that doesn't stop other languages from having them, despite being able to use while loops.
I know Scratch isn't “other languages”, but this makes it really easy to interact with everything in a list.
While it is consistent, the name isn't good.
What would you suggest?
“For” seems to make its function clear: it does something for every item in the list.

And all the world over, each nation's the same,
They've simply no notion of playing the game.
They argue with umpires, they cheer when they've won,
And they practice beforehand, which ruins the fun!
braxbroscratcher
Scratcher
1000+ posts

Why no for loops?

set [counter v] to [0]
repeat (length of [list v] :: list)
change [counter v] by (1)
. . . :: grey // loop contents
end
(item (counter) of [list v] :: list) // use this for inputs

I don't see why we need it, the workaround's pretty easy. Once we get custom loops this would be even easier.


My signature is kumquat proof.
But not tangerine pro-
nomnomnomnomnom










Current Project:
n/a
Quotes: “In our last hour, we burn the most brightly, trying to deny that we are burning out.” -Me
“Well, no. 1024 Killerbytes make a Murderbyte.” -MegaByteCorporations
“I hate out of context quotes.” -Me
“I hate it when Cubeupload breaks.” -Also me
Charles12310
Scratcher
1000+ posts

Why no for loops?

braxbroscratcher wrote:

set [counter v] to [0]
repeat (length of [list v] :: list)
change [counter v] by (1)
. . . :: grey // loop contents
end
(item (counter) of [list v] :: list) // use this for inputs

I don't see why we need it, the workaround's pretty easy. Once we get custom loops this would be even easier.
I don't think that's what they're talking about.

set [a v] to [0]
set [b v] to [0]
set [content v] to [...]
repeat (length of [list v])
change [a v] by (1)
if <(item (a) of [list v]) = (content)> then
change [b v] by (1)
end
end
repeat (b)
...
end


A few internet communication companies want to corrupt the internet by getting rid of net neutrality. Stop Them!
braxbroscratcher
Scratcher
1000+ posts

Why no for loops?

Charles12310 wrote:

braxbroscratcher wrote:

set [counter v] to [0]
repeat (length of [list v] :: list)
change [counter v] by (1)
. . . :: grey // loop contents
end
(item (counter) of [list v] :: list) // use this for inputs

I don't see why we need it, the workaround's pretty easy. Once we get custom loops this would be even easier.
I don't think that's what they're talking about.

set [a v] to [0]
set [b v] to [0]
set [content v] to [...]
repeat (length of [list v])
change [a v] by (1)
if <(item (a) of [list v]) = (content)> then
change [b v] by (1)
end
end
repeat (b)
...
end
he's talking about a for loop and a reporter that yields an item of a list based upon the iteration. It's really easy.


My signature is kumquat proof.
But not tangerine pro-
nomnomnomnomnom










Current Project:
n/a
Quotes: “In our last hour, we burn the most brightly, trying to deny that we are burning out.” -Me
“Well, no. 1024 Killerbytes make a Murderbyte.” -MegaByteCorporations
“I hate out of context quotes.” -Me
“I hate it when Cubeupload breaks.” -Also me
DaEpikDude
Scratcher
1000+ posts

Why no for loops?

braxbroscratcher wrote:

set [counter v] to [0]
repeat (length of [list v] :: list)
change [counter v] by (1)
. . . :: grey // loop contents
end
(item (counter) of [list v] :: list) // use this for inputs

I don't see why we need it, the workaround's pretty easy. Once we get custom loops this would be even easier.
Yes, I know there is an easy workaround, but my reasoning is that for loops exist in some form in basically every language. Why don't they exist in Scratch?

And all the world over, each nation's the same,
They've simply no notion of playing the game.
They argue with umpires, they cheer when they've won,
And they practice beforehand, which ruins the fun!
braxbroscratcher
Scratcher
1000+ posts

Why no for loops?

DaEpikDude wrote:

braxbroscratcher wrote:

set [counter v] to [0]
repeat (length of [list v] :: list)
change [counter v] by (1)
. . . :: grey // loop contents
end
(item (counter) of [list v] :: list) // use this for inputs

I don't see why we need it, the workaround's pretty easy. Once we get custom loops this would be even easier.
Yes, I know there is an easy workaround, but my reasoning is that for loops exist in some form in basically every language. Why don't they exist in Scratch?
For loops are technically our
repeat ()

end
loops as all a for loop does is repeat for X number of times. It's the i (iteration) counter that allows you to act on specific items of lists. Sure, this may be hidden in some languages inside the function, but I don't think the workaround is too hard to do, especially since it lets you understand how for loops work.


My signature is kumquat proof.
But not tangerine pro-
nomnomnomnomnom










Current Project:
n/a
Quotes: “In our last hour, we burn the most brightly, trying to deny that we are burning out.” -Me
“Well, no. 1024 Killerbytes make a Murderbyte.” -MegaByteCorporations
“I hate out of context quotes.” -Me
“I hate it when Cubeupload breaks.” -Also me
Ferociousfeind
Scratcher
100+ posts

Why no for loops?

Full support, though the name “for (item) in (list)” is somewhat unclear and not in Scratch's “it reads like an actually grammatically correct sentence!” like "if <> then“, ”touching ( v)?“, ”ask () and wait“, these all tell you exactly what they do, while ”for (item) in (list)" just doesn't. Perhaps something like

repeat every (item) in [list v] {
. . . :: tips
} :: list

would work better

Beep boop workin' on makin' silly games and nonsense.
Help wanted developing The Legend of Knight (working title) https://scratch.mit.edu/projects/171496233/
-Rex-
Scratcher
500+ posts

Why no for loops?

What about
repeat through [list v] with (var :: control) as each item {
...
} :: control

Last edited by -Rex- (Sept. 7, 2017 01:40:13)

Charles12310
Scratcher
1000+ posts

Why no for loops?

Ferociousfeind wrote:

Full support, though the name “for (item) in (list)” is somewhat unclear and not in Scratch's “it reads like an actually grammatically correct sentence!” like "if <> then“, ”touching ( v)?“, ”ask () and wait“, these all tell you exactly what they do, while ”for (item) in (list)" just doesn't. Perhaps something like

repeat every (item) in [list v] {
. . . :: tips
} :: list

would work better
Other languages use “for every () in ()”.


A few internet communication companies want to corrupt the internet by getting rid of net neutrality. Stop Them!
-Rex-
Scratcher
500+ posts

Why no for loops?

Charles12310 wrote:

Ferociousfeind wrote:

Other languages use “for every () in ()”.
Scratch is meant to be easier to understand than other languages. While a for loop would be nice, the name of the block would have to be changed to something more easily understandable.
DaEpikDude
Scratcher
1000+ posts

Why no for loops?

-Rex- wrote:

What about
repeat through [list v] with (var :: control) as each item {
...
} :: control
I like that wording, yeah. That's good!

And all the world over, each nation's the same,
They've simply no notion of playing the game.
They argue with umpires, they cheer when they've won,
And they practice beforehand, which ruins the fun!
kenny2scratch
Scratcher
500+ posts

Why no for loops?

Meh, I know the feeling…
and yet then there's
set [i v] to [0]
repeat (length of [list v])
change [i v] by (1)
set [var v] to (item (i) of [list v])
...
end

post brought to you by the preview links bug and previously the uploads site bug. 看一下中文 Scratch 維基想參加?請參考這頁
Join the Scratch Wiki!
Made by Scratchers, for Scratchers, since December 6, 2008

TimeLordPlanet
Scratcher
500+ posts

Why no for loops?

Support here! When I was in Python, I was super confused as to what a for loop was due to lack of corresponding Scratch Blocks,

I like Scratch 3.0! An immesurable improvment! Banner coming soon!
Za-Chary
Scratcher
1000+ posts

Why no for loops?

It looks like this is a duplicate topic of this one over here, so I’ll close this thread to keep the conversation all in one place.

Feel free to continue the discussion in the link provided above.

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.

I was a Scratch Team member from May 10th 2019 to October 29th 2021.

my notebook | scratch team essay | accessibility essay

Powered by DjangoBB