Discuss Scratch
- Discussion Forums
- » Questions about Scratch
- » Is Scratch statically or dynamically typed?
- Stegie1234
-
Scratcher
100+ posts
Is Scratch statically or dynamically typed?
Scratch variables can’t change to lists while the project is running, does that mean Scratch is statically typed? Or dynamically typed, since the variables can be a string, int, or float at any time?
Last edited by Stegie1234 (Sept. 18, 2023 23:33:49)
- Clippy-Cat
-
Scratcher
66 posts
Is Scratch statically or dynamically typed?
Scratch is dynamically typed. Although it does have some strict-ish elements, this does not make it strictly typed.
In fact, Scratch is more dynamically typed than most other dynamically typed languages, as there's no difference between a number and a string within Scratch's internal logic.
In fact, Scratch is more dynamically typed than most other dynamically typed languages, as there's no difference between a number and a string within Scratch's internal logic.
Last edited by Clippy-Cat (Sept. 19, 2023 01:09:06)
- DifferentDance8
-
Scratcher
1000+ posts
Is Scratch statically or dynamically typed?
A little bit of both.
- donotforgetmycode
-
Scratcher
1000+ posts
Is Scratch statically or dynamically typed?
Scratch is dynamically typed. The reason variables can't change to lists is because lists aren't a data type in Scratch.
- EngineerRunner
-
Scratcher
1000+ posts
Is Scratch statically or dynamically typed?
dynamically. hell, you can do this:
if (item <(apple) = (other list::list)> of [list v]) then
say <not(item (3) of [other other list v]::list)>
end
Last edited by EngineerRunner (Sept. 20, 2023 15:48:16)
- ajskateboarder
-
Scratcher
1000+ posts
Is Scratch statically or dynamically typed?
It's neither; it has no type system so you can't validate data or check the type of a variable
You'll need to check for things that make a certain type manually
You'll need to check for things that make a certain type manually
- donotforgetmycode
-
Scratcher
1000+ posts
Is Scratch statically or dynamically typed?
It's neither; it has no type system so you can't validate data or check the type of a variableIt actually does have a type system.
You'll need to check for things that make a certain type manually
- ajskateboarder
-
Scratcher
1000+ posts
Is Scratch statically or dynamically typed?
Example?It's neither; it has no type system so you can't validate data or check the type of a variableIt actually does have a type system.
You'll need to check for things that make a certain type manually
- CST1229
-
Scratcher
1000+ posts
Is Scratch statically or dynamically typed?
(#8)Number-type values get slightly visually rounded in variable monitors (but strings don't). However, most blocks cast values to a certain type so they all behave the same in most other cases.
Example?

(EDIT: It's not caused by floating-point inaccuracies, as if you put it in a join block it stays precise:)

Last edited by CST1229 (Sept. 20, 2023 19:45:37)
- donotforgetmycode
-
Scratcher
1000+ posts
Is Scratch statically or dynamically typed?
Example?Make a sprite with 2 costumes. The first costume should be called something like “costume1” and the second costume should be called “1”. Now run these two blocks:
switch costume to (join [1] [])
switch costume to ((1) + ())
- Stegie1234
-
Scratcher
100+ posts
Is Scratch statically or dynamically typed?
lists aren't a data type in Scratch.What? Arrays aren’t a data type the variables can be, but they still exist in Scratch.
It's neither; it has no type system so you can't validate data or check the type of a variableHow do you know it doesn’t have a type system? It could have types, but you can’t check the type of a variable because
<[] = []>is ==, not ===, in JavaScript.
dynamically. hell, you can do this:1. You can do that in most statically typed languages.if (item <(apple) = (other list::list)> of [list v]) then
say <not(item (3) of [other other list v]::list)>
end
2. Scratch doesn’t allow variables or list items to be in an if statement.
Edit: list items can be used a booleans.
Last edited by Stegie1234 (Sept. 21, 2023 05:48:37)
- ajskateboarder
-
Scratcher
1000+ posts
Is Scratch statically or dynamically typed?
So it doesn't have a type systemlists aren't a data type in Scratch.What? Arrays aren’t a data type the variables can be, but they still exist in Scratch.It's neither; it has no type system so you can't validate data or check the type of a variableHow do you know it doesn’t have a type system? It could have types, but you can’t check the type of a variable because<[] = []>is ==, not ===, in JavaScript.
Also IDK I don't think most other dynamic langs let you do this

- donotforgetmycode
-
Scratcher
1000+ posts
Is Scratch statically or dynamically typed?
So it doesn't have a type systemYes it does, see my post above.
- ajskateboarder
-
Scratcher
1000+ posts
Is Scratch statically or dynamically typed?
Yeah I saw that, but in the sense of a traditional type system:So it doesn't have a type systemYes it does, see my post above.

It doesn't have one, by definition. Implicit type casting doesn't really make a type system, it has to have a proper distinction
- Discussion Forums
- » Questions about Scratch
-
» Is Scratch statically or dynamically typed?
