chicken-users
[Top][All Lists]
Advanced

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

Re: [Chicken-users] newbie questions about macros in modules


From: Felix
Subject: Re: [Chicken-users] newbie questions about macros in modules
Date: Mon, 26 Jul 2010 11:07:31 +0200 (CEST)

From: Imran Rafique <address@hidden>
Subject: [Chicken-users] newbie questions about macros in modules
Date: Thu, 22 Jul 2010 16:46:39 -0700

> Rank newbie here, so bear with me. I know these examples are somewhat
> contrived. I'm just trying to explore what I can (and can't do). I have a
> couple of questions regarding macro's inside a module.
> 
> 1) how to define something so that its available within either a macro or a
> function
> 
> (define-for-syntax) doesn't make the binding available for use in a
> function. And (define ...) has the opposite problem.

The problem here is that we are talking about two different execution
contexts: compile/expansion-time and run-time are not equivalent, they
may be very different and physically and temporarily completele independent.
The module system enforces this somewhat, so more care has to be taken
when what code is intended to execute.

> 
> So far, the only way I've found to do this (thanks to the VERY helpful and
> patient guys on #chicken) is to create a secondary module, move my bindings
> into that, and then import it twice into the module where the macros and
> functions - which use those variables - are themselves defined.

Yes, that is more or less the canonical answer.

> 
> Is there a better way?
> 
> 2) module io defines a macro (debug-info) and a function (print-info).
> debug-info calls print-info. If module io is imported without a prefix, then
> it works. If module io is imported WITH a prefix, then the macro
> (debug-info) is trying to call a function (print-info) which isn't available
> (only <prefix>print-info is). Is there any way to account for this when
> creating the macro?

This is a bug. Apparently import with renaming isn't working here.
I'll try to fix that and get back to you.


cheers,
felix



reply via email to

[Prev in Thread] Current Thread [Next in Thread]