Re: [racket-dev] toward a new Racket macro expander

2015-02-26 Thread David Vanderson


On 02/26/2015 12:26 PM, Matthew Flatt wrote:

I've been working on a new macro expander for Racket, and I'm starting
to think that it will work. The new expander is not completely
compatible with the current expander --- and that will be an issue if
we eventually go forward with the change --- but most existing code
still works.

Here's a report on my current experiment:

  http://www.cs.utah.edu/~mflatt/scope-sets/


The goals for a new expander are

  1. to replace a complicated representation of syntax objects with a
 simpler one (and, as a result, avoid some performance and
 submodule-re-expansion problems that have been too difficult to fix
 with the current expander);

  2. to find a simpler model of binding than the current one, so that
 it's easier to explain and reason about scope and macros; and

  3. to implement the new expander in Racket instead of C.

I have possibly succeeded on 1, possibly succeeded to some degree on 2,
and temporarily given up on 3.

Thank you!  I'm still trying to understand how the current expansion 
process works.  This seems easier to reason about, so for me you're 
hitting goal 2.  And the comparison is helping me understand the current 
process as well.


Thanks,
Dave

--
You received this message because you are subscribed to the Google Groups Racket 
Developers group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-dev+unsubscr...@googlegroups.com.
To post to this group, send email to racket-...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-dev/54EFEA63.6040900%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


[racket-dev] gui responsiveness

2014-04-16 Thread David Vanderson

(moved to dev)

On Linux, the attached program shows terrible responsiveness when 
dragging points around on the graph.  Can anyone else on Linux reproduce 
this behavior?



The patch below dramatically improves the responsiveness by forcing the 
eventspace to process medium-level events (mouse movement) before 
refresh events.  Without the patch, each mouse drag causes a paint.  
With it, multiple mouse drags are processed before a paint.



I'm unsure about this fix.  Windows doesn't show the problem (I don't 
have a mac to test), so I think it's just a GTK issue.


My guess is that the gui layer is relying on the native libraries to 
coalesce multiple refresh requests (but this is not working with GTK).  
Can anyone confirm this?


Thanks,
Dave



diff -ru 
racket-6.0_clean/share/pkgs/gui-lib/mred/private/wx/common/queue.rkt 
racket-6.0/share/pkgs/gui-lib/mred/private/wx/common/queue.rkt
--- racket-6.0_clean/share/pkgs/gui-lib/mred/private/wx/common/queue.rkt 
2014-02-18 12:27:43.0 -0500
+++ racket-6.0/share/pkgs/gui-lib/mred/private/wx/common/queue.rkt 
2014-04-16 09:41:16.810993955 -0400

