Re: [racket-users] whither `splicing-parameterize`? or am I doing it wrong?

2018-01-25 Thread Alexis King
> On Jan 25, 2018, at 16:45, Robby Findler 
> wrote:
> 
> Isn't the last form already required to not be a definition?

In that example, yes, but not always, and splicing-parameterize can’t
be sure one way or the other. In this example, containing exclusively
definitions is completely legal:

(let ()
  (splicing-parameterize ([my-param #t])
(define x (my-param)))
  x)

I suppose it would be possible to force users of splicing-parameterize
to make the final body form an expression, but the other forms from
racket/splicing don’t have that restriction, so it would be a bit odd
to have different behavior here.

Alexis

-- 
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.


Re: [racket-users] whither `splicing-parameterize`? or am I doing it wrong?

2018-01-25 Thread Robby Findler
Isn't the last form already required to not be a definition?

Robby

On Thu, Jan 25, 2018 at 5:59 PM Alexis King  wrote:

> > On Jan 24, 2018, at 12:57 AM, Ryan Culpepper 
> > wrote:
> >
> > It might make sense to `(set! new-parameterization #f)` at the end so
> > that the parameterization (and the values it holds) can be GC'd sooner
> > when splicing-parameterize is used at top level or module level.
>
> The tricky thing about doing this is maintaining the evaluation result.
> If I add a (set! new-parameterization #f) to the end of
> splicing-parameterize, then this:
>
> (let ()
>   (splicing-parameterize ([my-param #t])
> 42))
>
> ...evaluates to # instead of 42. It’s theoretically possible to
> figure out if the last form is a definition or an expression, and if
> it’s the latter, insert a use of begin0, but this means the final
> expression is not called in tail position. This probably isn’t a
> problem, though, so maybe it’s still worth it?
>
> Alexis
>
> --
> 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.
>

-- 
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.


Re: [racket-users] whither `splicing-parameterize`? or am I doing it wrong?

2018-01-25 Thread Alexis King
> On Jan 24, 2018, at 12:57 AM, Ryan Culpepper 
> wrote:
> 
> It might make sense to `(set! new-parameterization #f)` at the end so
> that the parameterization (and the values it holds) can be GC'd sooner
> when splicing-parameterize is used at top level or module level.

The tricky thing about doing this is maintaining the evaluation result.
If I add a (set! new-parameterization #f) to the end of
splicing-parameterize, then this:

(let ()
  (splicing-parameterize ([my-param #t])
42))

...evaluates to # instead of 42. It’s theoretically possible to
figure out if the last form is a definition or an expression, and if
it’s the latter, insert a use of begin0, but this means the final
expression is not called in tail position. This probably isn’t a
problem, though, so maybe it’s still worth it?

Alexis

-- 
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.


Re: [racket-users] Strange window behavior in OSX Yosemite DrRacket

2018-01-25 Thread Jordan Johnson
Thanks for the suggestions, guys. Glad to hear it’s a known-and-fixed bug.

We’ll poke at it when we’re back in the lab tomorrow, and if we can’t resolve 
it I’ll follow up with another query here.

Thanks again,
jmj

> On Jan 25, 2018, at 11:42, Robby Findler  wrote:
> 
> This double contour thing is a bug that has been fixed, but the fix wasn't in 
> the last release.
> 
> If you first quit DrRacket and then open an older version of DrRacket and 
> disable the contour, then the doubled thing will go away in the new version.
> 
> Robby
> 
> 
> On Thu, Jan 25, 2018 at 11:38 AM, Philip McGrath  > wrote:
> In case it's relevant, I recently tried using text:inline-overview-mixin <> 
> for the first time in the hope that it would give me something like Program 
> Contour in DrRacket, and instead it did something very similar to the second 
> screenshot (using Racket 6.11 on Mac OS 10.13.2):
> 
> 
> ​
> 
> -Philip
> 
> On Thu, Jan 25, 2018 at 11:10 AM, 'John Clements' via Racket Users 
> > wrote:
> 
> 
> > On Jan 25, 2018, at 8:48 AM, Jordan Johnson  > > wrote:
> >
> > Hi all,
> >
> > One of my students is observing some strange behavior involving the Program 
> > Contour pane of DrRacket. He’s using v6.11 on OS X Yosemite 10.10.5.
> >
> > This is the top-right corner of his DrR window, with Program Contour open:
> > 
> >
> > Upon pressing Cmd+U to hide it, this is what happens:
> > 
> >
> > Additionally, the previous day he’d found that (with the Contour pane open) 
> > DrR was flickering while he typed, and (when I suggested closing the 
> > Contour pane to see if it was slowing down the window redraws) pressing 
> > Cmd+U or selecting the “Hide Program Contour” menu item did not hide the 
> > Contour pane.
> >
> > Any ideas of what we could do to diagnose this problem?
> 
> I believe the behavior of the contour window has changed recently, and I 
> conjecture that both mechanisms might still be implemented; would it help to 
> edit or remove the preferences file? I believe that you’ll find them in 
> ~/Library/Preferences/, and there are two:
> 
> org.racket-lang.DrRacket.plist
> org.racket-lang.prefs.rktd
> 
> I’m guessing the first is the one that would be relevant.
> 
> Just a thought,
> 
> John Clements
> 
> 
> 
> --
> 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 
> .
> 
> 
> -- 
> 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 
> .
> 

-- 
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.


Re: [racket-users] Understanding prop:impersonator-of

2018-01-25 Thread Philip McGrath
This is because `prop:impersonator-of` only applies to two instances that
inherit the property from the same structure type. (As the docs put it,
"The result value must have the same prop:impersonator-of and
prop:equal+hash property values as the original structure, if any, and the
property values must be inherited from the same structure type (which
ensures some consistency between impersonator-of? and equal?).")

The following works:

#lang racket

(struct our-impersonate-proc (f orig)
  #:property prop:impersonator-of (lambda (x) (displayln 'hi)
(our-impersonate-proc-orig x))
  #:property prop:procedure (struct-field-index f))

(let ([values (our-impersonate-proc values #f)])
  (impersonator-of?
   (our-impersonate-proc add1 values)
   values))

-Philip

On Thu, Jan 25, 2018 at 4:45 PM, Daniel Feltey <
daniel.fel...@eecs.northwestern.edu> wrote:

> I'm trying to understand the use of the prop:impersonator-of struct
> property, but the following program doesn't work the way I would have
> expected:
>
> #lang racket
>
> (struct our-impersonate-proc (f orig)
>  #:property prop:impersonator-of (lambda (x) (displayln 'hi)
> (our-impersonate-proc-orig x))
>  #:property prop:procedure (struct-field-index f))
>
> (impersonator-of?
>   (our-impersonate-proc add1 values)
>   values)
>
> The call to impersonator-of? doesn't seem to go through our
> prop:impersonator-of at all because we don't 'hi displayed when the program
> is run.
>
> Am I misunderstanding the way to use prop:impersonator-of ? I don't fully
> understand the documentation, so it's possible this isn't something that
> prop:impersonator-of is intended for.
>
> Thanks
> Dan
>
>
> --
> 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.
>

-- 
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.


[racket-users] Understanding prop:impersonator-of

2018-01-25 Thread Daniel Feltey
I'm trying to understand the use of the prop:impersonator-of struct
property, but the following program doesn't work the way I would have
expected:

#lang racket

(struct our-impersonate-proc (f orig)
 #:property prop:impersonator-of (lambda (x) (displayln 'hi)
(our-impersonate-proc-orig x))
 #:property prop:procedure (struct-field-index f))

(impersonator-of?
  (our-impersonate-proc add1 values)
  values)

The call to impersonator-of? doesn't seem to go through our
prop:impersonator-of at all because we don't 'hi displayed when the program
is run.

Am I misunderstanding the way to use prop:impersonator-of ? I don't fully
understand the documentation, so it's possible this isn't something that
prop:impersonator-of is intended for.

Thanks
Dan

-- 
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.


Re: [racket-users] A very simple #lang

2018-01-25 Thread Shu-Hung You
The explanation of the 5-argument read and 6-argument read-syntax is
here, starting from the 3rd paragraph of this subsection:
https://docs.racket-lang.org/reference/reader.html#%28part._parse-reader%29

The 5 (or 6) arguments version read accepts extra source location
information. However, this version is not exposed in the read
(read-syntax) from racket/base. As far as I know, those
read/read-syntax *might* be accessible when implementing
meta-languages using make-meta-reader. (That gives you the reader of
the underlying language).



On Thu, Jan 25, 2018 at 3:03 PM, Deren Dohoda  wrote:
> Thanks Philip, of course I should have checked for something like this
> directly.
>
> Deren
>
> On Thu, Jan 25, 2018 at 3:51 PM, Philip McGrath 
> wrote:
>>
>> You may just want to use #lang exact-decimal racket (see:
>> http://docs.racket-lang.org/exact-decimal-lang/index.html).
>>
>> I have encountered a similar problem with six arguments to read-syntax
>> before, and I remember there being a good reason that was explained in some
>> obscure corner of the documentation, but I don't remember exactly what the
>> reason was, and I'm not immediately finding it in the documentation, which
>> perhaps suggests that, whatever the reason is, it should be documented more
>> prominently.
>>
>> -Philip
>>
>> On Thu, Jan 25, 2018 at 2:21 PM, Deren Dohoda 
>> wrote:
>>>
>>> Hi everyone,
>>>
>>> I am desperately in need of a #lang exact so that decimals are read as
>>> exact values.
>>>
>>> I thought this would be extremely simple:
>>> ..\exact\lang\reader.rkt
>>>
>>> (module reader racket/base
>>>   (provide (rename-out (exact-read read)
>>>(exact-read-syntax read-syntax)))
>>>   (require (rename-in racket/base (read base:read) (read-syntax
>>> base:read-syntax)))
>>>   (define (exact-read . in)
>>> (parameterize ((read-decimal-as-inexact #f))
>>>   (apply base:read in)))
>>>   (define (exact-read-syntax . in)
>>> (parameterize ((read-decimal-as-inexact #f))
>>>   (apply base:read-syntax in
>>> ;;
>>> It installs alright, though chokes on building docs for some reason, but
>>> then when I attempt to use it:
>>> ..\exact\lang\reader.rkt:13:6: read-syntax: arity mismatch;
>>>  the expected number of arguments does not match the given number
>>>   expected: 0 to 2
>>>   given: 6
>>>   arguments...:
>>>
>>> Why is read-syntax getting six arguments?
>>>
>>> Deren
>>>
>>> --
>>> 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.
>>
>>
>
> --
> 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.

-- 
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.


Re: [racket-users] Strange window behavior in OSX Yosemite DrRacket

2018-01-25 Thread 'John Clements' via Racket Users


> On Jan 25, 2018, at 12:17 PM, Philip McGrath  wrote:
> 
> I took the steps you described and I no longer get the doubled program 
> contour, but I do get results like the screenshot of my experiment with 
> text:inline-overview-mixin I sent 
> earlier (maybe that's what the contour is supposed to look like now?). In 
> both cases, drawing the contour on top of the actual text seems to me to be 
> causing a problem: in, for example, line 219 of the following screenshot, the 
> overview covers up part of the program source, and I can't scroll to reveal 
> the covered part. In the example I sent earlier, auto-wrap is on, but 
> wrapping places text under the overview, and again it isn't possible to 
> scroll to uncover the text.
> 
> Is this the way this is supposed to work now?

To answer only this part of the question: yes, I believe this is how this is 
supposed to work. I personally prefer the new setup, but I’m not actually a 
super-frequent user of the feature, so maybe my opinion is not the most 
important one.

John Clements



-- 
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.


Re: [racket-users] A very simple #lang

2018-01-25 Thread Deren Dohoda
Thanks Philip, of course I should have checked for something like this
directly.

Deren

On Thu, Jan 25, 2018 at 3:51 PM, Philip McGrath 
wrote:

> You may just want to use #lang exact-decimal racket (see:
> http://docs.racket-lang.org/exact-decimal-lang/index.html).
>
> I have encountered a similar problem with six arguments to read-syntax
> before, and I remember there being a good reason that was explained in some
> obscure corner of the documentation, but I don't remember exactly what the
> reason was, and I'm not immediately finding it in the documentation, which
> perhaps suggests that, whatever the reason is, it should be documented more
> prominently.
>
> -Philip
>
> On Thu, Jan 25, 2018 at 2:21 PM, Deren Dohoda 
> wrote:
>
>> Hi everyone,
>>
>> I am desperately in need of a #lang exact so that decimals are read as
>> exact values.
>>
>> I thought this would be extremely simple:
>> ..\exact\lang\reader.rkt
>>
>> (module reader racket/base
>>   (provide (rename-out (exact-read read)
>>(exact-read-syntax read-syntax)))
>>   (require (rename-in racket/base (read base:read) (read-syntax
>> base:read-syntax)))
>>   (define (exact-read . in)
>> (parameterize ((read-decimal-as-inexact #f))
>>   (apply base:read in)))
>>   (define (exact-read-syntax . in)
>> (parameterize ((read-decimal-as-inexact #f))
>>   (apply base:read-syntax in​
>> ;;
>> It installs alright, though chokes on building docs for some reason, but
>> then when I attempt to use it:
>> ..\exact\lang\reader.rkt:13:6: read-syntax: arity mismatch;
>>  the expected number of arguments does not match the given number
>>   expected: 0 to 2
>>   given: 6
>>   arguments...:
>>
>> Why is read-syntax getting six arguments?
>>
>> Deren
>>
>> --
>> 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.
>>
>
>

-- 
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.


Re: [racket-users] A very simple #lang

2018-01-25 Thread Philip McGrath
You may just want to use #lang exact-decimal racket (see:
http://docs.racket-lang.org/exact-decimal-lang/index.html).

I have encountered a similar problem with six arguments to read-syntax
before, and I remember there being a good reason that was explained in some
obscure corner of the documentation, but I don't remember exactly what the
reason was, and I'm not immediately finding it in the documentation, which
perhaps suggests that, whatever the reason is, it should be documented more
prominently.

-Philip

On Thu, Jan 25, 2018 at 2:21 PM, Deren Dohoda 
wrote:

> Hi everyone,
>
> I am desperately in need of a #lang exact so that decimals are read as
> exact values.
>
> I thought this would be extremely simple:
> ..\exact\lang\reader.rkt
>
> (module reader racket/base
>   (provide (rename-out (exact-read read)
>(exact-read-syntax read-syntax)))
>   (require (rename-in racket/base (read base:read) (read-syntax
> base:read-syntax)))
>   (define (exact-read . in)
> (parameterize ((read-decimal-as-inexact #f))
>   (apply base:read in)))
>   (define (exact-read-syntax . in)
> (parameterize ((read-decimal-as-inexact #f))
>   (apply base:read-syntax in​
> ;;
> It installs alright, though chokes on building docs for some reason, but
> then when I attempt to use it:
> ..\exact\lang\reader.rkt:13:6: read-syntax: arity mismatch;
>  the expected number of arguments does not match the given number
>   expected: 0 to 2
>   given: 6
>   arguments...:
>
> Why is read-syntax getting six arguments?
>
> Deren
>
> --
> 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.
>

-- 
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.


Re: [racket-users] racket/gui and the Cocoa NSRunLoop

2018-01-25 Thread Mark Wunsch
Thanks for the response. Since writing this, I've tried to better understand 
this C code, and my understanding of the problems here might have not been 
correct. They still probably aren't correct, but I'll try to better articulate 
the challenge.
I tried all of the techniques you suggested, none of them seemed to work. With 
my limited understanding of this C GStreamer code, I think the problem area is 
in this function of the codebase: 
https://github.com/GStreamer/gst-plugins-bad/blob/8d99867c13944be9ba75a892682204955f16f586/gst-libs/gst/gl/cocoa/gstglwindow_cocoa.m#L421-L448

When initialized this code seems to create a new GCD dispatch queue:

(__bridge_retained gpointer)
  (dispatch_queue_create ("org.freedesktop.gstreamer.glwindow", NULL))

It then periodically dispatches work to this queue.

My understanding of how GCD dispatch queues work is practically nonexistent, 
but I'm under the impression that work is executed off these queues through 
some Cocoa mechanism off the main run loop, as before. Do you know how I might 
ensure that this work is executing or am I way off the mark?

Thanks.

On Mon, Jan 22, 2018, at 10:31 PM, Matthew Flatt wrote:
> Sorry for the slow response!
> 
> At Thu, 11 Jan 2018 12:56:02 -0500, Mark Wunsch wrote:
> > Yes — that's perfect, thank you! And it also gives me a better sense of how 
> > racket/gui is implemented for macOS. This snippet of code is now included 
> > in 
> > my library, and I wonder if there's benefit to having this be available in 
> > racket/gui for cross-platform usage?
> 
> The snippet seems fairly specialized to me, and I'm not sure there's a
> useful cross-platform interpretation.
> 
> > Now that I understand this a bit, I tried solving the second use-case I 
> > wrote 
> > about, using the glimagesink. My understanding of this code is that it 
> > creates 
> > a subview with a CAOpenGLLayer, and then enqueues a `setNeedsDisplay`: 
> > https://github.com/GStreamer/gst-plugins-bad/blob/8d99867c13944be9ba75a89268220
> > 4955f16f586/gst-libs/gst/gl/cocoa/gstglwindow_cocoa.m#L332-L354
> > 
> > When I run equivalent code outside of racket (e.g. through the gst-launch 
> > tool), I see that I continuously see calls to draw 
> > (https://developer.apple.com/documentation/quartzcore/caopengllayer/1522316-dra
> > w). Those calls are not being made when run from Racket.
> >
> > I realize we're venturing outside of the Realm of Racket (intentional pun)  
> > and closer to Cocoa, but I'd like to have a better sense of how to dequeue 
> > these drawing actions. Based on your previous code, I thought that I could 
> > yield to the main thread by calling `run` or `runUntilDate` on the main 
> > NSRunLoop, but that didn't seem to accomplish this goal.
> > 
> > Any ideas of how to "yield" to whatever queue or thread GStreamer has 
> > running?
> 
> I'm not sure I'm following, but I think a `setNeedsDisplay` on a view
> within a `racket/gui` frame will triggers a refresh callback in the
> normal `racket/gui` event queue.
> 
> Does the `yield` function from `racket/gui` allow the callback to run
> in the way you expect? I'd try `yield` applied to a semaphore that's
> posted by a low-priority callback installed with `queue-callback`,
> since refresh events will happen with higher priority.
> 
> There's also `flush-display`. For various reasons, `flush-display`
> rarely helps, but it may be worth a try.
> 

-- 
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.


Re: [racket-users] Strange window behavior in OSX Yosemite DrRacket

2018-01-25 Thread Robby Findler
On Thu, Jan 25, 2018 at 2:17 PM, Philip McGrath 
wrote:

> I took the steps you described and I no longer get the doubled program
> contour, but I do get results like the screenshot of my experiment with 
> text:inline-overview-mixin
> I sent
> earlier (maybe that's what the contour is supposed to look like now?). In
> both cases, drawing the contour on top of the actual text seems to me to be
> causing a problem: in, for example, line 219 of the following screenshot,
> the overview covers up part of the program source, and I can't scroll to
> reveal the covered part. In the example I sent earlier, auto-wrap is on,
> but wrapping places text under the overview, and again it isn't possible to
> scroll to uncover the text.
>
> Is this the way this is supposed to work now? Is there some way to prevent
> the overview from covering up text in the editor?
>

Currently the only way is to type cmd-u (temporarily turning it off) or, of
course, making the window wider.

It would not work well to adapt the current implementation so that
scrolling works. It would be doable, however, to adapt the current
implementation so there was a preference to move it into its own separate
canvas% object that lived beside the text (like the old contour). I opted
for the current setup, as typing cmd-u is fast and because you don't have
to pre-allocate space for the contour that could profitably be used for
lines in, say, only one part of the file.

That said, I can understand how you migth like to have the option. If you
(or anyone!) has interest in making a pull request, I can provide basic
guidance.

Robby

-- 
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.


[racket-users] A very simple #lang

2018-01-25 Thread Deren Dohoda
Hi everyone,

I am desperately in need of a #lang exact so that decimals are read as
exact values.

I thought this would be extremely simple:
..\exact\lang\reader.rkt

(module reader racket/base
  (provide (rename-out (exact-read read)
   (exact-read-syntax read-syntax)))
  (require (rename-in racket/base (read base:read) (read-syntax
base:read-syntax)))
  (define (exact-read . in)
(parameterize ((read-decimal-as-inexact #f))
  (apply base:read in)))
  (define (exact-read-syntax . in)
(parameterize ((read-decimal-as-inexact #f))
  (apply base:read-syntax in​
;;
It installs alright, though chokes on building docs for some reason, but
then when I attempt to use it:
..\exact\lang\reader.rkt:13:6: read-syntax: arity mismatch;
 the expected number of arguments does not match the given number
  expected: 0 to 2
  given: 6
  arguments...:

Why is read-syntax getting six arguments?

Deren

-- 
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.


Re: [racket-users] macro guard on variable type

2018-01-25 Thread Matthias Felleisen

You may also wish to use format-id from racket/syntax 

(require (for-syntax racket/syntax))

(define-syntax (lt/log stx)
  (syntax-case stx (quote)
[(_ (quote component) (quote level) msg v ...)
 (with-syntax ([name (format-id stx "log-sap-~a" (syntax->datum #'level))])
   #'(name (format (string-append (symbol->string (quote component)) ": " 
msg) v ...)))]
[(_ (quote level) msg v ...)
 (with-syntax ([name (format-id stx "log-pas-~a" (syntax->datum #'level))])
   #'(name (format msg v ...)))]))


and possibly switch to syntax-parse for this job. 



> On Jan 25, 2018, at 12:46 PM, Matthew Flatt  wrote:
> 
> I think you need to 
> 
> * remove the `quote`s around the two `(syntax->datum #'level)`s
> 
> * add `string->symbol` around the two `(format )`s
> 
> 
> At Thu, 25 Jan 2018 17:26:50 +0100, "'Paulo Matos' via Racket Users" wrote:
>> Hi,
>> 
>> I am trying to wrap some logging procedures into macros. I have a logger
>> for my application which I define as:
>> 
>> (define-logger sap)
>> 
>> Then I want to define a macro that possibly receives an extra argument
>> which is the part of the application that's issuing the logging message.
>> 
>> So, if logging from parser, the message would be something like:
>> sap:parser: msg...
>> 
>> So, I have:
>> (define-syntax (lt/log stx)
>>  (syntax-case stx (quote)
>>[(_ (quote component) (quote level) msg v ...)
>> (with-syntax ([name (datum->syntax stx
>>   (format "log-sap-~a" (quote
>> (syntax->datum #'level])
>>   #'(name (format (string-append (symbol->string (quote component))
>>  ": "
>>  msg)
>>   v ...)))]
>>[(_ (quote level) msg v ...)
>> (with-syntax ([name (datum->syntax stx
>>   (format "log-sap-~a" (quote
>> (syntax->datum #'level])
>>   #'(name (format msg v ...)))]))
>> 
>> The reason I am using (quote component) and (quote level) in the
>> template is because if I don't, then I get all sorts of issues with
>> messages being matched to the wrong syntax case template.
>> 
>> On the other hand, with this kind of macro the with-syntax doesn't seem
>> to be working so well when doing (format "log-sap-~a" (quote
>> (syntax->datum #'level))) because of the whole mess I created in the
>> template with the quote.
>> 
>> How can I properly write this macro such that it's properly matching the
>> arguments?
>> 
>> kind regards,
>> -- 
>> 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.
> 
> -- 
> 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.

-- 
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.


Re: [racket-users] macro guard on variable type

2018-01-25 Thread Matthew Flatt
I think you need to 

 * remove the `quote`s around the two `(syntax->datum #'level)`s

 * add `string->symbol` around the two `(format )`s


At Thu, 25 Jan 2018 17:26:50 +0100, "'Paulo Matos' via Racket Users" wrote:
> Hi,
> 
> I am trying to wrap some logging procedures into macros. I have a logger
> for my application which I define as:
> 
> (define-logger sap)
> 
> Then I want to define a macro that possibly receives an extra argument
> which is the part of the application that's issuing the logging message.
> 
> So, if logging from parser, the message would be something like:
> sap:parser: msg...
> 
> So, I have:
> (define-syntax (lt/log stx)
>   (syntax-case stx (quote)
> [(_ (quote component) (quote level) msg v ...)
>  (with-syntax ([name (datum->syntax stx
>(format "log-sap-~a" (quote
> (syntax->datum #'level])
>#'(name (format (string-append (symbol->string (quote component))
>   ": "
>   msg)
>v ...)))]
> [(_ (quote level) msg v ...)
>  (with-syntax ([name (datum->syntax stx
>(format "log-sap-~a" (quote
> (syntax->datum #'level])
>#'(name (format msg v ...)))]))
> 
> The reason I am using (quote component) and (quote level) in the
> template is because if I don't, then I get all sorts of issues with
> messages being matched to the wrong syntax case template.
> 
> On the other hand, with this kind of macro the with-syntax doesn't seem
> to be working so well when doing (format "log-sap-~a" (quote
> (syntax->datum #'level))) because of the whole mess I created in the
> template with the quote.
> 
> How can I properly write this macro such that it's properly matching the
> arguments?
> 
> kind regards,
> -- 
> 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.

-- 
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.


Re: [racket-users] Strange window behavior in OSX Yosemite DrRacket

2018-01-25 Thread 'John Clements' via Racket Users


> On Jan 25, 2018, at 8:48 AM, Jordan Johnson  wrote:
> 
> Hi all,
> 
> One of my students is observing some strange behavior involving the Program 
> Contour pane of DrRacket. He’s using v6.11 on OS X Yosemite 10.10.5.
> 
> This is the top-right corner of his DrR window, with Program Contour open:
> 
> 
> Upon pressing Cmd+U to hide it, this is what happens:
> 
> 
> Additionally, the previous day he’d found that (with the Contour pane open) 
> DrR was flickering while he typed, and (when I suggested closing the Contour 
> pane to see if it was slowing down the window redraws) pressing Cmd+U or 
> selecting the “Hide Program Contour” menu item did not hide the Contour pane.
> 
> Any ideas of what we could do to diagnose this problem?

I believe the behavior of the contour window has changed recently, and I 
conjecture that both mechanisms might still be implemented; would it help to 
edit or remove the preferences file? I believe that you’ll find them in 
~/Library/Preferences/, and there are two:

org.racket-lang.DrRacket.plist
org.racket-lang.prefs.rktd

I’m guessing the first is the one that would be relevant.

Just a thought,

John Clements



-- 
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.


[racket-users] Strange window behavior in OSX Yosemite DrRacket

2018-01-25 Thread Jordan Johnson
Hi all,

One of my students is observing some strange behavior involving the Program 
Contour pane of DrRacket. He’s using v6.11 on OS X Yosemite 10.10.5.

This is the top-right corner of his DrR window, with Program Contour open:


Upon pressing Cmd+U to hide it, this is what happens:


Additionally, the previous day he’d found that (with the Contour pane open) DrR 
was flickering while he typed, and (when I suggested closing the Contour pane 
to see if it was slowing down the window redraws) pressing Cmd+U or selecting 
the “Hide Program Contour” menu item did not hide the Contour pane.

Any ideas of what we could do to diagnose this problem?

Thanks,
Jordan

-- 
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.


[racket-users] macro guard on variable type

2018-01-25 Thread 'Paulo Matos' via Racket Users
Hi,

I am trying to wrap some logging procedures into macros. I have a logger
for my application which I define as:

(define-logger sap)

Then I want to define a macro that possibly receives an extra argument
which is the part of the application that's issuing the logging message.

So, if logging from parser, the message would be something like:
sap:parser: msg...

So, I have:
(define-syntax (lt/log stx)
  (syntax-case stx (quote)
[(_ (quote component) (quote level) msg v ...)
 (with-syntax ([name (datum->syntax stx
   (format "log-sap-~a" (quote
(syntax->datum #'level])
   #'(name (format (string-append (symbol->string (quote component))
  ": "
  msg)
   v ...)))]
[(_ (quote level) msg v ...)
 (with-syntax ([name (datum->syntax stx
   (format "log-sap-~a" (quote
(syntax->datum #'level])
   #'(name (format msg v ...)))]))

The reason I am using (quote component) and (quote level) in the
template is because if I don't, then I get all sorts of issues with
messages being matched to the wrong syntax case template.

On the other hand, with this kind of macro the with-syntax doesn't seem
to be working so well when doing (format "log-sap-~a" (quote
(syntax->datum #'level))) because of the whole mess I created in the
template with the quote.

How can I properly write this macro such that it's properly matching the
arguments?

kind regards,
-- 
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.


Re: [racket-users] Using ffi/unsafe/alloc

2018-01-25 Thread Konrad Hinsen
Hi Dmitry and Matthew,

Thanks for your suggestions, which, although quite different, turned out
to be both useful for me. As you can imagine, my real C API is a lot
more complicated. There are dependencies between allocated memory
blocks, i.e. freeing one can invalidate another one. More fine-grained
control is very welcome there, and now I know where to look for it.

Thanks,
  Konrad.

-- 
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.