New release out in online

struct Hello {
  String who;
  Void setWho(String who) {
    this.who = who;
  }
  Void print() {
    printLine("Hello " + this.who);
  }
};

Hello h;
h.setWho("World!");
h.print();

RE: New release out in online

How about that!

Great stuff

Av: Pär Pettersson 8. feb 2017

RE: New release out in online

I like it :)

Av: Simen Mostuen Iversen 8. feb 2017

RE: New release out in online

Drool

Av: Hans Wilhelmsen 8. feb 2017

RE: New release out in online

Oh joy! Love it! This is EXTREMELY useful! Finally it's easy to add business objects that can ensure validation before saving to database!

Since it doesn't seem like structs can have a constructor, here is a workaround for that:

#setLanguageLevel 3;

struct Car
{
  String Type;
  Integer YearModel;
  String ErrorMessage;
  
  //Attempt to save the car object to database. 
  //If object is not in a valid state to be saved then False is returned, and ErrorMessage set.
  Bool save()
  {
    if (this.YearModel < 1942)
    {
      this.ErrorMessage = "Car is too old";
      return false;
    }
    
    //...
    return true;
  }
  
  String getFullName()
  {
    return this.Type + " ( " + this.YearModel.toString() + ")";
  }
};

//A method that behaves like a constructor for the Car class.
Car Car(String name, Integer year)
{
  Car c;
  c.Type = name;
  c.YearModel = year;
  return c;
}

Car c = Car("Jaguar XJ220", 1893);
if (!c.save())
  printLine("ERROR: " + c.ErrorMessage);
else
  printLine(c.getFullName());

 

What about public/private access modifiers? Is that possible to add? Alternatively, could we fake up "private" properties by letting the variable start with underscore, that would only make it possible to use this variables when prefixed with "this." ? 

And would it be possible to add static methods? What about namespaces? Enums!! 

Love what you're doing to the language, this warms our hearts :)

Av: Frode Lillerud 8. feb 2017

RE: New release out in online

I like your code snippet, Frode - I'd like to try it out as well.

I had to smile when reading your second requests :p It seems like you want an open source scripting application

Av: Simen Mostuen Iversen 8. feb 2017

RE: New release out in online

Thank you - we appreciate your enthusiasm! :) We have more ideas in the pipeline, like the constructor stuff that Frode suggests, or perhaps private/public members. Not promising anything though. But I hope we will be able to deliver some more candy down the road.

Sverre

Av: Sverre Hjelm 9. feb 2017