@@ -300,8 +300,8 @@
(lambda (_) #f))
(or (first hi peek?)
(timer-first-ready timer peek?)
-   (first refresh peek?)
(first med peek?)
+   (first refresh peek?)
(and (not peek?)
 sync?
 ;; before going 
with low-priority events,


#lang racket/gui

(require plot
 (lib plot/private/no-gui/plot2d-utils.rkt)
 (lib plot/private/plot2d/plot-area.rkt))

(define data
  (vector (list 1 1)
  (list 3 4)))

(define *area* #f)

(define (draw-screen canvas dc)
  (define renderer-tree
(points data #:size 10))
  
  (define x 0)
  (define y 0)
  (define width 400)
  (define height 400)
  
  (define x-min 0)
  (define x-max 10)
  (define y-min 0)
  (define y-max 10)
  
  ; this shamefully ripped out of the plot code for plot/dc
  ; so we can access the area object
  (define renderer-list (get-renderer-list renderer-tree))
  (define bounds-rect (get-bounds-rect renderer-list x-min x-max y-min y-max))
  (define-values (x-ticks x-far-ticks y-ticks y-far-ticks)
(get-ticks renderer-list bounds-rect))
  
  (define area (make-object 2d-plot-area%
 bounds-rect x-ticks x-far-ticks y-ticks y-far-ticks dc x y 
width height))
  (plot-area area renderer-list)
  (set! *area* area))

(define frame
  (new frame%
   (label Interactive Plot)
   (width 400)
   (height 400)))

(define drag-point #f)
(define dragx #f)
(define dragy #f)

(define my-canvas
(class canvas%
  (define/override (on-event event)
(define x (send event get-x))
(define y (send event get-y))
(cond
  ((send event button-down? 'left)
   (set! drag-point #f)  ; just in case we missed the button-up?
   (define cur (send *area* dc-plot (vector x y)))
   (for (((d i) (in-indexed data)))
 (when (and
((abs (- (first d) (vector-ref cur 0))) .  . 0.5)
((abs (- (second d) (vector-ref cur 1))) .  . 0.5))
   (set! drag-point i)))
   (set! dragx x)
   (set! dragy y))
  ((send event dragging?)
   (when (and *area* drag-point)
 (define prev (send *area* dc-plot (vector dragx dragy)))
 (define cur (send *area* dc-plot (vector x y)))
 (define dx (- (vector-ref cur 0) (vector-ref prev 0)))
 (define dy (- (vector-ref cur 1) (vector-ref prev 1)))
 ;(printf change ~v\n (list dx dy))
 (vector-set! data drag-point
  (list (+ (first (vector-ref data drag-point)) dx)
(+ (second (vector-ref data drag-point)) dy)))
 (send this refresh))
   (set! dragx x)
   (set! dragy y
  (super-new)))
  
(define canvas
  (new my-canvas
   (parent frame)
   (paint-callback draw-screen)))

(send frame show #t)

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


Re: [racket-dev] gui responsiveness

2014-04-16 Thread David Vanderson
Thanks for the great (and quick!) response.  It's good to know that the 
ordering is intentional, and to have some nice ways to work around it if 
needed.


The reason I thought that refreshes were lower priority was because of 
the scrollbar behavior in the program below.  On Unix/X, dragging the 
scrollbar back and forth does lots of paints, but I only actually see a 
few of them.


Does that sound like a bug to you?


#lang racket/gui

(define num-on-paint 0)

(define frame
  (new frame%
   (label Refresh)
   (width 500)
   (height 500)))

(define (draw-screen canvas dc)
  (set! num-on-paint (add1 num-on-paint))
  (sleep 0.1) ; simulate a longer painting effort
  (send dc draw-text (~a num-on-paint  paints) 400 70))

(define canvas
  (new canvas%
   (parent frame)
   (paint-callback draw-screen)
   (style '(no-autoclear hscroll

(send frame show #t)

(send canvas init-auto-scrollbars 700 #f 0.0 0.0)



On 04/16/2014 01:56 PM, Matthew Flatt wrote:

You're right that it's about event ordering and not refresh coalescing.
Since mouse events are handled after refreshes, you won't get the next
refresh request until an earlier one is handled, after which the next
mouse event can trigger another refresh request. I think the difference
between Unix/X and Windows may be that Windows sends fewer mouse
events.

There are trade-offs here, but my experience is that ordering input
events before refresh does not work well in general. To trigger
refreshes at a lower priority in this case, you could use Neil's
suggestion or change

  (send this refresh)

to

  (set! needed? #t)
  (queue-callback (lambda () (when needed?
   (set! needed? #f)
   (send this refresh)))
  #f) ; = low priority

where `needed?` is a field that's initially #f.

At Wed, 16 Apr 2014 13:33:02 -0400, David Vanderson wrote:

(moved to dev)

On Linux, the attached program shows terrible responsiveness when
dragging points around on the graph.  Can anyone else on Linux reproduce
this behavior?


The patch below dramatically improves the responsiveness by forcing the
eventspace to process medium-level events (mouse movement) before
refresh events.  Without the patch, each mouse drag causes a paint.
With it, multiple mouse drags are processed before a paint.


I'm unsure about this fix.  Windows doesn't show the problem (I don't
have a mac to test), so I think it's just a GTK issue.

My guess is that the gui layer is relying on the native libraries to
coalesce multiple refresh requests (but this is not working with GTK).
Can anyone confirm this?

Thanks,
Dave



diff -ru
racket-6.0_clean/share/pkgs/gui-lib/mred/private/wx/common/queue.rkt
racket-6.0/share/pkgs/gui-lib/mred/private/wx/common/queue.rkt
--- racket-6.0_clean/share/pkgs/gui-lib/mred/private/wx/common/queue.rkt
2014-02-18 12:27:43.0 -0500
+++ racket-6.0/share/pkgs/gui-lib/mred/private/wx/common/queue.rkt
2014-04-16 09:41:16.810993955 -0400
@@ -300,8 +300,8 @@
(lambda (_) #f))
  (or (first hi peek?)
(timer-first-ready timer peek?)
-   (first refresh peek?)
  (first med peek?)
+   (first refresh peek?)
  (and (not peek?)
   sync?
   ;; before going
with low-priority events,


--
[text/plain graph_ui.rkt] [~/Desktop  open] [~/Temp  open]
_
   Racket Developers list:
   http://lists.racket-lang.org/dev


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


Re: [racket-dev] draw-text always pixel aligned?

2013-12-17 Thread David Vanderson
Update - according to the cairo developers, this is a limitation of the 
current implementation of cairo, so there's nothing to be fixed. Thanks 
again for looking into it!



As a workaround, they suggested creating a path from the text and 
filling it, which works well:


#lang racket/gui

(define (draw-text dc offset)
  (send dc set-brush red 'solid)
  (send dc set-pen red 1 'transparent)

  (let ((p (new dc-path%)))
(send p text-outline (send dc get-font) hello 0 0)
(send dc draw-path p 0 0))

  (send dc set-brush black 'solid)
  (send dc set-pen black 1 'transparent)

  (let ((p (new dc-path%)))
(send p text-outline (send dc get-font) hello 0 0)
(send dc draw-path p offset offset))

  (send dc set-text-foreground red)
  (send dc draw-text hello 0 20 #t)
  (send dc set-text-foreground black)
  (send dc draw-text hello offset (+ 20 offset) #t)
  )

(define (draw-screen canvas dc)
  (send dc set-smoothing 'smoothed)
  (send dc set-font
(send the-font-list find-or-create-font
  12 'default 'normal 'normal #f 'smoothed #f 'aligned))
  (send dc set-initial-matrix (vector 1 0 0 1 0 0))
  (for ((i 10))
(draw-text dc (/ i 10.0))
(send dc translate 50 0)))

(define frame (new frame% (label Test draw-text)))

(define canvas
  (new canvas%
   (parent frame)
   (min-width 500)
   (min-height 100)
   (paint-callback draw-screen)))

(send frame show #t)





On 12/16/2013 02:16 PM, David Vanderson wrote:

Thank you - I'll look into it.

On 12/16/2013 02:14 PM, Matthew Flatt wrote:

Yes, it's the same on Mac and Windows.

At Mon, 16 Dec 2013 14:12:18 -0500, David Vanderson wrote:
Thanks for looking into it. Can you confirm if you see similar 
output on

a different platform (Mac or Win)?

On 12/16/2013 12:26 PM, Matthew Flatt wrote:

I'm not sure about that part. I've confirmed that the cairo_move_to()
call just before pango_cairo_show_layout_line() varies the y 
argument

by 0.1, and I don't see any options that would affect vertical
alignment.

At Mon, 16 Dec 2013 10:37:39 -0500, David Vanderson wrote:

That makes sense, but the picture with 'unaligned seems strange
(attached). It looks like each individual character is being pixel
aligned, and also the vertical pixel drop doesn't happen until 
it's 0.7

pixels down. Does this make sense?

On 12/16/2013 08:15 AM, Matthew Flatt wrote:

Did you mean to pass 'unaligned instead of 'aligned as the last
argument to `find-or-create-font`? That should disable pixel 
alignment.


At Mon, 16 Dec 2013 01:28:23 -0500, David Vanderson wrote:

Hello,

It seems that draw-text always pixel-aligns its text. In the 
example
below, I draw a black hello on top of a red one, with a pixel 
offset
of 0, 0.1, 0.2, . . . 0.9. At least for me, I see no change 
until 0.5,

where the black text jumps a whole pixel (see attached image).

Am I missing something? Do others see this behavior? (I'm on Linux)

Thanks,
Dave


#lang racket/gui

(define (draw-text dc offset)
  (send dc set-text-foreground red)
  (send dc draw-text hello 0 0 #t)
  (send dc set-text-foreground black)
  (send dc draw-text hello offset offset #t))

(define (draw-screen canvas dc)
  (send dc set-smoothing 'smoothed)
  (send dc set-font
(send the-font-list find-or-create-font
  12 'default 'normal 'normal #f 'smoothed #f 
'aligned))

  (send dc set-initial-matrix (vector 1 0 0 1 0 0))
  (for ((i 10))
(draw-text dc (/ i 10.0))
(send dc translate 50 0)))

(define frame (new frame% (label Test draw-text)))

(define canvas
  (new canvas%
   (parent frame)
   (min-width 500)
   (min-height 100)
   (paint-callback draw-screen)))

(send frame show #t)


-- 

[image/png draw-text2-unaligned.png] [~/Desktop  open] [~/Temp 
 open]

.




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


Re: [racket-dev] draw-text always pixel aligned?

2013-12-16 Thread David Vanderson
That makes sense, but the picture with 'unaligned seems strange 
(attached). It looks like each individual character is being pixel 
aligned, and also the vertical pixel drop doesn't happen until it's 0.7 
pixels down. Does this make sense?


On 12/16/2013 08:15 AM, Matthew Flatt wrote:

Did you mean to pass 'unaligned instead of 'aligned as the last
argument to `find-or-create-font`? That should disable pixel alignment.

At Mon, 16 Dec 2013 01:28:23 -0500, David Vanderson wrote:

Hello,

It seems that draw-text always pixel-aligns its text. In the example
below, I draw a black hello on top of a red one, with a pixel offset
of 0, 0.1, 0.2, . . . 0.9. At least for me, I see no change until 0.5,
where the black text jumps a whole pixel (see attached image).

Am I missing something? Do others see this behavior?  (I'm on Linux)

Thanks,
Dave


#lang racket/gui

(define (draw-text dc offset)
(send dc set-text-foreground red)
(send dc draw-text hello 0 0 #t)
(send dc set-text-foreground black)
(send dc draw-text hello offset offset #t))

(define (draw-screen canvas dc)
(send dc set-smoothing 'smoothed)
(send dc set-font
  (send the-font-list find-or-create-font
12 'default 'normal 'normal #f 'smoothed #f 'aligned))
(send dc set-initial-matrix (vector 1 0 0 1 0 0))
(for ((i 10))
  (draw-text dc (/ i 10.0))
  (send dc translate 50 0)))

(define frame (new frame% (label Test draw-text)))

(define canvas
(new canvas%
 (parent frame)
 (min-width 500)
 (min-height 100)
 (paint-callback draw-screen)))

(send frame show #t)




attachment: draw-text2-unaligned.png_
  Racket Developers list:
  http://lists.racket-lang.org/dev


Re: [racket-dev] draw-text always pixel aligned?

2013-12-16 Thread David Vanderson
Thanks for looking into it. Can you confirm if you see similar output on 
a different platform (Mac or Win)?


On 12/16/2013 12:26 PM, Matthew Flatt wrote:

I'm not sure about that part. I've confirmed that the cairo_move_to()
call just before pango_cairo_show_layout_line() varies the y argument
by 0.1, and I don't see any options that would affect vertical
alignment.

At Mon, 16 Dec 2013 10:37:39 -0500, David Vanderson wrote:

That makes sense, but the picture with 'unaligned seems strange
(attached). It looks like each individual character is being pixel
aligned, and also the vertical pixel drop doesn't happen until it's 0.7
pixels down. Does this make sense?

On 12/16/2013 08:15 AM, Matthew Flatt wrote:

Did you mean to pass 'unaligned instead of 'aligned as the last
argument to `find-or-create-font`? That should disable pixel alignment.

At Mon, 16 Dec 2013 01:28:23 -0500, David Vanderson wrote:

Hello,

It seems that draw-text always pixel-aligns its text. In the example
below, I draw a black hello on top of a red one, with a pixel offset
of 0, 0.1, 0.2, . . . 0.9. At least for me, I see no change until 0.5,
where the black text jumps a whole pixel (see attached image).

Am I missing something? Do others see this behavior?  (I'm on Linux)

Thanks,
Dave


#lang racket/gui

(define (draw-text dc offset)
 (send dc set-text-foreground red)
 (send dc draw-text hello 0 0 #t)
 (send dc set-text-foreground black)
 (send dc draw-text hello offset offset #t))

(define (draw-screen canvas dc)
 (send dc set-smoothing 'smoothed)
 (send dc set-font
   (send the-font-list find-or-create-font
 12 'default 'normal 'normal #f 'smoothed #f 'aligned))
 (send dc set-initial-matrix (vector 1 0 0 1 0 0))
 (for ((i 10))
   (draw-text dc (/ i 10.0))
   (send dc translate 50 0)))

(define frame (new frame% (label Test draw-text)))

(define canvas
 (new canvas%
  (parent frame)
  (min-width 500)
  (min-height 100)
  (paint-callback draw-screen)))

(send frame show #t)


--
[image/png draw-text2-unaligned.png] [~/Desktop  open] [~/Temp  open]
.


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


[racket-dev] draw-text always pixel aligned?

2013-12-15 Thread David Vanderson

Hello,

It seems that draw-text always pixel-aligns its text. In the example 
below, I draw a black hello on top of a red one, with a pixel offset 
of 0, 0.1, 0.2, . . . 0.9. At least for me, I see no change until 0.5, 
where the black text jumps a whole pixel (see attached image).


Am I missing something? Do others see this behavior?  (I'm on Linux)

Thanks,
Dave


#lang racket/gui

(define (draw-text dc offset)
  (send dc set-text-foreground red)
  (send dc draw-text hello 0 0 #t)
  (send dc set-text-foreground black)
  (send dc draw-text hello offset offset #t))

(define (draw-screen canvas dc)
  (send dc set-smoothing 'smoothed)
  (send dc set-font
(send the-font-list find-or-create-font
  12 'default 'normal 'normal #f 'smoothed #f 'aligned))
  (send dc set-initial-matrix (vector 1 0 0 1 0 0))
  (for ((i 10))
(draw-text dc (/ i 10.0))
(send dc translate 50 0)))

(define frame (new frame% (label Test draw-text)))

(define canvas
  (new canvas%
   (parent frame)
   (min-width 500)
   (min-height 100)
   (paint-callback draw-screen)))

(send frame show #t)
attachment: draw-text2.png_
  Racket Developers list:
  http://lists.racket-lang.org/dev


Re: [racket-dev] draw-text sensitive to scale when first called

2013-12-07 Thread David Vanderson

Amazing - thank you!

On 12/06/2013 01:17 PM, Matthew Flatt wrote:

I've pushed a repair. Thanks for the report!

At Thu, 05 Dec 2013 16:08:45 -0500, David Vanderson wrote:

Hello,

I'm seeing that if the first draw-text on a canvas is at a small scale
(0.1), then later draw-text calls at larger scales (1) show strange
character spacing (see attached image).

This can be worked around by passing #t as the combine? argument to
draw-text, but it seems some state is being shared between draw-text calls.

Does this happen for others? (I'm on Linux)

Thanks,
Dave


#lang racket/gui

(define (draw-screen canvas dc)

(define t (send dc get-transformation))
(send dc scale 0.1 0.1)

(send dc draw-text small 1000 1000)

(send dc set-transformation t)

(define t2 (send dc get-transformation))
(send dc translate (+ (/ 500 2)) (/ 500 2))
(send dc scale 1 1)
(send dc draw-text 0.0.0.0 0 0 #f)  ; change #f to #t to fix
(send dc set-transformation t2))


(define frame (new (class frame% (super-new))
 (label Test draw-text when scaled)))

(define canvas
(new canvas%
 (parent frame)
 (min-width 500)
 (min-height 500)
 (paint-callback draw-screen)
 (style '(no-autoclear

(send frame show #t)

;(send (send canvas get-dc) draw-text  0 0)  ; or uncomment to fix

--
[image/png draw-text.png] [~/Desktop  open] [~/Temp  open]
.
_
   Racket Developers list:
   http://lists.racket-lang.org/dev


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


[racket-dev] draw-text sensitive to scale when first called

2013-12-05 Thread David Vanderson

Hello,

I'm seeing that if the first draw-text on a canvas is at a small scale 
(0.1), then later draw-text calls at larger scales (1) show strange 
character spacing (see attached image).


This can be worked around by passing #t as the combine? argument to 
draw-text, but it seems some state is being shared between draw-text calls.


Does this happen for others? (I'm on Linux)

Thanks,
Dave


#lang racket/gui

(define (draw-screen canvas dc)

  (define t (send dc get-transformation))
  (send dc scale 0.1 0.1)

  (send dc draw-text small 1000 1000)

  (send dc set-transformation t)

  (define t2 (send dc get-transformation))
  (send dc translate (+ (/ 500 2)) (/ 500 2))
  (send dc scale 1 1)
  (send dc draw-text 0.0.0.0 0 0 #f)  ; change #f to #t to fix
  (send dc set-transformation t2))


(define frame (new (class frame% (super-new))
   (label Test draw-text when scaled)))

(define canvas
  (new canvas%
   (parent frame)
   (min-width 500)
   (min-height 500)
   (paint-callback draw-screen)
   (style '(no-autoclear

(send frame show #t)

;(send (send canvas get-dc) draw-text  0 0)  ; or uncomment to fix
attachment: draw-text.png_
  Racket Developers list:
  http://lists.racket-lang.org/dev


Re: [racket-dev] Racket Guide chapter on concurrency

2013-10-07 Thread David Vanderson
This is fantastic!  Thank you!  I learned a good deal reading it just 
now.  Comments below:


On 10/06/2013 04:30 PM, David T. Pierson wrote:

1) Should it be broken into separate pages?

I'd leave it as a single page for now.  Easier to update.

2) It starts out with the basics of threads.  Is this too trivial to cover?

Please keep that part.  It gives the reader confidence.

3) There are lots of ways to synchronize Racket threads.  I try to cover them
broadly, but don't really delve into which ones are best.  Parts seem like
they are just restating information from the reference.  Should there be more
prescriptive text?
I think the text you have is good already.  The Guide and Reference are 
going to repeat some information, which is good.  Your page offers a 
quick overview, which is perfect for the Guide.  It would be nice to 
have a prescriptive sentence for each feature giving some guidance on 
when to use which, but I don't have the experience to write those.

4) Some of the examples feel clumsy.  Contriving concurrency examples
that are both simple and meaningful was hard.  I'm not sure I succeeded.

They are better than nothing!

make-arithmetic-thread is missing a (let loop () line.  Later in the 
same example (match should be (match item.


In the channel example, could you have the worker threads return some 
text when they are done?  It makes running the example clearer.  I don't 
understand the note below this example about the lack of 
synchronization.  I don't see how that can happen, can you explain it to me?


Even after reading the reference on wrap-evt and handle-evt, I don't 
understand when I would use wrap-evt.  It seems like handle-evt is 
better?  For the guide, I suggest cutting the wrap-evt example, and only 
show handle-evt.


Thanks,
Dave

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


Re: [racket-dev] call-with-limits memory bound isn't actually bounding memory usage

2013-09-09 Thread David Vanderson
I don't know if I understand.  It sounds like you want to the limit the 
total memory allocated during the dynamic extent of the function 
called.  I don't know of functionality that does that.


The limit is on the total amount of memory reachable only from within 
the function.  Without knowing more, I would recommend to change the 
function from modifying global data structures directly, to returning 
whatever data it is generating.  That way the limit will apply.


Does that make sense?

Thanks,
Dave

On 09/09/2013 02:01 PM, J. Ian Johnson wrote:

Ah, that would probably be the problem. Without having to modify too much code, 
would the proper way to call a function entirely within the sandbox be to use 
dynamic-require in the thunk, rather than require in the module using 
call-with-limits?
-Ian
- Original Message -
From: David Vanderson david.vander...@gmail.com
To: J. Ian Johnson i...@ccs.neu.edu
Cc: dev dev@racket-lang.org
Sent: Monday, September 9, 2013 1:50:13 PM GMT -05:00 US/Canada Eastern
Subject: Re: [racket-dev] call-with-limits memory bound isn't actually bounding 
memory usage

Just to make sure, is the memory being allocated reachable from outside
the sandbox?

http://www.cs.utah.edu/plt/publications/ismm04-addendum.txt

On 09/09/2013 01:29 PM, J. Ian Johnson wrote:

I don't use the gui framework at all. This is all just pounding on global 
hash-tables and vectors. Or are you talking about the sandbox queuing up 
callbacks?
-Ian
- Original Message -
From: Robby Findler ro...@eecs.northwestern.edu
To: J. Ian Johnson i...@ccs.neu.edu
Cc: dev dev@racket-lang.org
Sent: Monday, September 9, 2013 1:16:51 PM GMT -05:00 US/Canada Eastern
Subject: Re: [racket-dev] call-with-limits memory bound isn't actually bounding 
memory usage


The framework will, sometimes do stuff that queues callbacks and, depending on 
how you've set up other things, the code running there might escape from the 
limit. Did you try putting the eventspace under the limit too?

Robby



On Mon, Sep 9, 2013 at 10:54 AM, J. Ian Johnson  i...@ccs.neu.edu  wrote:


I'm running my analysis benchmarks in the context of (with-limits (* 30 60) 2048 
run-analysis), and it's been good at killing the process when the run should 
time out, but now I have an instantiation of the framework that just gobbles up 15GiB 
of memory without getting killed. What might be going on here?

Running 5.90.0.9
-Ian
_
Racket Developers list:
http://lists.racket-lang.org/dev

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





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


Re: [racket-dev] call-with-limits memory bound isn't actually bounding memory usage

2013-09-09 Thread David Vanderson
Just to make sure, is the memory being allocated reachable from outside 
the sandbox?


http://www.cs.utah.edu/plt/publications/ismm04-addendum.txt

On 09/09/2013 01:29 PM, J. Ian Johnson wrote:

I don't use the gui framework at all. This is all just pounding on global 
hash-tables and vectors. Or are you talking about the sandbox queuing up 
callbacks?
-Ian
- Original Message -
From: Robby Findler ro...@eecs.northwestern.edu
To: J. Ian Johnson i...@ccs.neu.edu
Cc: dev dev@racket-lang.org
Sent: Monday, September 9, 2013 1:16:51 PM GMT -05:00 US/Canada Eastern
Subject: Re: [racket-dev] call-with-limits memory bound isn't actually bounding 
memory usage


The framework will, sometimes do stuff that queues callbacks and, depending on 
how you've set up other things, the code running there might escape from the 
limit. Did you try putting the eventspace under the limit too?

Robby



On Mon, Sep 9, 2013 at 10:54 AM, J. Ian Johnson  i...@ccs.neu.edu  wrote:


I'm running my analysis benchmarks in the context of (with-limits (* 30 60) 2048 
run-analysis), and it's been good at killing the process when the run should 
time out, but now I have an instantiation of the framework that just gobbles up 15GiB 
of memory without getting killed. What might be going on here?

Running 5.90.0.9
-Ian
_
Racket Developers list:
http://lists.racket-lang.org/dev

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



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


Re: [racket-dev] tests not being run?

2013-09-06 Thread David Vanderson
Ah - thank you!  I think I finally understand how this works.  To make 
sure, I query the props like this:


~/apps/racket$ ./pkgs/plt-services/meta/props get drdr:command-line 
pkgs/racket-pkgs/racket-test/tests/run-automated-tests.rkt

mzc -k ~s

This tells DrDr to make sure the file compiles without error, but don't run.

~/apps/racket$ ./pkgs/plt-services/meta/props get drdr:command-line 
pkgs/racket-pkgs/racket-test/tests/file/main.rkt



This is empty, telling DrDr to not do anything with this file - no 
compilation, no running, no reporting.


~/apps/racket$ ./pkgs/plt-services/meta/props get drdr:command-line 
pkgs/racket-pkgs/racket-test/tests/file/sha1.rkt
props: no `drdr:command-line' property for 
pkgs/racket-pkgs/racket-test/tests/file/sha1.rkt


This tells DrDr to do the default action, which is raco test ~s.


Is this correct?

Thanks,
Dave


On 09/05/2013 08:40 AM, Jay McCarthy wrote:
On Wed, Sep 4, 2013 at 1:55 PM, David Vanderson 
david.vander...@gmail.com mailto:david.vander...@gmail.com wrote:


I totally missed
pkgs/racket-pkgs/racket-test/tests/run-automated-tests.rkt, but it
looks like DrDr is running that with 'mzc -k _' - doesn't that
just compile it?


Yes, the intention there is to run the tests individually but test 
that the all runner works



There is also a file/main.rkt that runs all the file/ tests, but
that file doesn't show up in DrDr.


That means that it is disabled, probably because it was intended to 
just run each file separately



I'm more confused now.  Does DrDr automatically run a main.rkt
file if it's present?


Whether DrDr runs a file is different on a file-by-file basis via the 
props database. For this file...



Thanks,
Dave

On 09/04/2013 01:58 PM, Robby Findler wrote:

I think it makes more sense to change those 'main' modules into
'test' modules, but I'm not positive.

Robby


On Wed, Sep 4, 2013 at 12:26 PM, David Vanderson
david.vander...@gmail.com mailto:david.vander...@gmail.com wrote:

It looks to me like most of the tests in
racket/pkgs/racket-pkgs/racket-test/tests/file/* are not
being run by DrDr.  I think DrDr is running them with 'raco
test _' while the files mostly need to be run as 'racket _'.

Am I missing something?  If not, should I fix the files to be
run with 'raco test _'?

Thanks,
Dave
_
 Racket Developers list:
http://lists.racket-lang.org/dev





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




--
Jay McCarthy j...@cs.byu.edu mailto:j...@cs.byu.edu
Assistant Professor / Brigham Young University
http://faculty.cs.byu.edu/~jay http://faculty.cs.byu.edu/%7Ejay

The glory of God is Intelligence - DC 93


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


Re: [racket-dev] hex decoding?

2013-09-04 Thread David Vanderson
Sorry it took so long, but I've submitted a pull request to make this 
function public in file/sha1:


https://github.com/plt/racket/pull/426

Let me know if I screwed up, it's my first pull request.

Thanks,
Dave

On 06/11/2013 05:11 PM, Robby Findler wrote:

Yes, I think file/sha1 is the right place.

Thanks!

Robby


On Tue, Jun 11, 2013 at 3:26 PM, David Vanderson 
david.vander...@gmail.com mailto:david.vander...@gmail.com wrote:


Thank you Stephen and Tony for your examples.  I found the
following private function in db/private/mysql/connection.rkt:

(define (hex-string-bytes s)
  (define (hex-digit-int c)
(let ([c (char-integer c)])
  (cond [(= (char-integer #\0) c (char-integer #\9))
 (- c (char-integer #\0))]
[(= (char-integer #\a) c (char-integer #\f))
 (+ 10 (- c (char-integer #\a)))]
[(= (char-integer #\A) c (char-integer #\F))
 (+ 10 (- c (char-integer #\A)))])))
  (unless (and (string? s) (even? (string-length s))
   (regexp-match? #rx[0-9a-zA-Z]* s))
(raise-type-error 'hex-string-bytes
  string containing an even number of
hexadecimal digits s))
  (let* ([c (quotient (string-length s) 2)]
 [b (make-bytes c)])
(for ([i (in-range c)])
  (let ([high (hex-digit-int (string-ref s (+ i i)))]
[low  (hex-digit-int (string-ref s (+ i i 1)))])
(bytes-set! b i (+ (arithmetic-shift high 4) low
b))


Can this function be exported?  I'm willing to make a patch with
docs and tests - is file/sha1 the right place?


Thanks,
Dave

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




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


[racket-dev] tests not being run?

2013-09-04 Thread David Vanderson
It looks to me like most of the tests in 
racket/pkgs/racket-pkgs/racket-test/tests/file/* are not being run by 
DrDr.  I think DrDr is running them with 'raco test _' while the files 
mostly need to be run as 'racket _'.


Am I missing something?  If not, should I fix the files to be run with 
'raco test _'?


Thanks,
Dave
_
 Racket Developers list:
 http://lists.racket-lang.org/dev


Re: [racket-dev] tests not being run?

2013-09-04 Thread David Vanderson
I totally missed 
pkgs/racket-pkgs/racket-test/tests/run-automated-tests.rkt, but it looks 
like DrDr is running that with 'mzc -k _' - doesn't that just compile it?


There is also a file/main.rkt that runs all the file/ tests, but that 
file doesn't show up in DrDr.


I'm more confused now.  Does DrDr automatically run a main.rkt file if 
it's present?


Thanks,
Dave

On 09/04/2013 01:58 PM, Robby Findler wrote:
I think it makes more sense to change those 'main' modules into 'test' 
modules, but I'm not positive.


Robby


On Wed, Sep 4, 2013 at 12:26 PM, David Vanderson 
david.vander...@gmail.com mailto:david.vander...@gmail.com wrote:


It looks to me like most of the tests in
racket/pkgs/racket-pkgs/racket-test/tests/file/* are not being run
by DrDr.  I think DrDr is running them with 'raco test _' while
the files mostly need to be run as 'racket _'.

Am I missing something?  If not, should I fix the files to be run
with 'raco test _'?

Thanks,
Dave
_
 Racket Developers list:
http://lists.racket-lang.org/dev




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


Re: [racket-dev] hex decoding?

2013-06-11 Thread David Vanderson
Thank you Stephen and Tony for your examples.  I found the following 
private function in db/private/mysql/connection.rkt:


(define (hex-string-bytes s)
  (define (hex-digit-int c)
(let ([c (char-integer c)])
  (cond [(= (char-integer #\0) c (char-integer #\9))
 (- c (char-integer #\0))]
[(= (char-integer #\a) c (char-integer #\f))
 (+ 10 (- c (char-integer #\a)))]
[(= (char-integer #\A) c (char-integer #\F))
 (+ 10 (- c (char-integer #\A)))])))
  (unless (and (string? s) (even? (string-length s))
   (regexp-match? #rx[0-9a-zA-Z]* s))
(raise-type-error 'hex-string-bytes
  string containing an even number of hexadecimal 
digits s))

  (let* ([c (quotient (string-length s) 2)]
 [b (make-bytes c)])
(for ([i (in-range c)])
  (let ([high (hex-digit-int (string-ref s (+ i i)))]
[low  (hex-digit-int (string-ref s (+ i i 1)))])
(bytes-set! b i (+ (arithmetic-shift high 4) low
b))


Can this function be exported?  I'm willing to make a patch with docs 
and tests - is file/sha1 the right place?


Thanks,
Dave

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


Re: [racket-dev] hex decoding?

2013-06-11 Thread David Vanderson

On 06/11/2013 04:33 PM, Matthias Felleisen wrote:


  db/private/mysql/connection.rkt does not export the function, otherwise you 
could.
I don't understand this.  I'd like to make the function available to 
users somewhere - are you saying that's bad?



On Jun 11, 2013, at 4:26 PM, David Vanderson wrote:


Thank you Stephen and Tony for your examples.  I found the following private 
function in db/private/mysql/connection.rkt:

(define (hex-string-bytes s)
  (define (hex-digit-int c)
(let ([c (char-integer c)])
  (cond [(= (char-integer #\0) c (char-integer #\9))
 (- c (char-integer #\0))]
[(= (char-integer #\a) c (char-integer #\f))
 (+ 10 (- c (char-integer #\a)))]
[(= (char-integer #\A) c (char-integer #\F))
 (+ 10 (- c (char-integer #\A)))])))
  (unless (and (string? s) (even? (string-length s))
   (regexp-match? #rx[0-9a-zA-Z]* s))
(raise-type-error 'hex-string-bytes
  string containing an even number of hexadecimal digits 
s))
  (let* ([c (quotient (string-length s) 2)]
 [b (make-bytes c)])
(for ([i (in-range c)])
  (let ([high (hex-digit-int (string-ref s (+ i i)))]
[low  (hex-digit-int (string-ref s (+ i i 1)))])
(bytes-set! b i (+ (arithmetic-shift high 4) low
b))


Can this function be exported?  I'm willing to make a patch with docs and tests 
- is file/sha1 the right place?

Thanks,
Dave

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




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


[racket-dev] hex decoding?

2013-06-09 Thread David Vanderson
I'm doing some cryptography exercises that involve a lot of hex 
encoding/decoding.  I see there's a bytes-hex-string function in 
file/sha1 and openssl/sha1, but I can't find a decode function.


Is a hex decode function in the distribution?

Thanks,
Dave
_
 Racket Developers list:
 http://lists.racket-lang.org/dev


Re: [racket-dev] URL escaping: question for web experts

2012-12-17 Thread David Vanderson
No guru here, but my experience has been that every url encoder is 
slightly different - I don't think there's a broad consensus on edge 
cases.  I'd say go for it.


On 12/17/2012 06:59 AM, Eli Barzilay wrote:

For many people there is a constant source of annoyance when you
copy+paste doc URLs into a markdown context as with stackoverflow and
others.  The problem is that these URLs have parens in them and at
least in Chrome, the copied URL still has them -- and because markdown
texts use parens for URLs [text](url) they get confused which means
that you have to manually replace parens with %28 and %29.

Danny submitted a pull request that eventually got changed by Matthew
into a new parameter that controls which characters get encoded by
`net/uri-codec', so it can escape these too.  The result on Chrome is
that the copied URL has the escapes instead of parens, and clicking
such a URL makes the copy-able address have the escapes too.  The
actuall page that is displayed is still the same one, of course, it's
just weird that Chrome has a certain context where the original URL
string is preserved as is.  (It even considered the escaped URL as one
that I didn't visit, even though I visited the one with the unescaped
parens.)

In any case, given all of this I thought that maybe the default mode
could do the extra escaping -- it seems to me that there is no damage
with doing that, since in theory every character could be escaped
anyway.  There's a minor overhead of a few extra characters, but
there's the above benefit of doing it (which might be a temporary
thing for all I know).

Neither Matthew nor I feel confident enough to have this encoding be
the default without consulting some potential web standard gurus.

So?



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


Re: [racket-dev] planet2 and versions

2012-12-12 Thread David Vanderson
I was professionally writing Ruby code as that community struggled 
through package issues.  I hope that experience can shed some light 
here.  Also I'd like to understand the basic use cases and how they work 
in planet2.


As a user, here are my 2 use cases:

1. My friend tells me about awesome library X, and I want to install it 
and use it.  Planet2 makes this easy.


2. I have an existing app running and I want to replicate it exactly 
somewhere else (including libraries).  I'm not sure this is possible 
with raw Planet2.  The Ruby community finally dealt with this by saving 
the full library dependency list in a file (bundle, with version 
numbers) that you save alongside your app.  It works fairly well.


Their experience suggests that accidental backwards incompatible changes 
in libraries happen frequently enough to need some kind of support for.  
Compatibility with the core language was not supported.  Either a 
library's webpage would say requires ruby core = 1.8.x, or sometimes 
importing the library would produce an error message telling you the same.


Do these use cases make sense?  (I'd like to hear about library 
developer use cases, but I have no experience there)


Thanks,
Dave
_
 Racket Developers list:
 http://lists.racket-lang.org/dev


[racket-dev] tiny doc bug?

2012-12-01 Thread David Vanderson

http://docs.racket-lang.org/data/Orders_and_Ordered_Dictionaries.html

Towards the bottom of this page there is the following error:

 (datum-order (make-fish 'alewife) (make-fish 'sockeye))
make-fish: undefined;
 cannot reference undefined identifier

Is this intentional?

Thanks,
Dave
_
 Racket Developers list:
 http://lists.racket-lang.org/dev


Re: [racket-dev] `racket/string' extensions

2012-04-19 Thread David Vanderson
Thank you so much for this.  This was definitely one area of difficulty 
when I started using Racket for scripting.


On 04/19/2012 09:28 AM, Eli Barzilay wrote:

But to allow other uses, make these arguments a string *or* a regexp,
where a regexp is taken as-is.  This leads to another simplicity point
in this design:


This is fantastic.

   (string-split str [sep #px\\s+])
 Splits `str' on occurrences of `sep'.  Unclear whether it should
 do that with or without trimming, which affects keeping a
 first/last empty part.  [*1*] Possible solution: make it take a
 `#:trim?' keyword, in analogy to `string-normalize-spaces'.  This
 would make `#t' the obvious choice for a default, which means that
   (string-split ,,foo, bar, ,) -  '(foo  bar)
I like the #:trim? keyword, but I would suggest defaulting to #f.  Many 
of my uses of string-split would be doing simple parsing of delimited 
input, and it seems to me that trimming by default would be non-obvious.

   (string-index str sub [start 0] [end (string-length str)])
 Looks for occurrences of `sub' in `str', returns the index if
 found, #f otherwise.  [*2*] I'm not sure about the name, maybe
 `string-index-of' is better?

Either sounds fine, so I'd go with string-index just because it's shorter.

   (list-index list elt)
 Looks for `elt' in `list'.  This is a possible extension for
 `racket/list' that would be kind of obvious with adding the above.
 [*3*] I'm not sure if it should be added, but IIRC it was
 requested a few times.  If it does get added, then there's another
 question for how far the analogy goes: [*3a*] Should it take a
 start/end index too?  [*3b*] Should it take a list of elements and
 look for a matching sublist instead (which is not a function that
 is common to ask for, AFAICT)?


How do people do this now?


Thanks,
Dave
_
 Racket Developers list:
 http://lists.racket-lang.org/dev


Re: [racket-dev] [PATCH] add in-slice sequence

2011-12-15 Thread David Vanderson
I only got one comment (thanks John), so I'm resending for more 
feedback.  Is there any interest in adding this, or does everybody do it 
a better/different way?



A more motivated example would be showing a list of products on a 
webpage in batches:


(define products '(a b c d e f g))
(for/list ([s (in-slice 3 products)])
  `(ul ,@(for/list ([e s])
`(li ,e

Thanks,
Dave

On 12/09/2011 02:46 AM, David Vanderson wrote:

Hello,

I was trying to write some code to process a few items at a time from 
a list.  Nothing I came up with looked great, so I wrote an in-slice 
sequence function:


 (for/list ([e (in-slice 3 (in-range 8))]) e)
'((0 1 2) (3 4 5) (6 7))

Patch below.  Comments?

Thanks,
Dave



diff --git a/collects/racket/private/for.rkt 
b/collects/racket/private/for.rkt

index 88733ca..9e032fa 100644
--- a/collects/racket/private/for.rkt
+++ b/collects/racket/private/for.rkt
@@ -51,6 +51,7 @@

  in-sequences
  in-cycle
+ in-slice
  in-parallel
  in-values-sequence
  in-values*-sequence
@@ -984,10 +985,30 @@
 (if (and (pair? sequences) (null? (cdr sequences)))
 (car sequences)
 (append-sequences sequences #f)))
+
   (define (in-cycle . sequences)
 (check-sequences 'in-cycle sequences)
 (append-sequences sequences #t))

+  (define (in-slice k seq)
+(when (not (exact-positive-integer? k))
+  (raise (exn:fail:contract in-slice length must be a positive 
integer

+  (current-continuation-marks
+(check-sequences 'in-slice (list seq))
+(make-do-sequence
+ (lambda ()
+   (define-values (more? get) (sequence-generate seq))
+   (values
+(lambda (_)
+  (for/list ((i k)
+ #:when (more?))
+(get)))
+values
+#f
+#f
+(lambda (val) (0 .  . (length val)))
+#f
+
   (define (in-parallel . sequences)
 (check-sequences 'in-parallel sequences)
 (if (= 1 (length sequences))
diff --git a/collects/scribblings/reference/sequences.scrbl 
b/collects/scribblings/reference/sequences.scrbl

index d3ecdfb..6192761 100644
--- a/collects/scribblings/reference/sequences.scrbl
+++ b/collects/scribblings/reference/sequences.scrbl
@@ -298,6 +298,16 @@ in the sequence.
   demanded---or even when the sequence is @tech{initiate}d, if all
   @racket[seq]s are initially empty.}

+@defproc[(in-slice [length exact-positive-integer?] [seq sequence?]) 
sequence?]{
+  Returns a sequence where each element is a list with 
@racket[length] elements

+  from the given sequence.
+
+  @examples[
+  (for/list ([e (in-slice 3 (in-range 8))]) e)
+  ]
+
+  }
+
 @defproc[(in-parallel [seq sequence?] ...) sequence?]{
   Returns a sequence where each element has as many values as the number
   of supplied @racket[seq]s; the values, in order, are the values of
diff --git a/collects/tests/racket/for.rktl 
b/collects/tests/racket/for.rktl

index 691e309..6c883b8 100644
--- a/collects/tests/racket/for.rktl
+++ b/collects/tests/racket/for.rktl
@@ -84,6 +84,15 @@
 (test #t sequence? (in-cycle))
 (test #t sequence? (in-cycle '()))

+(test #t sequence? (in-slice 1 '()))
+(test '() 'empty-seq (for/list ([v (in-slice 1 '())]) v))
+(test '((0 1)) 'single-slice (for/list ([v (in-slice 3 (in-range 
2))]) v))

+(test-sequence [((0 1 2) (3 4 5))] (in-slice 3 (in-range 6)))
+(test-sequence [((0 1 2) (3 4 5) (6 7))] (in-slice 3 (in-range 8)))
+(test-sequence [((0 1 2) (3 4 5) (6 7 8)) (0 1 2)]
+(in-parallel (in-slice 3 (in-naturals)) (in-range 3)))
+(err/rt-test (for/list ([x (in-slice 0 (in-range 8))]) x) 
exn:fail:contract?)

+
 (test-sequence [(0 1 2) (a b c)] (in-parallel (in-range 3) (in-list 
'(a b c
 (test-sequence [(0 1 2) (a b c)] (in-parallel (in-range 10) (in-list 
'(a b c
 (test-sequence [(0 1 2) (a b c)] (in-parallel (in-range 3) (in-list 
'(a b c d



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


[racket-dev] doc bug - syntax-id-rules

2011-12-08 Thread David Vanderson

I think the docs for syntax-id-rules have 2 lines swapped.  Here's a patch:

diff --git a/collects/scribblings/reference/stx-patterns.scrbl 
b/collects/scribblings/reference/stx-patterns.scrbl

index 83d13bc..209961b 100644
--- a/collects/scribblings/reference/stx-patterns.scrbl
+++ b/collects/scribblings/reference/stx-patterns.scrbl
@@ -459,8 +459,8 @@ corresponding @racket[template].}
 Equivalent to

 @racketblock[
-(lambda (stx)
-  (make-set!-transformer
+(make-set!-transformer
+ (lambda (stx)
(syntax-case stx (literal-id ...)
  [pattern (syntax-protect (syntax template))] ...)))
 ]}


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


[racket-dev] [PATCH] add in-slice sequence

2011-12-08 Thread David Vanderson

Hello,

I was trying to write some code to process a few items at a time from a 
list.  Nothing I came up with looked great, so I wrote an in-slice 
sequence function:


 (for/list ([e (in-slice 3 (in-range 8))]) e)
'((0 1 2) (3 4 5) (6 7))

Patch below.  Comments?

Thanks,
Dave



diff --git a/collects/racket/private/for.rkt 
b/collects/racket/private/for.rkt

index 88733ca..9e032fa 100644
--- a/collects/racket/private/for.rkt
+++ b/collects/racket/private/for.rkt
@@ -51,6 +51,7 @@

  in-sequences
  in-cycle
+ in-slice
  in-parallel
  in-values-sequence
  in-values*-sequence
@@ -984,10 +985,30 @@
 (if (and (pair? sequences) (null? (cdr sequences)))
 (car sequences)
 (append-sequences sequences #f)))
+
   (define (in-cycle . sequences)
 (check-sequences 'in-cycle sequences)
 (append-sequences sequences #t))

+  (define (in-slice k seq)
+(when (not (exact-positive-integer? k))
+  (raise (exn:fail:contract in-slice length must be a positive 
integer

+  (current-continuation-marks
+(check-sequences 'in-slice (list seq))
+(make-do-sequence
+ (lambda ()
+   (define-values (more? get) (sequence-generate seq))
+   (values
+(lambda (_)
+  (for/list ((i k)
+ #:when (more?))
+(get)))
+values
+#f
+#f
+(lambda (val) (0 .  . (length val)))
+#f
+
   (define (in-parallel . sequences)
 (check-sequences 'in-parallel sequences)
 (if (= 1 (length sequences))
diff --git a/collects/scribblings/reference/sequences.scrbl 
b/collects/scribblings/reference/sequences.scrbl

index d3ecdfb..6192761 100644
--- a/collects/scribblings/reference/sequences.scrbl
+++ b/collects/scribblings/reference/sequences.scrbl
@@ -298,6 +298,16 @@ in the sequence.
   demanded---or even when the sequence is @tech{initiate}d, if all
   @racket[seq]s are initially empty.}

+@defproc[(in-slice [length exact-positive-integer?] [seq sequence?]) 
sequence?]{
+  Returns a sequence where each element is a list with @racket[length] 
elements

+  from the given sequence.
+
+  @examples[
+  (for/list ([e (in-slice 3 (in-range 8))]) e)
+  ]
+
+  }
+
 @defproc[(in-parallel [seq sequence?] ...) sequence?]{
   Returns a sequence where each element has as many values as the number
   of supplied @racket[seq]s; the values, in order, are the values of
diff --git a/collects/tests/racket/for.rktl b/collects/tests/racket/for.rktl
index 691e309..6c883b8 100644
--- a/collects/tests/racket/for.rktl
+++ b/collects/tests/racket/for.rktl
@@ -84,6 +84,15 @@
 (test #t sequence? (in-cycle))
 (test #t sequence? (in-cycle '()))

+(test #t sequence? (in-slice 1 '()))
+(test '() 'empty-seq (for/list ([v (in-slice 1 '())]) v))
+(test '((0 1)) 'single-slice (for/list ([v (in-slice 3 (in-range 2))]) v))
+(test-sequence [((0 1 2) (3 4 5))] (in-slice 3 (in-range 6)))
+(test-sequence [((0 1 2) (3 4 5) (6 7))] (in-slice 3 (in-range 8)))
+(test-sequence [((0 1 2) (3 4 5) (6 7 8)) (0 1 2)]
+(in-parallel (in-slice 3 (in-naturals)) (in-range 3)))
+(err/rt-test (for/list ([x (in-slice 0 (in-range 8))]) x) 
exn:fail:contract?)

+
 (test-sequence [(0 1 2) (a b c)] (in-parallel (in-range 3) (in-list 
'(a b c
 (test-sequence [(0 1 2) (a b c)] (in-parallel (in-range 10) (in-list 
'(a b c
 (test-sequence [(0 1 2) (a b c)] (in-parallel (in-range 3) (in-list 
'(a b c d


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


[racket-dev] failed bug report

2011-06-01 Thread David Vanderson

Thanks for Racket!

I tried to send a bug report via drracket, but got this error:

An error occurred when submitting your Racket bug report.

Please enter the correct text at the bottom of the bug form.

If this problem persists, please send email to the Racket mailing list, 
or to rac...@racket-lang.org.




Here's the bug report
(Racket 5.1.1 precompiled x86_64 on Ubuntu 10.10)
environment: unix Linux dvanderson-XPS-L501X 2.6.35-29-generic 
#51+kamal~mjgbacklight4-Ubuntu SMP Mon Apr 18 19:32:49 UTC 2011 x86_64 
GNU/Linux (x86_64-linux/3m) (get-display-depth) = 32


save file dialog with multiple file ext filters doesn't show any 
existing files


severity: non-critical

(on Ubuntu 10.10 x64)

When saving a file, the save dialog has a filter of Racket Sources 
(*.rkt;*.scrbl;*.ss;*.scm), but it doesn't show any .rkt files.


Looking at collects/framework/private/finder.rkt , I'm guessing that a 
list of filters isn't supported.  If someone can point me in the right 
direction I'll take a crack at it.


- load drracket
- type anything in the definitions window
- click save
- navigate to a directory with .rkt files
- .rkt file aren't shown unless the filter is changed to Any


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


Re: [racket-dev] racket vs. scheme vs. clojure (as it appears to others)

2011-04-29 Thread David Vanderson

What's the benefit of using regexp-match instead of port-string ?

Thanks,
Dave

On 04/29/2011 07:23 AM, John Clements wrote:

This is just one random guy, but it's interesting to see how Racket is 
perceived.

Excerpts from a conversation on stackoverflow about Racket:

Thanks. And that's why I'm starting to learn to dislike Scheme, despite 
everything else. – MCXXIII yesterday

In that case, it's a good thing that Racket isn't Scheme. – John Clements 20 
hours ago

I don't know if I'd like to turn to some fringe language. Also seems odd to 
me to call it a Scheme implementation if it's not meant to be Scheme at all. I really 
like standards and Scheme seems to suffer greatly in that area. I think I may have to 
switch to some other form of Lisp. Clojure seems potentially nice at a glance. – MCXXIII 
20 hours ago

Ah! You said the magic word! Clojure is a LISP implementation in a very similar 
way that Racket is a Scheme implementation. Put differently: if you don't 
object to Clojure, there's no good reason to object to Racket. – John Clements 
13 hours ago

Racket comes off as Scheme, but not really while Clojure comes off as Clojure (inspired by 
Lisp). At least that's the impression. It's kinda like how Java was inspired by C/C++ yet Java is Java. 
Also, I could go learn INTERCAL too. It wouldn't be very useful aside from the pure experience, and maybe 
with INTERCAL that experience would be worth it, but in the case of Racket I might as well get that exact 
same experience from something more mainstream. So, if my objective is to learn some form of 
Lisp, I'd go with one of the three major dialects, not Racket. – MCXXIII 5 hours ago

Thanks for your thoughtful reply. Obviously, Racket is still working to define 
itself as a separate entity. – John Clements 0 secs ago

You can see the original thread here:

http://stackoverflow.com/questions/5806222/opening-urls-with-scheme/5811345#5811345


John Clements



_
   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] weak boxes in a script

2011-03-16 Thread David Vanderson
I'm seeing a difference between when the value in a weak box is 
collected.  When I run the following interactively, the value is 
collected like I expect.  But it is not collected when running in a 
script, or in DrRacket.  This is v5.1 on Ubuntu x64, compiled from source.


Can someone explain the difference?

~$ racket
Welcome to Racket v5.1.
 (define b (make-weak-box 'not-used))
 (weak-box-value b)
'not-used
 (collect-garbage)
 (weak-box-value b)
#f


~$ cat weak-box.rkt
#lang racket

(define b (make-weak-box 'not-used))
(weak-box-value b)
(collect-garbage)
(weak-box-value b)

~$ racket weak-box.rkt
'not-used
'not-used

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


Re: [racket-dev] weak boxes in a script

2011-03-16 Thread David Vanderson

Thanks so much, that makes perfect sense.

On 03/16/2011 02:16 PM, Carl Eastlund wrote:

David,

I believe you are seeing the difference between modules and the REPL.
At the REPL, each expression is compiled, run, and discarded.  This
yields the behavior you expect.  But a #lang form produces a module,
which is compiled and kept for the rest of the session.  Thus, even
after garbage collection, the compiled form of the first term still
exists:

(define b (make-weak-box 'not-used))

Thus there is a reference to the symbol not-used, and it is not
garbage collected.

Carl Eastlund

On Wed, Mar 16, 2011 at 5:09 PM, David Vanderson
david.vander...@gmail.com  wrote:

I'm seeing a difference between when the value in a weak box is collected.
  When I run the following interactively, the value is collected like I
expect.  But it is not collected when running in a script, or in DrRacket.
  This is v5.1 on Ubuntu x64, compiled from source.

Can someone explain the difference?

~$ racket
Welcome to Racket v5.1.

(define b (make-weak-box 'not-used))
(weak-box-value b)

'not-used

(collect-garbage)
(weak-box-value b)

#f


~$ cat weak-box.rkt
#lang racket

(define b (make-weak-box 'not-used))
(weak-box-value b)
(collect-garbage)
(weak-box-value b)

~$ racket weak-box.rkt
'not-used
'not-used

Thanks,
Dave

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