Sorry if I didn't find it somewhere obvious, but I don't know how to do the
following.

I would like a have a file that when run standalone executes some code, and
when "required" by another module just provides some definitions.

Example:

;-------------------------------------------------------
; my-lib.rkt
(provide make-milk-shake)

(define (make-milk-shake flavor)
  ...)

; run this only when run standalone
(*magic-thing*
  (make-milk-shake 'banana)


;-------------------------------------------------------
; some-other.rkt
(require "my-lib.rkt")

(make-milk-shake 'strawberry)
; only make 1 milk shake of strawberry...



That is, I am searching for an equivalent idiom for what in Python I'd
write:

if __name__ == "__main__":
    do_things()




[]'s

Rodolfo Carvalho
_________________________________________________
  For list-related administrative tasks:
  http://lists.racket-lang.org/listinfo/users

Reply via email to