[racket-dev] cross-phase syntax constants

2012-07-05 Thread Sam Tobin-Hochstadt
I'd like to write a program basically like this:

#lang racket/load

(module m1 racket
  (define l (list #'l))
  (provide l))

(module m2 racket
  (require (for-syntax 'm1))
  (define-syntax (mac stx)
#`(module* sub #f
(length (list #,(car l)
  (provide mac))

(module m3 racket
  (require 'm2)
  (mac))

But I can't come up with any way to `require` m1 appropriately so that
`l` is bound in the generated submodule.  If I wrap the body of the
submodule in `begin-for-syntax`, then it works, but then loading the
submodule does the computation at the wrong phase.  So another
solution would be `dynamic-require-for-template`, if that's feasible.
-- 
sam th
sa...@ccs.neu.edu
_
  Racket Developers list:
  http://lists.racket-lang.org/dev


[racket-dev] A very listy Typed Racket Integer

2012-07-05 Thread Neil Toronto

I just found this today:


#lang typed/racket

(define: b : (Boxof Any) (box 4))

(define-predicate boxof-integer? (Boxof Integer))

(define (set-b-box! v) (set-box! b v))

(: a-very-listy-integer (- Integer))
(define (a-very-listy-integer)
  (cond [(boxof-integer? b)  (set-b-box! '(1 2 3))
 (unbox b)]
[else  (error 'a-very-listy-integer can't happen)]))


 (a-very-listy-integer)
- : Integer
'(1 2 3)


Is this a bug or a limitation? It can be replicated with any mutable 
container type as far as I can tell.


Also, if it's a limitation, can I get (Vectorof Index) to be a subtype 
of (Vectorof Integer)?


Neil ⊥
_
 Racket Developers list:
 http://lists.racket-lang.org/dev


Re: [racket-dev] A very listy Typed Racket Integer

2012-07-05 Thread Sam Tobin-Hochstadt
On Jul 5, 2012 8:50 PM, Neil Toronto neil.toro...@gmail.com wrote:

 I just found this today:


 #lang typed/racket

 (define: b : (Boxof Any) (box 4))

 (define-predicate boxof-integer? (Boxof Integer))

This is the bug -- there's no way to write the boxof-integer? predicate,
and define- predicate shouldn't think it can.

 (define (set-b-box! v) (set-box! b v))

 (: a-very-listy-integer (- Integer))
 (define (a-very-listy-integer)
   (cond [(boxof-integer? b)  (set-b-box! '(1 2 3))
  (unbox b)]
 [else  (error 'a-very-listy-integer can't happen)]))


  (a-very-listy-integer)
 - : Integer
 '(1 2 3)


 Is this a bug or a limitation? It can be replicated with any mutable
container type as far as I can tell.

A bug.  Anytime you get a result like that it's a bug.


 Also, if it's a limitation, can I get (Vectorof Index) to be a subtype of
(Vectorof Integer)?

No, that relationship would be unsound for similar reasons.

 Neil ⊥
 _
  Racket Developers list:
  http://lists.racket-lang.org/dev
_
  Racket Developers list:
  http://lists.racket-lang.org/dev