The Artima Developer Community
Sponsored Link

Weblogs Forum
New HeronFront with Classes and Delegations

1 reply on 1 page. Most recent reply: Jan 24, 2006 11:52 PM by Christopher Diggins

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
Christopher Diggins

Posts: 1215
Nickname: cdiggins
Registered: Feb, 2004

New HeronFront with Classes and Delegations (View in Weblogs)
Posted: Jan 24, 2006 9:54 AM
Reply to this message Reply
Summary
I've just uploaded the latest Heron version which now supports classes, structs and delegations
Advertisement
In the previous version of HeronFront a class would have to be written in C++, and the interface (previously a "trait") would have to be written in Heron. Well that was kind of confusing to say the least, so I finally managed to get the HeronFront translator to handle classes. A Heron class looks more or less like a class in C++/Scala/Python:
class string 
{
  delegates
  {
    Stack[char] : f;
  }
  fields 
  {
    stack[char] f;  
  }
  public 
  {
    def _init(cstring x) {
      while (x != NULL) {
        push(*x++);
      };
    }    
    def _eq(self& x) : self& {
      clear();
      _plus_eq(x);
      return *this;
    }
    def _plus_eq(self& x) : self& {
      uint i=0;
      while (i < x.count()) {
        push(x[i]);
      };
      return *this;
    }
    def _plus(self& x) : self {
      return *this += x;      
    }
  }     
}
In a class all fields are private, while in a struct all fields are public. This is intended to assure that the interface of a class is only made up of functions. This may lead to other features in the future, like the ability to ellicit an interface from a class.

The _eq, _plus, and _plus_eq functions are operator overloads. The _init function is the constructor. There are a few extra neccessary semicolons (why they are needed is a very long story related to the future ability to pass code-blocks to macros).

The delegation specification automatically generates functions which forward an interface's required functions to a member field.

The latest version of HeronFront is very unstable, but I posted it to http://www.heron-language.com/downloads.html for anyone who might be using the HeronFront / YARD code base for their own work.

For the time being I have to figure out why my vlist-based string class is so much slower than the GCC standard library implementation of a string!


Christopher Diggins

Posts: 1215
Nickname: cdiggins
Registered: Feb, 2004

Re: New HeronFront with Classes and Delegations Posted: Jan 24, 2006 11:52 PM
Reply to this message Reply
> For the time being I have to figure out why my vlist-based
> string class is so much slower than the GCC standard
> library implementation of a string!

In turns out I was comparing different compilers! The speed is essentially the same, but the lines of code is a fraction of the size.

I plugged HeronFront into my C++ IDE (Dev-C++ which is for available for free at http://www.bloodshed.net/ ) and it works really well.

Anyway things are starting to roll finally, look out below!

Flat View: This topic has 1 reply on 1 page
Topic: Desktop Linux Just Died Previous Topic   Next Topic Topic: Generics and Packages


Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2014 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us