Re: [racket-dev] current-load/use-compiled

2011-06-22 Thread Robby Findler
Did you find the compiler/cm library? I think that's what you want.

Robby

On Thu, Jun 23, 2011 at 12:24 AM, Jon Rafkind  wrote:
> I'm trying to hook into the part of racket that loads files so I can
> automatically create .zo files when they don't exist (and no, I don't
> want to type raco make). Here is the code that loads the file and sets
> up the handler (more explanation follows the code).
>
> == load.rkt
> (let ([namespace (make-base-namespace)])
>  (define loader (current-load/use-compiled))
>  (parameterize ([current-namespace namespace]
>                 [current-load/use-compiled
>                   (lambda (path something)
>                     (define-values (parent self _) (split-path path))
>                     (parameterize ([current-load-relative-directory
> parent])
>                       (printf "compile/load ~a ~a\n" path something)
>                       (printf "load directory ~a\n"
> (current-load-relative-directory))
>                       #;
>                       ((compile-zos #f #:module? #t) (list path)
> "compiled")
>                       (define load-path
>                         (if (is-zo? path)
>                           path
>                           (build-path parent "compiled"
> (path-add-suffix self #".zo"
>                       (printf "Loading file ~a\n" load-path)
>                       (loader load-path something)))])
>    (eval-syntax (with-syntax ([file "test.rkt"])
>                   #'(require file)
>
> And here are the files being loaded
> == test.rkt
> #lang racket/base
>
> (require "test1.rkt")
>
> (printf "hello from test!\n")
>
> == test1.rkt
> #lang racket/base
>
> (require (for-syntax racket/base))
>
> (define-syntax (foo stx)
>  (printf "hello from foo macro\n")
>  #'(void))
>
> (foo)
>
> #;
> (begin-for-syntax
>  (printf "hello from phase1 code\n"))
>
> (printf "test1!\n")
>
> If I uncomment the 'begin-for-syntax' expression and run 'raco make' to
> produce a .zo file then running 'racket test.rkt' won't display the
> "hello from phase1 code" line. However if I run 'load.rkt' then no
> matter if there is a .zo or not I see that printf being executed.
> _
>  For list-related administrative tasks:
>  http://lists.racket-lang.org/listinfo/dev
>

_
  For list-related administrative tasks:
  http://lists.racket-lang.org/listinfo/dev

Re: [racket-dev] Strange problem with `check-docs' and `#:use-sources'

2011-06-22 Thread Robby Findler
To really know what is going on, one has to trace thru the re-provides
for each of these identifiers and match them up to the
declare-exporting declarations.

In the declaration below, you're essentially saying "any identifiers
documented in this module should appear to come from the
typed/scheme/base, typed/scheme, and typed-scheme modules, but they
are really actually exported from one of the modules listed in the
#:use-sources keyword" which means, to the documentation system that
any module that re-exports an identifier from, say,
typed-scheme/base-env/base-types-extra, will have its documentation
attached to the docs in the file with the declare-exporting below and
the docs system will then point userse to typed/scheme/base.

I don't think that this is what you want, since you probably want to
to point people to typed/racket.

To know what the right answer is for the declare-exporting below, I'd
have to know how typed/racket fits into the picture. In particular, is
it re-exporting things from typed/scheme? Or from those helper modules
you have listed? Or from some other place?

Robby

On Thu, Jun 23, 2011 at 3:16 AM, Sam Tobin-Hochstadt  wrote:
> Currently, the documentation completeness checker (a wonderful tool;
> thanks, Robby!) for Typed Racket complains that `->' and
> `with-handlers' are not documented when provided from `typed/scheme',
> `typed/scheme/base', and `typed-scheme'.  However, these identifiers
> are fine when provided from `typed/racket', and are both defined in
> modules where `check-docs' finds the documentation for other things
> just fine, such as `define:' and `All'.  The documentation looks like
> this:
>
> (declare-exporting typed/scheme/base typed/scheme typed-scheme
>                    #:use-sources
>                    (typed-scheme/typed-scheme
>                     typed-scheme/base-env/prims
>                     typed-scheme/base-env/extra-procs
>                     typed-scheme/base-env/base-types
>                     typed-scheme/base-env/base-types-extra))
>
> where `->' is defined in `typed-scheme/base-env/base-types-extra' and
> `with-handlers' is defined in `typed-scheme/base-env/prims'.
>
> Is there something else I should be doing here?  Is there a bug in
> `check-docs'?
> --
> sam th
> sa...@ccs.neu.edu
> _
>  For list-related administrative tasks:
>  http://lists.racket-lang.org/listinfo/dev
>

_
  For list-related administrative tasks:
  http://lists.racket-lang.org/listinfo/dev

[racket-dev] Strange problem with `check-docs' and `#:use-sources'

2011-06-22 Thread Sam Tobin-Hochstadt
Currently, the documentation completeness checker (a wonderful tool;
thanks, Robby!) for Typed Racket complains that `->' and
`with-handlers' are not documented when provided from `typed/scheme',
`typed/scheme/base', and `typed-scheme'.  However, these identifiers
are fine when provided from `typed/racket', and are both defined in
modules where `check-docs' finds the documentation for other things
just fine, such as `define:' and `All'.  The documentation looks like
this:

(declare-exporting typed/scheme/base typed/scheme typed-scheme
#:use-sources
(typed-scheme/typed-scheme
 typed-scheme/base-env/prims
 typed-scheme/base-env/extra-procs
 typed-scheme/base-env/base-types
 typed-scheme/base-env/base-types-extra))

where `->' is defined in `typed-scheme/base-env/base-types-extra' and
`with-handlers' is defined in `typed-scheme/base-env/prims'.

Is there something else I should be doing here?  Is there a bug in
`check-docs'?
-- 
sam th
sa...@ccs.neu.edu
_
  For list-related administrative tasks:
  http://lists.racket-lang.org/listinfo/dev


[racket-dev] current-load/use-compiled

2011-06-22 Thread Jon Rafkind
I'm trying to hook into the part of racket that loads files so I can
automatically create .zo files when they don't exist (and no, I don't
want to type raco make). Here is the code that loads the file and sets
up the handler (more explanation follows the code).

== load.rkt
(let ([namespace (make-base-namespace)])
  (define loader (current-load/use-compiled))
  (parameterize ([current-namespace namespace]
 [current-load/use-compiled
   (lambda (path something)
 (define-values (parent self _) (split-path path))
 (parameterize ([current-load-relative-directory
parent])
   (printf "compile/load ~a ~a\n" path something)
   (printf "load directory ~a\n"
(current-load-relative-directory))
   #;
   ((compile-zos #f #:module? #t) (list path)
"compiled")
   (define load-path
 (if (is-zo? path)
   path
   (build-path parent "compiled"
(path-add-suffix self #".zo"
   (printf "Loading file ~a\n" load-path)
   (loader load-path something)))])
(eval-syntax (with-syntax ([file "test.rkt"])
   #'(require file)

And here are the files being loaded
== test.rkt
#lang racket/base

(require "test1.rkt")

(printf "hello from test!\n")

== test1.rkt
#lang racket/base

(require (for-syntax racket/base))

(define-syntax (foo stx)
  (printf "hello from foo macro\n")
  #'(void))

(foo)

#;
(begin-for-syntax
  (printf "hello from phase1 code\n"))

(printf "test1!\n")

If I uncomment the 'begin-for-syntax' expression and run 'raco make' to
produce a .zo file then running 'racket test.rkt' won't display the
"hello from phase1 code" line. However if I run 'load.rkt' then no
matter if there is a .zo or not I see that printf being executed.
_
  For list-related administrative tasks:
  http://lists.racket-lang.org/listinfo/dev