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

#1 2007-05-16 00:38:46

Chupi
Scratcher
Registered: 2007-05-16
Posts: 4

Recursion

It would be nice to be able to implement some form of recursion.  The most obvious is to use broadcasts as procedure calls, but broadcast-and-wait doesn't remember more than one level of the same signal.

I'd like to request broadcasts that work more like a call stack in a future version.

-Thanks

Offline

 

#2 2007-05-16 08:32:13

johnm
Scratcher
Registered: 2007-03-08
Posts: 100+

Re: Recursion

Hi.

We're considering adding recursion in a future version. It was left out of this version very intentionally, as it has potential to be confusing. But for more advanced projects, such as your Mandelbrot project, it would be nice to have.

  -- John

Offline

 

#3 2007-05-16 16:05:16

Canthiar
Scratcher
Registered: 2007-05-16
Posts: 100+

Re: Recursion

Whoa, my first response was to do a mandelbrot program, as well, though I think you did a much better job.  My second response was to do a raytracer, but I saw that there was no recursive capability.  I think it might be possible to fake recursion by doing multiple copies of the same script and naming the script based on the recursion level.

Offline

 

#4 2007-05-16 23:32:52

gamerfreak
Scratcher
Registered: 2007-05-15
Posts: 7

Re: Recursion

johnm wrote:

Hi.

We're considering adding recursion in a future version. It was left out of this version very intentionally, as it has potential to be confusing. But for more advanced projects, such as your Mandelbrot project, it would be nice to have.

  -- John

It may be a good idea to have two separate "modes" that you can select on startup. A basic mode, for beginners and an advanced mode so that scratch could be more useful to more advanced programmers. Having these two modes would allow for you to implement the more advanced ideas that have been bounced around, all while maintaining the simplicity that scratch thrives on.

Last edited by gamerfreak (2007-05-16 23:35:59)

Offline

 

#5 2007-05-19 10:08:01

jldugger
Scratcher
Registered: 2007-05-19
Posts: 5

Re: Recursion

Seperate modes can be hard to find. I'd suggest just sorting tools by relative difficulty if you feel a certain set of features are too confusing.  I don't know if standard F-scan reading patterns apply to the squeak environment, but I'd wager at the very least scroll bars are a semi "advanced" concept. And lets face it, there's plenty of more advanced systems out there besides Scratch. 

But I'd definately like some functions around. I donno exactly how well it would work within Scratches "programs as tangible objects" design. Perhaps a message - reply system?

Offline

 

#6 2007-05-20 00:49:35

kevin_karplus
Scratcher
Registered: 2007-04-27
Posts: 1000+

Re: Recursion

There are two different requests here:
    procedures that encapsulate a chunk of code and take parameters
    functions that return a value.

Both can be easily incorporated into the scratch metaphor by allowing users to create their own blocks (whose shape and color determine whether or not they return a value).

Note: I said it was easy to incorporate into the metaphor, not that it was easy to implement!

Offline

 

#7 2007-05-20 03:46:34

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

Re: Recursion

I agree, and I've had that same feeling; it's very easy to slip some sort of modularity into this metaphor.  You've got these chunky pieces, and you put them together into bigger chunks... shouldn't I just be able to drag those over to the left hand side, and have them shrink into new reusable magic blocks?!?  wink   But implementing it would be a trick!

<3

Offline

 

#8 2007-05-20 14:29:24

johnm
Scratcher
Registered: 2007-03-08
Posts: 100+

Re: Recursion

Hi, all.

Thanks for the great ideas and thinking about this. We are considering adding a "define your own block" mechanism like what Kevin and MungoJelly describe.

Procedure abstraction, parameterization, functions, and recursion are all powerful mathematical ideas that were fundamental to Logo. It would be great to work them into Scratch in a natural way that does not make it more difficult for a beginner to learn Scratch. I agree with you guys that it should be possible do that; it's just the details that are tricky.

  -- John

Offline

 

Board footer