Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
Re: Where can I find eval rules for ruby?
Phlip
8/15/2007 6:20:00 PM
Daryoush Mehrtash wrote:
> I am trying to understand Domain Specific Language implementation in Ruby,
> there are lot of examples such as
>
http://www.infoq.com/articles/eval-optio...
, but I can't find a
> definitive guide on the interpreters rule for evaluating a line of DSL
> String in instance_eval call.
DSL is a state of mind, not a language inside a string inside a language.
The state of mind is that you intend to write in one language style,
inside another language. For example, Rake is a _light_ form of rule
solver, so you can write it in a format paralleling a Makefile:
task :rule_1 => [:rule_2, :rule_C] do
evaluate_rule_1
end
To write in a declarative mode, write object methods with store their
commands in an engine, and then process the engine. Here's a little
Flea script to draw a spiral:
egg = startOvum(18, 45, 100)
ax = egg.newRootAxiom('A')
b = egg.newAxiom('B')
ax.longer(6).right.color(1).gosub(b)
b.tube.shorter(0.8).left.link(b)
render egg
The commands like longer, right, color, etc are turtle graphics
describing a shape. render then outputs the shape.
All the ActiveRecord association commands - has_many, belongs_to, etc
- qualify as DSLs too. The goal is to give your user-programmer a
clear but deep interface, so they can write the command they need, in
the relevant context they need, and the engine on the inside hides the
complexity.
--
Phlip
http://www.oreilly.com/catalog/9780...
^ assert_xpath
http://tinyurl....
<-- assert_latest Model
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Re: Where can I find eval rules for ruby?
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password