OK, I sat down and re-read:
https://docs.racket-lang.org/guide/phases.html

Then I noticed I made a stupid mistake in my first attempt. I didn't
need to provide the binding at different levels, I needed only to
require it at different levels. So doing
(require s10/arch-choice
         (for-syntax s10/arch-choice))

did the trick.

Thanks for your time helping me with this issue.

Kind regards,

Paulo Matos

On 13/09/2018 14:28, 'Paulo Matos' via Racket Users wrote:
> 
> 
> On 12/09/2018 16:37, Matthew Flatt wrote:
>> As you
>> say, you could have a macro expand to the result of `(getenv "ARCH")`
>> to pin it down at compile time, but you'll need to import that macro
>> into two phases, since the right-hand side of
>> `define-runtime-module-path-index` is implicitly used at two phases. 
> 
> Thanks for your thorough explanation of the issues. That clarified it
> completely.
> 
> I have got it to working and realised that actually a compile time
> configuration is more future-proof in case I end up developing a private
> backend for a customer which I should ship to another customer by
> mistake, therefore embedding a single backend per release is better.
> 
> I setup a file which does this to choose the backend at compile-time:
> #lang racket/base
> ;;
> ---------------------------------------------------------------------------------------------------
> 
> (require (for-syntax racket/base))
> 
> (provide get-configured-backend-path)
> 
> ;;
> ---------------------------------------------------------------------------------------------------
> ;; This module is used to move the compile time variable s10arch, read
> from the environment
> ;; to a build-time variable using a macro.
> 
> (begin-for-syntax
>   ;; An environment variable must be defined selecting the arch to use.
>   (define s10arch (getenv "S10ARCH"))
> 
>   (unless s10arch
>     (raise-user-error 'driver "Please define S10ARCH environment
> variable")))
> 
> (define-syntax (get-configured-backend-path stx)
>   (syntax-case stx ()
>     [(_) (datum->syntax stx s10arch)]))
> 
> 
> Then from another module I am doing:
> (require s10/arch-choice)
> 
> (define-runtime-module-path-index backend-path
>   (build-path (get-configured-backend-path) "name.rkt"))
> 
> However the problem here is that get-configured-backend-path does not
> exist in level0 - only in level1.
> 
> I tried to provide it then like so:
> (provide get-configured-backend-path
>          (for-syntax get-configured-backend-path))
> 
> and then require it for syntax as well in the driver module, however
> this generates the strange:
> s10/arch-choice.rkt:7:21: provide: provided identifier is not defined or
> required
> 
> How can get get-configured-backend-path to exist at both level which
> seems to be what define-runtime-module-path-index requires?
> 
> 

-- 
Paulo Matos

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to