Thursday, May 28, 2015

Quick Example

A reader might be curious about the syntax. This is a very short example program.



module my

type AType<S> {
    memref : Ref<S>;             ## default is private
 

    public self( s : Ref<S> ) {  ## constructor
        self.memref = s;
    }

    public getter()->Ref<S> {
   ## Ref<S> can also be written &S
         return self.memref;
    }
}

main()->Int {

    obj := new AType<Int>( 42 );
    ret := obj.getter();
    return ret;
}

Spring Progress Update

How should one spend one's time...

I've focused on implementation since january and have regretfully not posted any progress updates. This is what's been done since then:


  • Symbol table rewrite - DONE
  • Central compiler "driver" routine incl options handling - DONE
  • Modules and import handling - DONE
  • Generic (parameterized) types except for reentrant code generation - DONE
  • Proper integer literal type handling, range checking and conversion - DONE
  • Bool type and boolean expressions - DONE
  • Polymorphism (virtual lookup) for static members - DONE
  • Function objects retaining their closure (e.g. 'self') - DONE
  • Preserve type information in references - DONE
  • 'self' implicit method argument - DONE
  • Virtual methods - DONE
  • 'new' operator and heap allocation - DONE
  • Initializers / constructors - DONE
  • super() constructor invocation; super.method() invocation - DONE


My next todos are:

  • Generic type instance fields support
  • Interfaces
  • Checked type casts (with special if statements)

But before that I need to do an important refactoring. Finding a clean way of modeling the grammar nodes, symbols, fields and types becomes rather difficult when name overloading and generic types are part of the mix. I think I've finally found the proper dimension along which to achieve separation of concern / modularization. (And as so often, in retrospect the solution looks rather trivial.)