Alice Community  

Go Back   Alice Community > Alice 2 > Suggestion Box

Thread Tools Display Modes
List Handling
Posts: n/a
Default List Handling - 11-18-2006, 06:27 PM

Last Thursday, when one of the kids in my Alice class at Friends of the Children in Seattle asked if they could make their five penguins do the same thing as easily as one, I told them I would look into it and let them know at the next class. I didn't find what I expected. It turns out that the feasibility of controlling multiple objects in one stroke varies between clunky and impossible. What I expected seems preferable to what exists in Alice at the moment. I urge you to consider including something like what I describe here in a future version of Alice.

What I imagined as a user experience was that as soon as the user drags more than one instance of a given object into their world, either by dragging from the library or using the gallery's copy tool, Alice would automatically create a parent object for those multiple instances. For instance, the first penguin you added to your world would be a child of the world object, but as soon as you added another penguin to your world, a container object named Penguins would appear under the world object, and the existing Penguin and the new Penguin2 would be moved to be children of the Penguins object. To make all the Penguins do the same thing, the easiest way would be to drag the Penguins object from the object tree into the empty body of my first method, select wing_flap from the pop-up menu, then 2 for the number of times to flap, and hit Play.

To make all that work a number of new features would be required. Here is what I suggest:

First, when creating a list property, the user should be able to assign the type of the list to be a specific object type, such as Penguin, not just any object. Without the list having a specific type, as it is now, Alice can only expose the properties, methods, and functions that all objects share, and we can"t see the wing_flap method that is private to Penguin.

Second, all objects would come with a child_list property that, in the example of the Penguins container object, an element of which would be of type Penguin, would contain a list of the Penguin objects under the Penguins container object.

The longer form of the example would be to first drag a For All into the code panel, then click on expressions then world.Penguins.child_list in the pop-up menu. This is itself a shortcut for clicking the Penguins object in the object tree, clicking on the properties tab in the details area, then dragging the child_list property tile from the details area onto the For All's list field.

The short form of the original example requires another control construct I'll call Pick that is similar to a function in that it acts syntactically like it returns a value, and is also similar to a For All in the sense that it takes a list as its argument and the expression to the right is evaulated as many times as there are elements in the list.

By the way, I think that sequential versus synchronous ought to be a more option like duration, instead of cluttering up the control tile space at the bottom of the screen.

To go the next step and make use of parent objects that have a heterogeneous set of child types, you need a couple more features:

First you need the type of a variable to be able to be a list of types, not just a single type.

Second, you need a case statement to be able to map the type-safe casting of a composite type to blocks of code to handle each of the distinct types in the composite type list.

For example, the child_list of a Penguin would be of list of three types: head, leg, and wing. Inside a For All to consume the child_list of a Penguin, you might have a select/case statment that turns a head, kicks a leg, and flaps a wing.

With one or two other assembly tools, such as being able to drag new objects from the gallery and being able to drop them anywhere in the object tree, rather than only under the world, and rearrange the object tree at will using drag and drop, then save their new creation in the gallery, you would open up the ability for users to create new composite types from small component pieces, a middle ground between what we have now in Alice 2.0 and the more heavy-handed option of adding a 3D modeling program into Alice, which I hesistate to recommend.
Reply With Quote
Posts: n/a
Default 11-25-2006, 05:27 PM

Are you asking for an Iterator object for a List Class in Alice ? I may be offbase but I thought the For All control tile did that, contained within a Do together statement.

The For All In Order allows for sequential processing through a list. If you wish to process All of the list simultaneously then use the For all together construct. (all items in your list will perform the same action at the same time.)

NOTE: The Rockettes perform their actions using a List collection by iterating throught the List sequentially.

Sorry if I misunderstood.

Last edited by lanceA; 11-25-2006 at 05:44 PM. Reason: providing additional info.....
Reply With Quote

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Copyright ©2022, Carnegie Mellon University
Alice 2.x © 1999-2012, Alice 3.x © 2008-2012, Carnegie Mellon University. All rights reserved.