This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2007-05-22 00:12:35

fandebiao
Scratcher
Registered: 2007-05-15
Posts: 25

Advanced data type

Does Scratch support advanced data type such as array, list, etc?

Offline

 

#2 2007-05-22 15:45:31

dmagee
Scratcher
Registered: 2007-05-17
Posts: 13

Re: Advanced data type

No, but they would be nice.

Offline

 

#3 2007-05-23 11:18:44

tammy
Scratcher
Registered: 2007-03-07
Posts: 57

Re: Advanced data type

Hi fandebiao,

Scratch doesn't yet support advanced data types, though it is something we hope to add in the future.  We'd want to add it in a way that doesn't make getting started with Scratch much harder or more confusing for beginners.  We're still thinking of the most appropriate way to do it.  Do you have any ideas for how you would imagine those data types in Scratch?

Thanks!
-Tammy

Offline

 

#4 2007-05-23 20:18:21

mungojelly
Scratcher
Registered: 2007-05-19
Posts: 35

Re: Advanced data type

What I think is crucial-- and I think you've gotten this mostly right with Scratch-- is that there are important ways in which you can't make something simple just by putting most of it behind an "advanced" tab.  It matters sometimes how simple the system actually is, not just how simple it's pretending to be.

For instance one way it matters is that it affects the people who use it.  Scratch is at a level of complexity that I see as effective on two levels simultaneously: For the young & beginning users, it's at a level of complexity that's easy to get your brain around when you're not already familiar with these tools & concepts.  That's one.  The other is for the older & more experienced people who get involved with the project: The level of complexity that Scratch is at now is a level that an adult who's experienced with computers can get a solid hold of in just a day or two.  That makes anyone who comes here to play around instantly a qualified teacher.

If OTOH Scratch had a bunch of advanced features behind a superficial simplicity, when beginners came to the forums and asked, "how do you do X?", the advanced users would say: "Well that's simple! You set up an array of boolean values..."  Limiting the advanced users to a set of choices that's small enough that everyone understands the options increases the chances of a useful dialog.

Not that I'm weighing in against adding arrays.  I just think any additions should be carefully measured.  In the future I think it might make sense to splinter off an advanced scratch variant, as a decoy to host people's featuritis.  Speaking of which, your code is going to be released sometime?  It's in Squeak?

<3

Offline

 

#5 2007-05-23 21:42:56

fandebiao
Scratcher
Registered: 2007-05-15
Posts: 25

Re: Advanced data type

mungojelly has a point... but I think that kids are smart enough to master array in a couple weeks... I mean, without some advanced features( I'm not sure array is even "advanced", it's kinda necessary), Scratch isn't a real programming language...

And to tammy, I suggest that you put array in the form of a table, like the tables in MS office, on the top left corner is the name of the array, and on top of each cell is an index...

Offline

 

#6 2007-06-01 20:20:48

wjcarpenter
Scratcher
Registered: 2007-05-29
Posts: 5

Re: Advanced data type

Maybe it would be good to implement arrays with the following ideas:

1.  arrays are associative (even though Scratch today only has good numeric variable values, at least you could use a string constant as an index into an associative array)

2.  any variable can act as an array (more precisely, every variable *is* an array with a handy convention for use in a scalar context [see next item])

3.  extend the variable blocks to "set foo to [0] at position [0]", etc, with the convention that the current block without a position implies "at position [0]"

4.  type coercion on the index, so "1" is the same as 1, etc

5.  today, variables (and, hence, arrays) only hold integers; when variables are later extended to allow strings, arrays will get that too

6.  Any variable can be used as a value in a "set" block.  I'd like a way to set the value to be a reference to the variable, but at the moment I can't think of an approachable way to do that.  Anyhow, you could then have an array of arrays to build up arbitrary data structures.

Offline

 

#7 2007-06-01 23:21:44

rivendell
Scratcher
Registered: 2007-05-29
Posts: 24

Re: Advanced data type

There is already a defacto "array" in Scratch:  costumes.  They can be set by number as well as by name.  The "next costume" block wraps around, but the idea is there.  So if they can get that, real arrays shouldn't be much of a jump.

BTW, I would like to be able to read the value of costume, whether numeric or by name (associative), as well as set it.

Offline

 

#8 2007-06-02 00:10:05

Roberth
Scratcher
Registered: 2007-05-15
Posts: 46

Re: Advanced data type

Actually, the idea that a Scratch "array" can "wrap around" may be a good one, in terms of avoiding syntax errors and introducing "random" data that is outside of the array.  In other words, if you have an array of 10 items, the 13th item is just element #3.

While not perfect, and you should still encourage kids to do bounds checking in terms of accuracy, it does solve the problem of keeping it simple and has a certain elegance to it at the same time.  Indeed, I can think right off hand some cool "game" applications that might even take advantage of a self-wrapping array, and it simplifies some other algorithms as well.  And it keeps a Scratch project from crashing if the array is out of bounds.

So far, the only run-time error condition I've seen on Scratch is a division by zero error.  I don't know how to avoid that one if you are going to allow division at all, but that can easily be explained to children who understand the ideas of division at all.  It would be wise to keep it that way as well on all new block suggestions unless there is no possible work-around.

One thing I liked about BASIC arrays is that, by default, they were set with a size of 10 elements.  This is something that was very simple for new BASIC programmers to work with, and didn't require variable declarations.  There was a DIMension statement to establish array sizes if you wanted to get fancy (even with Dartmouth BASIC), and certainly advanced BASIC programs did extensive use of this statement.  IMHO Visual Basic has perverted the DIMension statement of "standard" BASIC beyond recognition and doing things that simply were never a part of the basic simplicity of the original BASIC.

I would also encourage the setting of array element counts to be something that is done dynamically with a block rather than some other more complicated menuing thing in the variable area.  And to make the element count something that can be set to a variable as well.  An example of this elsewhere was with the Applesoft (a variant of the 8-bit Microsoft BASIC) of the Apple ][ computer.  You could "redimension" arrays in the middle of your program (although it was often done only at the beginning), where it would truncate elements if the count became smaller, and added pre-initialized elements set to zero if you enlarged an array.  That was also an interpreted environment similar to Scratch in a small way.  The original Dartmouth BASIC threw a run-time error condition (or a compiler error) if you tried this idea, and there were other things that happened in other dialects of BASIC, although a run/compile error was very common.

Again, all of this is to define the behavior of this concept that would keep it simple enough for kids to use without having to learn all of the background theory about how  it actually works.

Offline

 

Board footer