Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Useful C Macros

Name: Anonymous 2010-01-12 15:24

Let's share the macros we use that make our C code really EXPERT!!

Right now I'm specifically interested in macros to add half-assed object orientation. Thanks!!

I'll contribute myself:
#define mainstart int main(int argc, char **argv) {

Name: Anonymous 2010-01-14 11:57

Here is a useful c macro.
(define f
  (λ()(error "f")))


(define-syntax c
  (syntax-rules ()
    ((c) (f))
    ((c ?x) ?x)
    ((c ?x ?y)
     (let ((old-f f))
       ((call-with-current-continuation
         (lambda (cc)
           (set! f
                 (lambda ()
                   (set! f old-f)
                   (cc (lambda () ?y))))
           (lambda () ?x))))))
    ((c ?x ?rest ...)
     (c ?x (c ?rest ...)))))

(let ((x (c 1 2 3 4 5))
      (y (c 1 2 3 4 5))
      (z (c 1 2 3 4 5)))
  (if (= 14 (+ x y z))
      (list x y z)
      (c)))
=> (4 5 5)

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List