View Single Post
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