The RR programming model
Mat Korica
mkorica at ica.net
Fri Nov 15 13:37:22 EST 2002
>Going back to the original question about the programming model, I tend
>to think of Rev as an object oriented language with preset objects. To
>talk in C++ speak for a moment, you can instantiate a button, give it
>data (name, size, color, custom properties etc), and give it methods
>(mouseUp, mouseDown, doMyStuff). Purists would probably say that it
While it's easy to create an interface using Revolution's built-in objects,
the big weakness is that you can't make your own custom objects. I actually
was impressed enough with Revolution to implement this myself using
Transcript.
I decided that stacks/cards can represent classes/objects. Class methods are
functions stored in the script of a stack while stack and card custom
properties store the object and class attributes. I implemented inheritance
by giving classes a custom property that indicates their parent "stack". I
also provided object aggregation in a similar way.
The end result was that I could use the following syntax:
show age of Student of School "James Culnan"
...where "Student" and "School" are individual stacks, "James Culnan" is a
card in the "School" stack, "age" is a custom property on cards in the
"Student" stack, and "show" is a function in the stack "Class" that
"Student" inherits from. Also, the "School" stack acts as a container for
"Student". ("Student" really means "Students" in this context).
This actually works reasonably well, but the code I wrote is kind of
cumbersome. I also recently tried RealBASIC and realized that this type of
workaround is unnecessary there.
Cheers,
Mat
More information about the use-livecode
mailing list