What's better about Ruby than Python?

Kenny Tilton ktilton at nyc.rr.com
Thu Aug 21 19:57:02 EDT 2003


Dave Kuhlman wrote:
> Andrew Dalke wrote:
> 
> [snip]
> 
>>The complaint about macros has been their tendency to
>>increase a single person's abilities at the cost of overall
>>loss in group understanding.  I've heard references to
>>projects where that didn't occur, but am not swayed
>>by it because those seem staffed by people with
>>extraordinarily good programming skills almost never
>>found amoung the chemists and biologists I work with.
> 
> 
> I just took a quick look at the "Revised5 Report on the
> Algorithmic Language Scheme".  Macros in Scheme5 are called
> "hygienic macros", so apparently there are some dirty macros that
> we should worry about.  

(defmacro whoops (place &body code)
    `(let ((x (random 3)))
        (setf ,place (progn , at code))))

...wreaks havoc if the code refers to an X it had bound to something 
else and expected it to be used. otoh:

(defmacro c? (&body code)
    `(lambda (self) , at code))

...is cool because I can do the anaphoric thing and provide the user 
with a uniform referent to the instance owning the slot, ala SmallTalk 
or C++ with "this".



> My understanding is that macros came to
> Scheme slowly, with resistence, with a good deal of thought, and
> with restrictions.
> 
>      "More recently, Scheme became the first programming language
>      to support hygienic macros, which permit the syntax of a
>      block-structured language to be extended in a consistent and
>      reliable manner."
> 
> See:
> 
>     http://www.schemers.org/Documents/Standards/R5RS/HTML/
>    
> http://www.schemers.org/Documents/Standards/R5RS/HTML/r5rs-Z-H-3.html
>    
> http://www.schemers.org/Documents/Standards/R5RS/HTML/r5rs-Z-H-7.html#%_sec_4.3
> 
> I have the same worry that some others on this thread have
> expressed, that a macro capability in Python would enable others
> to write code that I would not be able to read or to figure out.
> 

Do what I do. Don't look at anyone else's code (if you have to work on 
it, rewrite it anyway) and never show your code to anyone.

Naw, c'mon, everyone seems to be conceding macros are powerful. But you 
are going to be held back by fear and worry? Well, I am a lispnik, we 
always opt for power and damn the torpedos, as when we go for the 
productivity win of untyped variables and give up on bugs strong static 
typing is supposed to find.



-- 

  kenny tilton
  clinisys, inc
  http://www.tilton-technology.com/
  ---------------------------------------------------------------
"Career highlights? I had two. I got an intentional walk from
Sandy Koufax and I got out of a rundown against the Mets."
                                                  -- Bob Uecker





More information about the Python-list mailing list