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

Re: [Scheme-reports] file inclusion (section 4.1.7 of draft 9)

On Sat, Jun 8, 2013 at 1:40 PM, Takashi Kato <ktakashi@x> wrote:
On 08/06/2013 05:38, John Cowan wrote:
> Daniel Villeneuve scripsit:
>> (define-syntax m
>>     (syntax-rules ()
>>       ((_) (lambda (a) (include "some/file.sch")))))
>> where the file "some/file.sch" contains, say,
>> (+ a 1)
>> Is the symbol `a' in "some/file.sch" supposed to match the
>> lambda's argument?
> Yes, I believe so: files are included at the S-_expression_ level,
> not hygienically.

I disagree. Since 'include' is exportable syntax then the expanded
_expression_ should be like this;

(lambda (~a) (include "some/file.sch"))

Then compiler will compile it. Now, included 'a' is mere symbol so that
'include' includes mere S-_expression_. So after include should be like this;

(lambda (~a) (+ a 1))

How could compiler know these 2 symbols are the same? (I haven't checked
with current implementations, including mine, so what I'm saying might
not be the current situation, though.)

Correct - the macro is hygienic, so the a in the file won't
match the renamed a in the lambda.

BTW, if the above macro is defined in a library, which file would be
included? The file in the same location of the library or macro caller

By the time the include is expanded it has no idea in
which file it was originally defined (barring some sort
of self-introspection on source info), so the include path
would naturally be relative to the caller location.


Scheme-reports mailing list