Re: [racket-dev] Wrapping loops for TR isn't working, and the type annotations are for the wrong value

2012-08-15 Thread Sam Tobin-Hochstadt
On Tue, Aug 14, 2012 at 11:52 PM, Neil Toronto neil.toro...@gmail.com wrote: Some typed for loops would have to be reimplemented, unless inference improves a lot. To make this easier, I've attached an example implementation of `for/vector:' and `for*/vector:'. It allows both body and result

Re: [racket-dev] Wrapping loops for TR isn't working, and the type annotations are for the wrong value

2012-08-15 Thread Neil Toronto
On 08/15/2012 05:24 AM, Sam Tobin-Hochstadt wrote: On Tue, Aug 14, 2012 at 11:52 PM, Neil Toronto neil.toro...@gmail.com wrote: Some typed for loops would have to be reimplemented, unless inference improves a lot. To make this easier, I've attached an example implementation of `for/vector:'

Re: [racket-dev] Wrapping loops for TR isn't working, and the type annotations are for the wrong value

2012-08-15 Thread Sam Tobin-Hochstadt
On Wed, Aug 15, 2012 at 9:54 AM, Neil Toronto neil.toro...@gmail.com wrote: On 08/15/2012 05:24 AM, Sam Tobin-Hochstadt wrote: On Tue, Aug 14, 2012 at 11:52 PM, Neil Toronto neil.toro...@gmail.com wrote: Some typed for loops would have to be reimplemented, unless inference improves a lot.

Re: [racket-dev] Wrapping loops for TR isn't working, and the type annotations are for the wrong value

2012-08-15 Thread Neil Toronto
On 08/15/2012 08:05 AM, Sam Tobin-Hochstadt wrote: On Wed, Aug 15, 2012 at 9:54 AM, Neil Toronto neil.toro...@gmail.com wrote: When #:length is given, it's similar in that it creates a vector outside the loop and bangs values into it. But I have to start with (define vs (vector)) and then (set!

Re: [racket-dev] Wrapping loops for TR isn't working, and the type annotations are for the wrong value

2012-08-15 Thread Matthew Flatt
At Wed, 15 Aug 2012 07:54:16 -0600, Neil Toronto wrote: I wouldn't want to because `for/vector' is currently broken when #:length is given. (See PR 13029 and PR 13030.) I think the only way to fix it is to implement it like I did: expand to plain `for:' and mutate an external index. I

Re: [racket-dev] Wrapping loops for TR isn't working, and the type annotations are for the wrong value

2012-08-15 Thread J. Ian Johnson
- Original Message - From: Neil Toronto neil.toro...@gmail.com To: Sam Tobin-Hochstadt sa...@ccs.neu.edu Cc: dev@racket-lang.org dev@racket-lang.org Sent: Wednesday, August 15, 2012 10:36:36 AM GMT -05:00 US/Canada Eastern Subject: Re: [racket-dev] Wrapping loops for TR isn't working, and

Re: [racket-dev] Wrapping loops for TR isn't working, and the type annotations are for the wrong value

2012-08-15 Thread Neil Toronto
On 08/15/2012 08:39 AM, J. Ian Johnson wrote: - Original Message - From: Neil Toronto neil.toro...@gmail.com To: Sam Tobin-Hochstadt sa...@ccs.neu.edu So then the first value computed is replicated everywhere? That seems unappealing as well. It costs nothing, and if the #:length

Re: [racket-dev] Wrapping loops for TR isn't working, and the type annotations are for the wrong value

2012-08-15 Thread Jens Axel Søgaard
2012/8/15 Neil Toronto neil.toro...@gmail.com: Other options: 1. Raise an error when the vector isn't filled. 2. Return a (Vectorof (U T #f)) (better than (Vectorof (U T 0))?). 3. Always return a vector whose length is the number of iterations. Or a variation of 2.: 4. Let the user

Re: [racket-dev] Wrapping loops for TR isn't working, and the type annotations are for the wrong value

2012-08-15 Thread Matthew Flatt
At Wed, 15 Aug 2012 17:38:18 +0200, Jens Axel Søgaard wrote: 2012/8/15 Neil Toronto neil.toro...@gmail.com: Other options: 1. Raise an error when the vector isn't filled. 2. Return a (Vectorof (U T #f)) (better than (Vectorof (U T 0))?). 3. Always return a vector whose length is

Re: [racket-dev] Wrapping loops for TR isn't working, and the type annotations are for the wrong value

2012-08-15 Thread Neil Toronto
I've attached my latest. It's possibly better. On 08/15/2012 08:05 AM, Sam Tobin-Hochstadt wrote: So then the first value computed is replicated everywhere? That seems unappealing as well. I've implemented #:fill in this one. If both #:length and #:fill are given, the vector is created with

Re: [racket-dev] Wrapping loops for TR isn't working, and the type annotations are for the wrong value

2012-08-15 Thread Neil Toronto
On 08/15/2012 08:05 AM, Sam Tobin-Hochstadt wrote: On Wed, Aug 15, 2012 at 9:54 AM, Neil Toronto neil.toro...@gmail.com wrote: BTW, what do you think of deprecating result annotations and using body annotations instead? I'm not sure yet. This short exercise might convince you: implement

Re: [racket-dev] Wrapping loops for TR isn't working, and the type annotations are for the wrong value

2012-08-15 Thread Jens Axel Søgaard
There is a similar problem with for/product: . The initial 1 is that an integer, a real or a complex? (for/product: : Real ([i : Integer (in-range 0 5)]) (/ i)) Type Checker: Expected Integer, but got Exact-Rational in: (for/product: : Real ((i : Integer (in-range 0 5))) (/ i)) It does not

[racket-dev] Wrapping loops for TR isn't working, and the type annotations are for the wrong value

2012-08-14 Thread Neil Toronto
I like the idea of wrapping Racket's standard for loops with a few annotations and letting inference figure out the rest of the types. The problem is, it doesn't work very well. 1. Even though the loop's type is technically optional, it seems to always be required. 2. Many simple loops