[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Aikido language




On 4 Feb 2004, at 19:51, Michael St. Hippolyte wrote:

> David Allison wrote:
>> Some "unique" aspects:
>> * block extension (the ability to add code/data to existing 
>> functions, classes, etc)
>
> How is this different from standard implementation inheritance, where
> you add code or data to a class by subclassing it?

Hi Michael,

It's different because you don't have to create a new block to extend
an existing one.  Consider the scenario of a class called String that
implements a string of characters.  There are many things that
you can do with strings and it is unlikely that the designer of the
String class can provide them all.

Block extension allows a program to add things to the String class
for the duration of the program.  For example, if the String class
didn't provide a function to convert to upper case, the programmer has 3
choices:

1. edit the source code for the String class
2. Derive a new type MyString from String.
3. Extend String by adding the functions he needs.

Case 1 is probably not possible.  Case 2 means that all instances
of String have to be converted to MyString.  Case 3 means that existing
code that uses String will still work, but will not know about the
new functions.

Consider:

// in a library somewhere
class String {
   // methods
}

// in your code

extend String {
     public function toUpperCase() {
         // convert the string to upper case
     }
}

You can also extend functions, threads, enumerations, etc. (any "block")


>
>> * function inheritance (the ability to inherit functions from 
>> functions)
>
> If I understand what you mean by this, Bento (see 
> http://www.bentodev.org)
> has this.
>

Function inheritance (or more generally, block inheritance) is the same 
as
class inheritance.  A function is very similar to a class in Aikido.  
Let me explain.

A function is just an instance of an object that is created when it is 
called, with
its memory on the stack.  It lives for a while then it dies and is 
destructed when
it returns.  This similarity means that you can treat classes and 
functions as
synonymous in certain circumstances.  Generally, block inheritance 
allows
you to inherit any block from any other block - a class from a 
function, or function
from function.  I can't think of a good reason to do some of the 
combinations, but they
are possible.

I wasn't able to glean much from the Bento web site (from my quick 
viewing of it)
so I don't know if it's exactly the same or not.

Sorry for the long answer.  I like talking about Aikido :-)

Dave


> Michael St. Hippolyte
>