Angel \”Java\” Lopez on Blog

December 26, 2009

AjSharp: Dynamic classes and objects

Filed under: .NET, AjSharp, Programming Languages — ajlopez @ 11:15 am

I’m writing a C#-like not-typed interpreter, named AjSharp. I wrote about the open source project at:

AjSharp Programming Language a C#-like Dynamic Language

You can download the current version from at trunk/AjLanguage

Today, I added a new feature, defining an object. AjSharp supports the definition of a dynamic class:

class Person
  var Name;
  var Age;
  function AddYears(years) 
    this.Age = this.Age + years;

and then, you can create a new object using:

adam = new Person();
adam.Name = "Adam";

Notably, the object is a dynamic one: you can add instance variables and methods, at any moment:

adam.LastName = "unknown";
adam.EyeColor = "brown";
adam.SayHello = function() { PrintLine("Hello"); };

You can create objects, setting it’s state:

adam = new Person() { FirstName = “Adam”, LastName = “Genesis”, Age = 800 };

The object can have no associated class:

dynobj = new { Name = “Adam”, Age = 800 };

You can define a dynamic object, more “programmatically”:

dynobj = new DynamicObject();
dynobj.FirstName = “Adam”;
dynobj.LastName = "Genesis”;
dynobj.Age = 800;
dynobj.FullName = function() { return FirstName + “ “ + LastName; }

Today, I added a new notation, create an object using:

object Adam
  var Name = "Adam";
  var Age = 700;
  function AddYears(years) 
    this.Age = this.Age + years;

Don’t forget you can create and use native .NET objects

ds = new System.Data.DataSet();
dinfo = new System.IO.DirectoryInfo(“.”);
foreach (fi in dinfo.GetFiles())

I should think about how to add and implement:

  • Inheritance in DynamicClasses
  • Public and Private members
  • prototype in DynamicClasses, something like Person.prototype.Age = 800;

I want to add support to something like “channels”, “ports”:

port1 -> DoSomething(value);
port1 -> DoAnotherThing(value);
port1 <- value1;
port1 <- value2;

That is: when port1 receives a value (with <-) that operation triggers commands IN PARALLEL using the new received value. In this way, I could explore reactive programming ideas.

And I want to add something like agents, actors, and shared transactional memory, see:

Hmmmm… I could rewrite Distributed Agents using DSS/VPL or  Genetic Algorithms with AjAgents and Concurrency and Coordination Runtime (CCR)

Keep tuned!

Angel “Java” Lopez


  1. […] AjSharp: Dynamic Classes and Objects […]

    Pingback by Working on AjObjects: in-memory document/Dynamic object Base « Angel “Java” Lopez on Blog — March 1, 2010 @ 11:00 am

  2. […] AjSharp: Dynamic Classes and Objects AjSharp: Clases y Objectos Dinámicos AjSharp posts AjSharp posts en español […]

    Pingback by Trabajando en AjObjects: objectos dinámicos/documentos en memoria - Angel "Java" Lopez — March 8, 2010 @ 10:09 am

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at

%d bloggers like this: