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

Re: Aikido language



Hi David,

> Consider:
>
> // in a library somewhere
> class String {
>   // methods
> }
>
> // in your code
>
> extend String {
>     public function toUpperCase() {
>         // convert the string to upper case
>     }
> }

In Nice (http://nice.sourceforge.net):

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

// in your code
String toUpperCase(String input) {
    // convert to upper case
}

This may look like a function, but it really is a method - you can 
specialize it for subclasses, you can use "regular" method syntax:

"hello".toUpperCase();
 
and so on.

> 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.

Can you give some examples of why you'd want to inherit from a function?

Bryn