Loading ...
Sorry, an error occurred while loading the content.

72Re: [ruby-india] Re: Learning Ruby

Expand Messages
  • Yogi
    Mar 7, 2005
      You're right, my mistake... when I first saw eval and the way Ruby
      uses symbols to do neat stuff like create methods, it seemed very much
      like the lisp approach of building the language up to the domain, and
      I (wrongly) jumped to the conclusion that ruby has full-blown macros.

      But it doesn't. At least not like lisp, where the parameters to a
      macro are immediately quoted and passed in as a data structure which
      the macro can use to form another SExp. Essentially lisp delays the
      evaluation of a macro's parameters until they are expanded by the

      While you can use ruby eval to build the language up to the domain
      (the active record example you mentioned), you cannot easily extend
      the core syntax of ruby as you can in lisp (well at least not that
      easily or cleanly... in the link you mentioned the defmacro method
      takes a regular expression as a parameter to do replacements in the
      body of the method, which is then passed to eval... which is actually
      really clever, but a bit hacky).

      Thanks for pointing that out! Ravi, did I get that right?

      On Mon, 07 Mar 2005 13:23:53 +0530, Avik Sengupta
      <avik.sengupta@...> wrote:
      > Well, since even excel has macros (and so does textpad), the term is
      > probably overloaded...
      > So apparently ruby does NOT have macro's in the language in the Lisp
      > sense of the term, but arguably you can do almost everything that you'd
      > need macros for using blocks etc... See discussion starting here
      > http://www.ruby-talk.org/cgi-bin/scat.rb/ruby/ruby-talk/108059 for
      > arguments both for and against that hypothesis (and according to Paul
      > Graham, if you add macro's to the language, you cant say you'd invented
      > a new language, you'd just have a dialect of lisp :)
      > In particular, the domain language used by Active Record is really the
      > kind of thing that you'd use macro's for. I have no idea how its
      > implemented ... presumably a combination of blocks/ method_missing/
      > mixins etc (above thread also shows how to emulate some form of macro
      > functionality in pure ruby). So while a lisp'er will cringe at calling
      > it a macro... "Anything that quacks like a macro - is a macro" ??
      > :)
      > -
      > Avik
      > disclaimer - All the above may be b****hit... i'm still trying to figure
      > out what a continuation is... so a lot of this is over my head :)

      - Yogi
      Developer, www.thoughtworks.com
    • Show all 12 messages in this topic