[antlr-interest] Agglutinative language

James Carroll jamesdcarrollml at verizon.net
Fri Jan 22 07:20:48 PST 2010


I'm only starting with ANTLR and thinking about 'language' for its own
sake and was wondering.... are there any agglutinative programming
languages? 

The Decorator pattern would seem to lend itself to it. From wikipedia
(javascript example):
function Coffee() {this.cost = function(){return 1;};
} 
// Decorator A
function Milk(coffee) {this.cost = function() {return coffee.cost() + 0.5;};	
}
// Decorator B
function Whip(coffee) {this.cost = function() {return coffee.cost() + 0.7;};
}
 
// Decorator C
function Sprinkles(coffee) {this.cost = function() {return coffee.cost() + 0.2;};
}
var coffee = new Coffee();
coffee = new Sprinkles(coffee);
coffee = new Whip(coffee);
coffee = new Milk(coffee);

But what if I wanted to do this:

entity Coffee() {this.cost = function(){return 1;};
}
entity Espresso() is Coffee {this.cost = function(){return 1.5;}
// Decorator A
feature Milked(coffee) {this.cost = function() {return coffee.cost() + 0.5;};	
}
// Decorator B
feature Whipped(coffee) {this.cost = function() {return coffee.cost() + 0.7;};
}
 
// Decorator C
feature Sprinkled(coffee) {this.cost = function() {return coffee.cost() + 0.2;};
}
var coffee1 = new Coffee();
var coffee2 = new WhippedCoffee();
var coffee3 = new SprinkledMilkedCoffee();
var coffee4 = new SprinkledEspresso();

Just curious.





More information about the antlr-interest mailing list