lua-users home
lua-l archive

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


Hello,

The preface to "Programming in Lua" states that "many people regard Lua not as a language, but as a kit for building domain-specific languages". Fair enough, but what does that mean in practice? What usage of Lua qualifies as "domain specific language"? Does anyone have a concrete example of using Lua for such purpose?

Suspending disbelieve for an instant, one could imagine the DSL realm as something like "data definition language" or perhaps its hillbilly cousin: object-relational mapping.

Bellow are a couple of syntactical example broadly dealing with the same issue of "data definition" and/or "mapping":


Oracle's SQL:

create table orders (
  order_id number,
  order_dt date,
  cust_id  references customer
  constraint pk_orders (order_id)
)


Smalltalk's GLORP:

Joinfrom: (myTable fieldNamed: 'ADMIN_ID') to: (userTable fieldNamed: 'ID'))


Lisp's CLSQL:

(manager :accessor employee-manager :db-kind :join :db-info (:join-class employee :home-key managerid :foreign-key emplid :set nil))


Perl's Class::DBI:

Music::CD->has_a(artist => 'Music::Artist');


Python's SQLObject 2:

class Foo(SQLObject):
    other = Reference('Other', 'other_id')


Ruby's RoR:

class Project < ActiveRecord::Base
    belongs_to              :portfolio
    has_one                 :project_manager
    has_many                :milestones
    has_and_belongs_to_many :categories
end


Is any of the above an illustration of "domain specific language"?

What would be a "domain specific language" way to convey such information in Lua?

Does this qualify as "data manipulation language"?

local aStatement = function()
        Select()
        From( Employee )
        Where( Eq( name, "Vladimir" ), Eq( city, "Moskva" ) )
        Order( By( name ) )
end

Could this be a "data definition language"?

local aModel = function()
    Is( Employee, hr.v_employee )
    Has( name, string )
    HasOne( manager, Manager )
    HasMany( colleagues, Employee )
end

Confused :/

Cheers

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