[racket-users] Semaphore-count

2018-09-04 Thread Craig Allen
So I have this snippet pinched from Rosetta Code: (define-syntax-rule (define/atomic (name arg ...) body ...) (define name (let ([sema (make-semaphore 1)]) (lambda (arg ...) (dynamic-wind (lambda () (semaphore-wait sema)) (lambda () body ...)

Re: [racket-users] Semaphore-count

2018-09-04 Thread Matthew Flatt
There's no `semaphore-count`, but you can use `semaphore-try-wait?` to poll a semaphore instead of blocking. At Tue, 4 Sep 2018 04:47:46 -0700 (PDT), Craig Allen wrote: > So I have this snippet pinched from Rosetta Code: > > (define-syntax-rule (define/atomic (name arg ...) body ...) > (define

Re: [racket-users] Semaphore-count

2018-09-04 Thread Craig Allen
I saw that function, but was scared off by its documentation: Like semaphore-wait, but semaphore-try-wait? never blocks execution. If sema’s internal counter is zero, semaphore-try-wait? returns #f immediately without decrementing the counter. If sema’s counter is positive, it is decremented an

[racket-users] Scribble how to fix red underline keywords?

2018-09-04 Thread Erich Rast
Hi! I'm new to scribble and try to fix keywords that are underlined in red. My package is called appy and appy/gui. These export all classes and other bindings of the package. In the scribble document I tried both: @(require (for-label racket) (for-label "../gui.rkt")) and @(require

Re: [racket-users] Scribble how to fix red underline keywords?

2018-09-04 Thread Philip McGrath
Have you used `defmodule` or `declare-exporting`? -Philip On Tue, Sep 4, 2018 at 8:28 AM Erich Rast wrote: > Hi! I'm new to scribble and try to fix keywords that are underlined in > red. My package is called appy and appy/gui. These export all classes > and other bindings of the package. > > I

Re: [racket-users] Scribble how to fix red underline keywords?

2018-09-04 Thread Erich Rast
Nevermind, I've got it working. I used the wrong for-label require after defmodule - with a relative path instead of an absolute path, as the manual says. It works fine now. Best, Erich On Tue, 4 Sep 2018 14:28:20 +0100 Erich Rast wrote: > Hi! I'm new to scribble and try to fix keywords that

Re: [racket-users] Semaphore-count

2018-09-04 Thread George Neuner
On 9/4/2018 8:31 AM, Craig Allen wrote: I saw that function, but was scared off by its documentation: Like semaphore-wait, but semaphore-try-wait? never blocks execution. If sema’s internal counter is zero, semaphore-try-wait? returns #f immediately without decrementing the counter. If sema’s

[racket-users] How to tighten the contract on a function

2018-09-04 Thread David Storrs
Say I have this (possibly from a third-party module): (define/contract (foo arg) (-> string? #t) #t) I want to ensure that the argument is always non-empty, so I tighten the contract. I could do this: (set! foo (contract (-> non-empty-string? #t) foo 'foo 'neg)) Mutating the function is pr

[racket-users] #%module-begin with module+

2018-09-04 Thread Philip McGrath
Is there a way to control what version of `#%module-begin` is introduced for a `module+` submodule? I have a DSL that is implemented by doing some fairly strange things with `#%module-begin`, but I want to reuse `module+` in the DSL. The submodules should be able to see all of the bindings from th

Re: [racket-users] How to tighten the contract on a function

2018-09-04 Thread David Storrs
On Tue, Sep 4, 2018 at 8:55 PM, Matthew Butterick wrote: > > On Sep 4, 2018, at 3:54 PM, David Storrs wrote: > > Say I have this (possibly from a third-party module): > > (define/contract (foo arg) (-> string? #t) #t) > > I want to ensure that the argument is always non-empty, so I tighten the

[racket-users] Re: #%module-begin with module+

2018-09-04 Thread Philip McGrath
Inspired by https://groups.google.com/d/msg/racket-users/H7vilh3KcD4/WoKcRUXe-PAJ, I have a strange but simple workaround. Essentially, I added a module like: #lang racket (require syntax/parse/define) (provide (rename-out [child-module+ module+] [child-module* module*])) (defi