All pastes #824663 Raw Edit

Someone

public text v1 · immutable
#824663 ·published 2007-12-20 03:05 UTC
rendered paste body
// call standard.build(), put any exported symbols into the application/module's namespace
// the standard module is as the name suggests, where all the standard symbols live
import standard

meta {
  // name, description, etc
  // can be read by self or other modules, not used for any executable code
  name("Sample");
  description("Basic syntax sample");
  blabla("Arbitary string data field");
  meow(100); // more arbitary data
}

class myclass {
  void myfunction(string bla) {
    print("You passed me " + bla);
  }
}

class myotherclass(myclass) {
  void myfunction(string bla) {
    print("ZOMG! Overriden function!");
  }
  short wonderful_extended_function(short i) {
     // we can extend classes too, like add this function that adds 1 to it's first param
    return i+1;
  }
}

a_global_function() {
   // always implicity void return
   // can be invoked from the command line directly, can have params too, but just not showing them here
}

build() {
  // should we ever want to link this module into a larger library or application we need to export our stuff
  // build() and run() are exported by default
  export_class(myclass);
  export_class(myotherclass);
  export_function(a_global_function);
}

run() {
  // default entry point
  print("Wow, what a lovely program!")
  my_variable = myclass()
  my_variable.myfunction("Bla");
  my_variable = myotherclass()
  my_variable.myfunction("Bla");
  print("Wow, look at this: according to myotherclass 1+1=", my_variable.wonderful_extended_function(1));
}