AjSharp: Dynamic classes and objects

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 http://code.google.com/p/ajcodekatas 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



2 thoughts on “AjSharp: Dynamic classes and objects

  1. Pingback: Working on AjObjects: in-memory document/Dynamic object Base « Angel “Java” Lopez on Blog

  2. Pingback: Trabajando en AjObjects: objectos dinámicos/documentos en memoria - Angel "Java" Lopez

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Connecting to %s