[racket-users] One macro -> N defined functions
I'm just beginning to dig in to Racket macros, so forgive the newbie question :) Is it possible to create a macro that will result in multiple functions being defined? I have a bunch of predicate functions, and I'm creating a parallel set of assert functions that look like the following: (define (assert-at-home-page response) (assert-lines response at-home-page?)) (define (assert-at-signon-page response) (assert-lines response at-signon-page?)) ... It would be trivial to define a macro to create a single assert more nicely than the above, but it would be nice to be able to use something like: (define-asserts at-home-page? at-inquiry-menu? at-signon-page? ... ) All of the macros I've experimented with thus far deal with a single form. Thanks, Brian -- 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] One macro -> N defined functions
The begin form can encapsulate multiple definitions like this: (require (for-syntax racket/sequence racket/syntax) syntax/parse/define) (define-simple-macro (define-asserts predicate:id ...) #:with (assert-name ...) (for/list ([id (in-syntax #'(predicate ...))]) (format-id this-syntax "assert-~a" (syntax-e id))) (begin (define (assert-name response) (assert-lines response predicate)) ...)) Note that format-id needs to use this-syntax (from syntax parse, referring to the syntax object passed to the current syntax transformer) to obtain the right lexical context. On Tue, Nov 20, 2018 at 8:26 AM Brian Adkins wrote: > > I'm just beginning to dig in to Racket macros, so forgive the newbie question > :) Is it possible to create a macro that will result in multiple functions > being defined? > > I have a bunch of predicate functions, and I'm creating a parallel set of > assert functions that look like the following: > > (define (assert-at-home-page response) > (assert-lines response at-home-page?)) > > (define (assert-at-signon-page response) > (assert-lines response at-signon-page?)) > > ... > > It would be trivial to define a macro to create a single assert more nicely > than the above, but it would be nice to be able to use something like: > > (define-asserts at-home-page? at-inquiry-menu? at-signon-page? ... ) > > All of the macros I've experimented with thus far deal with a single form. > > Thanks, > Brian > > -- > 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] One macro -> N defined functions
So simple in hindsight - thanks! I didn't realize begin could be used that way, but it makes perfect sense, and that was the key missing piece for me. On Tuesday, November 20, 2018 at 9:56:08 AM UTC-5, Shu-Hung You wrote: > > The begin form can encapsulate multiple definitions like this: > > (require (for-syntax racket/sequence > racket/syntax) > syntax/parse/define) > > (define-simple-macro (define-asserts predicate:id ...) > #:with (assert-name ...) > (for/list ([id (in-syntax #'(predicate ...))]) > (format-id this-syntax "assert-~a" (syntax-e id))) > (begin > (define (assert-name response) > (assert-lines response predicate)) > ...)) > > Note that format-id needs to use this-syntax (from syntax parse, > referring to the syntax object passed to the current syntax > transformer) to obtain the right lexical context. > > On Tue, Nov 20, 2018 at 8:26 AM Brian Adkins > wrote: > > > > I'm just beginning to dig in to Racket macros, so forgive the newbie > question :) Is it possible to create a macro that will result in multiple > functions being defined? > > > > I have a bunch of predicate functions, and I'm creating a parallel set > of assert functions that look like the following: > > > > (define (assert-at-home-page response) > > (assert-lines response at-home-page?)) > > > > (define (assert-at-signon-page response) > > (assert-lines response at-signon-page?)) > > > > ... > > > > It would be trivial to define a macro to create a single assert more > nicely than the above, but it would be nice to be able to use something > like: > > > > (define-asserts at-home-page? at-inquiry-menu? at-signon-page? ... ) > > > > All of the macros I've experimented with thus far deal with a single > form. > > > > Thanks, > > Brian > > > > -- > > 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...@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-on-Chez snapshot builds
I'm getting much faster startup times. And the initial freeze when loading a file after initial startup - is that actually faster or has it been amortized using lazy techniques? On Monday, November 19, 2018 at 6:35:43 PM UTC-5, Matthew Butterick wrote: > > > > On Nov 19, 2018, at 2:06 PM, Matthew Flatt > wrote: > > > > Although Racket-on-Chez is not yet ready to replace the existing > > implementation of Racket for most purposes, it should generally work > > now --- and it might even be useful for some purposes. Many, many > > details have to be right for Racket-on-Chez to assemble itself into a > > snapshot distribution, so this is a significant milestone. > > Thank you for the all your effort & hard work to get Racket-on-Chez this > far. > > This week, I've gone over to using the Racket-on-Chez snapshots > exclusively. They are stable & fast enough for everything I do with Racket. > There are bugs, of course, though so far all small. And Matthew has been > fixing them as fast as I can file them. > > For that matter, if you've ever wondered "what can I do to improve > Racket-on-Chez, without being a 1337 h4x0r?" I suggest that you also use > the snapshots and file bugs. Because that will make Racket-on-Chez better, > sooner, for everyone. > > One tip, if you haven't used the snapshots before (I hadn't): I've > switched to installing my own packages in "--scope user" rather than > "--scope installation". This keeps the packages out of the snapshot folder, > so the snapshot can be easily replaced without disturbing the rest. > > To infinity and beyond. -- 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.