Re: [racket-users] Why is struct/contract so much faster than a guard?

2020-09-02 Thread Christopher Lemmer Webber
Philip McGrath writes: > On Wed, Sep 2, 2020 at 3:41 PM Christopher Lemmer Webber < > cweb...@dustycloud.org> wrote: > >> Unfortunately I can't use #:methods with struct/contract so I'm stuck >> with the slow one if I want a contract on the struct? >> > > For another option (though you may

Re: [racket-users] Why is struct/contract so much faster than a guard?

2020-09-02 Thread Christopher Lemmer Webber
Ah, I didn't know one could just write a function for the guard... but that makes a lot of sense! Sam Tobin-Hochstadt writes: > The issue is that `struct-guard/c` is slow. If you just write a > function as a guard it's faster than `struct/contract`. > > Sam > > On Wed, Sep 2, 2020 at 3:41 PM

Re: [racket-users] Why is struct/contract so much faster than a guard?

2020-09-02 Thread Philip McGrath
On Wed, Sep 2, 2020 at 3:41 PM Christopher Lemmer Webber < cweb...@dustycloud.org> wrote: > Unfortunately I can't use #:methods with struct/contract so I'm stuck > with the slow one if I want a contract on the struct? > For another option (though you may already know this), I'd advocate for

Re: [racket-users] Create C functions for embedded Racket CS

2020-09-02 Thread Hendrik Boom
On Wed, Sep 02, 2020 at 02:05:11PM -0700, dotoscat wrote: > There are a function such scheme_make_prim_w_arity > > for the CS version? > The idea is to use Racket > as a scripting language for a C program.

[racket-users] Create C functions for embedded Racket CS

2020-09-02 Thread dotoscat
There are a function such scheme_make_prim_w_arity for the CS version? The idea is to use Racket as a scripting language for a C program. Thank you. -- You received this message because you are subscribed

Re: [racket-users] provide-if-not-defined

2020-09-02 Thread Sorawee Porncharoenwase
IIUC, that’s not what Shriram wants. He wants a kind of interface / contract for a module (that it must export certain identifiers). The solution that you posted makes the module satisfy the interface by construction, but it creates another problem which is that he might accidentally export a

Re: [racket-users] Why is struct/contract so much faster than a guard?

2020-09-02 Thread Sam Tobin-Hochstadt
The issue is that `struct-guard/c` is slow. If you just write a function as a guard it's faster than `struct/contract`. Sam On Wed, Sep 2, 2020 at 3:41 PM Christopher Lemmer Webber wrote: > > I tested the following: > > (struct foo (bar baz) > #:guard (struct-guard/c any/c list?)) > >

Re: [racket-users] provide-if-not-defined

2020-09-02 Thread Michael MacLeod
Does this example work: http://pasterack.org/pastes/95923? `if-not-defined` is written as a provide transformer which uses `syntax-local-module-defined-identifiers` to get the list of phase-0 identifiers defined in the module. Best, Michael [code also pasted below]: #lang racket/base (module

[racket-users] difference in struct printing from default #:transparent versus make-constructor-style-printer

2020-09-02 Thread Jeremy Siek
I'm seeing some bad behavior from make-constructor-style-printer when there are lists mixed in with the structs. It seems to switch from print mode to write mode when going under a list. Whereas the default printer for transparent structs gets this right. The following program demonstrates the

[racket-users] Why is struct/contract so much faster than a guard?

2020-09-02 Thread Christopher Lemmer Webber
I tested the following: (struct foo (bar baz) #:guard (struct-guard/c any/c list?)) and: (struct/contract foo ([bar any/c] [baz list?])) With the first: test> (time (for ([i 100]) (foo 'yeah '(buddy cpu time: 2601 real time: 2599

[racket-users] Re: consistent interfaces from multiple files

2020-09-02 Thread Shriram Krishnamurthi
I realize I could have used `define-language` and `define-extended-language` and friends from Redex, except … `redex-match` works over terms, not over syntax objects. Of course I also can't write (redex-match LANG NON-TERM (term (syntax->datum S))) because TERM is a special form, so it

[racket-users] provide-if-not-defined

2020-09-02 Thread Shriram Krishnamurthi
Related to my previous post [ https://groups.google.com/g/racket-users/c/OqyqDFxwhf0], I have several cases where I have this kind of pattern: V1: #lang racket (provide +) V2: #lang racket (provide [rename-out (my-+ +)]) (define my-+ …) Each variant provides some/all primitives directly from

[racket-users] consistent interfaces from multiple files

2020-09-02 Thread Shriram Krishnamurthi
This may be a somewhat niche request, but hopefully it's just a special case of a common need. I have multiple files, say V1 and V2, that each provide the same surface language constructs – e.g., #%app, some macros, some functions — but of course implemented in different ways. I also have

Re: [racket-users] Is this running in DrRacket or as a script?

2020-09-02 Thread Stefan Schmiedl
Title: Re: [racket-users] Is this running in DrRacket or as a script? Hello Laurent and Sorawee, this is exactly what I was looking for and it works like a charm. I never realised that "Submodules to run" was an active UI element. Probably one of the places where I should have RTExcellentM a

Re: [racket-users] Is this running in DrRacket or as a script?

2020-09-02 Thread Sorawee Porncharoenwase
Using Laurent’s suggestion, you can also create a global variable / parameter that will be set by the drracket submodule. That way, you can create running-in-drracket? and use it inside functions. On Wed, Sep 2, 2020 at 12:54 AM Laurent wrote: > You can use a `drracket` submodule: > > (module+

Re: [racket-users] Is this running in DrRacket or as a script?

2020-09-02 Thread Laurent
You can use a `drracket` submodule: (module+ drracket (foo) (bar)) but you need to configure DrRacket to recognize it: Click on the bottom-left button about languages, and at the bottom of "Dynamic Properties", click on "Submodules to run", then "Add submodule option" and add "drracket".

[racket-users] Is this running in DrRacket or as a script?

2020-09-02 Thread Stefan Schmiedl
Greetings, I find myself coding some more in DrRacket on my local Win10 PC. The finished program is to be run on a remote linux server. I like to keep the code set up for the production environment but to test it locally I need to configure some things differently. Currently I'm doing this