[racket] Call racket from racket on MacOSX, no response

From: Danny Yoo (dyoo at cs.wpi.edu)
Date: Wed Jul 27 00:18:50 EDT 2011

On Tue, Jul 26, 2011 at 11:37 PM, Niitsuma Hirotaka
<hirotaka.niitsuma at gmail.com> wrote:
> more problem
>
> It happen on linux
>
> save as a.scm
> ---------
> (display (+ 10 3))
> ---------
> then call from shell
>
> $ racket -f a.scm
> 13
>
> It works OK


But just as a note: this use of Racket is not as popular these days,
because the file above is not a "module".   In idiomatic Racket, I
would translate the above to a file called 'a.rkt' with the content:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
#lang racket
(display (+ 10 3))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

The lang line at the top of the file explicitly labels the program as
one written in "racket".  The file can be executed from the shell with
the following:

    $ racket a.rkt


I would stay away from non-module code in Racket unless I had a very
good reason to do so.  Modules do a good amount of error trapping.  If
I misspell an identifier in a function definition, for example,
modules will catch the errors at compile time, rather than at run
time.  As an example, I can try to compile:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
#lang racket
(define (greet name)
   (string-append "hello " nme))

(greet "Niitsuma")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

If I write this as a module, then Racket will tell me immediately that
I've misspelled 'nme'.

But if I were to do the same without modules, by having a file without
the lang line and running it with -f, Racket will try to look up the
value of 'nme' at runtime at the toplevel, which is almost certainly
not what I want.


Posted on the users mailing list.