Re: [racket-users] Macros that use with-handlers

2016-07-17 Thread Jack Firth
On Saturday, July 16, 2016 at 7:06:10 PM UTC-4, David K. Storrs wrote: > So, if one should prefer functions, what is a good place to use > macros? When people talk about why LISP/Scheme/Racket are the most > powerful languages, they inevitably mention macros and continuations. > What is a good

Re: [racket-users] Macros that use with-handlers

2016-07-16 Thread David Storrs
I see. Okay, thanks for clarifying. On Sat, Jul 16, 2016 at 8:05 PM, Alex Knauth wrote: > >> On Jul 16, 2016, at 7:18 PM, David Storrs wrote: >> >> Wow, that is a lot of problems. Thanks for taking the time to >> comment; this was in large part an

Re: [racket-users] Macros that use with-handlers

2016-07-16 Thread Alex Knauth
> On Jul 16, 2016, at 7:18 PM, David Storrs wrote: > > Wow, that is a lot of problems. Thanks for taking the time to > comment; this was in large part an effort to learn macros, so it's > helpful to get this kind of feedback. > On Sat, Jul 16, 2016 at 2:48 PM, Alex

Re: [racket-users] Macros that use with-handlers

2016-07-16 Thread David Storrs
Wow, that is a lot of problems. Thanks for taking the time to comment; this was in large part an effort to learn macros, so it's helpful to get this kind of feedback. On Sat, Jul 16, 2016 at 2:48 PM, Alex Knauth wrote: > >> On Jul 16, 2016, at 2:16 PM, David Storrs

Re: [racket-users] Macros that use with-handlers

2016-07-16 Thread David Storrs
On Sat, Jul 16, 2016 at 2:48 PM, William J. Bowman wrote: > To address the immediate problem, this `procedure?` test will always return > `#f`, since `#'pred` is a > syntax object and not a procedure. You need to do `(procedure? (syntax->datum > #'pred))`. Similarly >

Re: [racket-users] Macros that use with-handlers

2016-07-16 Thread David Storrs
On Sat, Jul 16, 2016 at 2:48 PM, Alexis King wrote: > Of course, this makes sense, given that macros operate entirely at > compile-time. What you really want here is a function, not a macro. You > can write a simple function that will accept a procedure or a string and >

Re: [racket-users] Macros that use with-handlers

2016-07-16 Thread Alex Knauth
> On Jul 16, 2016, at 2:16 PM, David Storrs wrote: > > I'm trying to write a macro to test expected exceptions. I'd like it > to have the following forms: > > (throws exception-generator-function proc msg) > (throws exception-generator-function string msg) > > Where

Re: [racket-users] Macros that use with-handlers

2016-07-16 Thread 'William J. Bowman' via Racket Users
On Sat, Jul 16, 2016 at 02:16:20PM -0400, David Storrs wrote: > I saw the #:when keyword for patterns and thought that would do what I > needed. The following code seems like it should work, but it doesn't. > What am I missing? > > > (define-syntax (throws stx) > (syntax-parse stx >

Re: [racket-users] Macros that use with-handlers

2016-07-16 Thread Alexis King
I don’t think you want to use a macro to do this. You could detect, at compile-time, whether or not the provided argument is a string within the macro. The best way to do this would probably be to use the “str” syntax class, which detects strings within a syntax-parse pattern. However, this has a

[racket-users] Macros that use with-handlers

2016-07-16 Thread David Storrs
I'm trying to write a macro to test expected exceptions. I'd like it to have the following forms: (throws exception-generator-function proc msg) (throws exception-generator-function string msg) Where 'proc' would be something like exn:fail? and 'string' would be matched against the message