Mailing List Archive


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

[tlug] STM, the Silver Bullet, and the Foot



Curt Sampson writes:

 > This differs significantly from modern LISP-like languages where when
 > you say '(foo (a) (b))', and 'foo' happens to be 'and', it's specified
 > that '(a)' must be evaluated before '(b)', and '(b)' must not evaluated
 > if '(a)' evaluates to false. (Is 'foo' a macro with special evaluation
 > order, as above?

'foo' is whatever it is.  'and's behavior means that it is a "special
form", neither a macro nor a function (it can be implemented as a
macro, since macros evaluate none of their arguments so that its
expansion can do so where necessary).

;; Emacs Lisp idiom
(defmacro and (&rest args)
  ;; catch returns the value associated with the throw, if it occurs
  ;; otherwise it returns the value of the last form executed within it
  '(catch 'return
     (while args
       ;; don't eval an arg until it is used
       (when (null (eval (pop args))) (throw 'return nil)))
     t))

 > The advantage lies in Haskell, not in STM.

I'll buy that.  Caveat "or any pure functional language", of course.
Haskell just happens to be the (deservedly) popular one at the moment.



Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links