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

Re: Ruby and OO (fwd)



I'd like to point out that what makes the Ruby syntax convenient is that
it does not force the programmer to think in OO terms.  Even if the
block { |i| puts(i) } is implemented as some kind of object, from the
programmer's perspective it's just a function.  There's no need to
establish a package/object/method/statement/expression hierarchy as in
Java.

Don Blaheta <dpb@cs.brown.edu> writes:

> (List-each lst (lambda (i) (puts i)))

Here's complete code that gets rid of the scary word, "lambda", allowing

 (list-each lst (i) (puts i))

to work.  Any Scheme implementation that complies to the 1998 standard
will handle it.

(define (puts i)
  (display i)
  (newline))

(define-syntax list-each
  (syntax-rules ()
    ((list-each lst args expr ...)
     (for-each (lambda args expr ...) lst))))

(define lst (list 1 2 3))

(define (test-list-each)
  (list-each lst (i) (puts i)))

-- 
<brlewis@[(if (brl-related? message)    ; Bruce R. Lewis
              "users.sourceforge.net"   ; http://brl.sourceforge.net/
              "alum.mit.edu")]>