• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content

Loading…

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

Like this presentation? Why not share!

DSLs in Ruby through metaprogramming

on

  • 1,879 views

Using metaprogramming facilities in Ruby to build DSLs.

Using metaprogramming facilities in Ruby to build DSLs.

Statistics

Views

Total Views
1,879
Views on SlideShare
1,788
Embed Views
91

Actions

Likes
5
Downloads
37
Comments
0

3 Embeds 91

http://francescoagati.wordpress.com 89
url_unknown 1
https://francescoagati.wordpress.com 1

Accessibility

Categories

Upload Details

Uploaded via as Apple Keynote

Usage Rights

CC Attribution-NonCommercial LicenseCC Attribution-NonCommercial License

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />

DSLs in Ruby through metaprogramming DSLs in Ruby through metaprogramming Presentation Transcript

  • DSL-uri in Ruby prin metaprogramming
  • DSL • Domain Specific Language • subroutine (Assembler) • procedure (Fortran, Pascal, C) • objects, messages (C++, Java) • DSLs (Lisp, Smalltalk, Ruby)
  • Classes vs Objects • Object Oriented programming • Ruby object model • Class => objects • metaclass?
  • Objects State + Behavior => Object
  • State + Behavior @name: “Fred” fred say_name() attack(player)
  • Methods @name: “Fred” Monster fred say_name() method table attack(player)
  • Calling methods @name: “Fred” Monster fred say_name() class attack(player) fred.say_name()
  • self • current object • default receiver • @ivar
  • Metaprogramming Changing self
  • Changing self • self = blah • object.method • class • Module#class_eval • Object#instance_eval
  • object.method(param) • self <= object • look up method in self.class • invoke method
  • value: “fred” String monster capitalize() class
  • Inheritance Object super: class: frozen?() value: “fred” String super: monster class: class capitalize()
  • Object super: class: frozen?() String super: class: capitalize() anonymous super: value: “fred” class: monster class: say_name()
  • Object super: Ghost class: class: • metaclass frozen?() • eigenclass String • singleton class super: class: capitalize() anonymous super: value: “fred” class: monster class: say_name()
  • Ruby Classes Objects
  • Ruby Classes
  • Ruby Classes
  • Changing self
  • Changing self
  • Anonymous classes
  • Class methods There is no spoon...
  • Class methods
  • Object Class super: super: class: class: frozen?() new() anonymous super: super: class: class: Monster methods... say_name()
  • Changing self
  • Module#class_eval
  • Object#instance_eval
  • Object#instance_eval
  • Module#class_eval
  • module NiftyDSL
  • Fin.
  • One more thing...
  • Fin.