[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: *current-language*
From: |
Andy Wingo |
Subject: |
Re: *current-language* |
Date: |
Sun, 04 Dec 2011 22:01:44 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) |
Hello June!
On Sun 12 Jun 2011 03:24, BT Templeton <address@hidden> writes:
> What is `*current-language*' supposed to be used for?
It is supposed to be a default language for the compiler and other
things that are interested in languages.
> I see that it's
> set by `(@ (ice-9 eval-string) read-and-eval)' and by `(@ (system base
> compile) read-and-compile)', but not by the REPL.
That's a bug. Fixed, thanks for the report!
> I think it might be preferable to require explicit language arguments to
> all compilation functions, or to default to Scheme explicitly.
We can change this in 2.2 I think if we want to. But do we want to? It
seems like a classic use for dynamic scoping.
> --- a/module/system/base/compile.scm
> +++ b/module/system/base/compile.scm
> @@ -120,9 +120,18 @@
> (and (false-if-exception (ensure-writable-dir (dirname f)))
> f))))
>
> +(define (guess-file-language file)
> + (cond
> + ((string-suffix? ".scm" file)
> + (lookup-language 'scheme))
> + ((string-suffix? ".el" file)
> + (lookup-language 'elisp))
> + (else
> + (current-language))))
> +
> (define* (compile-file file #:key
> (output-file #f)
> - (from (current-language))
> + (from (guess-file-language file))
I guess in general I'd prefer something like Racket's #!lang directives,
though I'm not opposed to this approach. Dunno!
Andy
--
http://wingolog.org/
- Re: *current-language*,
Andy Wingo <=