lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]



On Mar 10, 2006, at 01:19, Thomas Wrensch wrote:

I've also used Lua to build a very-high level modeling language for object-oriented systems. This was a more traditional DSL for designers of object-oriented software systems. Rather than using Lua's syntax directly it implements a language parser in Lua.

I was wondering if you could provide some example of your modeling language?

How does it compare, relate to something like UML Object Constraint Language (OCL)?

Perhaps a topical example could be related to object relationships :)

For example, while not full fledged modeling languages, O/RM tools try to emulate them to a certain extends:

[Ruby on Rails]
http://www.loudthinking.com/arc/000297.html

class Book < ActiveRecord::Base
  belongs_to :publisher
  has_and_belongs_to_many :authors
end

class Publisher < ActiveRecord::Base
  has_many :books
end

class Author < ActiveRecord::Base
  has_and_belongs_to_many :books
end

[SQLObject]
http://blog.ianbicking.org/another-less-sleepy-alternative-to- hibernate.html

class Book(SQLObject):
    publisher = ForeignKey('Publisher')
    authors = RelatedJoin('Author')

class Publisher(SQLObject):
    books = MultipleJoin('Book')

class Author(SQLObject):
    books = RelatedJoin('Book')

[dejavu]
http://projects.amor.org/docs/dejavu/intro.html

Book.many_to_one('publisher', Publisher, 'ID')
Authorship.many_to_one('bookID', Book, 'ID')
Authorship.many_to_one('authorID', Author, 'ID')

[DBModel.lua]
http://dev.alt.textdrive.com/browser/DB/TestModel.lua

function()
        Is( Author )
        HasMany( books )
end

function()
        Is( Book )
        HasOne( publisher )
        HasMany( authors )
end

function()
        Is( Publisher )
        HasMany( books )
end

Cheers

--
PA, Onnay Equitursay
http://alt.textdrive.com/