Alice Community  

Go Back   Alice Community > Alice 2 > Suggestion Box

Reply
 
Thread Tools Display Modes
fireworks and fuses
Old
mikka
Guest
 
Status:
Posts: n/a
Default fireworks and fuses - 05-19-2007, 06:16 AM

Compared to usual object-oriented languages, there are some simplifications in Alice that pose certain restrictions on the expressiveness of the language.

One restriction is, that arguments of methods can only be of simple type, not objects.

There are some simple mechanisms, to extend the expressiveness while keeping the language simple and safe.

The concept of “delegates” (found in C# and Delphi) allows to connect objects indirectly on the event level.
Delegate objects combine one receiver object and one of its methods.
The delegate (type) declares the signature (argument list) of the method.

An object S can declare a variable as a (“multi-cast”) “event” for a delegate type D.
A single event variable can hold an arbitrary number of delegate objects.
The language provides basic operations to add or remove a delegate object to / from the event variable.

Object S can trigger the event by calling the event variable with the required arguments. This has the effect that all the delegate objects that are in the event variable are executed, i.e. the method is called on the receiver object with the arguments of the event call.

[The notion “delegate” is not very meaningful for kids, because it is kind-of tech-speak. A word with could be used to describe the mechanism with an impressive picture would be “bomb” (or “firework”). The event variable could then be called the “trigger” (or “fuse”).]

What do you think? Would some "firework" bring more power and excitement to Alice programming?
   
Reply With Quote
Old
DickBaldwin
Guest
 
Status:
Posts: n/a
Default 05-19-2007, 11:18 AM

You wrote:

"Compared to usual object-oriented languages, there are some simplifications in Alice that pose certain restrictions on the expressiveness of the language.

One restriction is, that arguments of methods can only be of simple type, not objects."

====================

The second statement above is incorrect. You can pass parameters as type Object as well as about a dozen other abstract types to methods.

The restriction is that when you pass a parameter as type Object, you cannot cast the parameter to a subclass of the type Object in order to gain access to methods, functions, and properties belonging to a subclass.

Dick Baldwin

Last edited by DickBaldwin; 05-19-2007 at 11:29 AM. Reason: Correct spelling
   
Reply With Quote
Old
DrJim
Guest
 
Status:
Posts: n/a
Default 05-19-2007, 07:50 PM

Won’t try to get into a discussion of “objects,” “classes” etc. in Alice vs. the “ususal” object oriented languages – will leave the “fireworks” to others.

I will note that you can effectively pass a sub-object with a method call – it has to be passed as a combination of an object name and a string as per the attached and the method has to use the “<object>’s part named <string>” function block (see attached).

This does appear to be a fairly robust approach - as long as the full name for the part exists, there seems to be no restriction on what object or sub-object “owns” the method. It can also be quite useful, although the lack of restrictions and the multiple naming conventions used for objects in the Alice Gallery can make using it a bit tricy.

(An earlier set of e-mails discussed the “<object>’s variable named <variable name>” block which seems similar. However, to me at least, that construct is not particularly useful. I'd like to know if anyone else has figured out an effective way to use that. )
Attached Files
File Type: a2w Flap.a2w (544.5 KB, 747 views)
   
Reply With Quote
Reply

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 ©2024, Carnegie Mellon University
Alice 2.x © 1999-2012, Alice 3.x © 2008-2012, Carnegie Mellon University. All rights reserved.