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

[racket-users] HTML sanitization

2016-07-16 Thread Alexis King
Has anyone written an HTML sanitizer in Racket? A naïve one is not too difficult, given that it’s possible to create a very simple whitelist of elements and attributes, but getting it completely right isn’t as easy at it seems. For example, I’d like to allow elements for the most part, but I’d

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

Re: [racket-users] get the contract of a (or any) function - or find matching functions

2016-07-16 Thread Alex Knauth
> On Jul 16, 2016, at 3:20 AM, mattapiro...@gmail.com wrote: > > Hi, > > Thanks again and again for all the work on racket. Great language / > implementation. > > I wonder if there's a way to get the contract of functions in the libraries? Well, it depends. If a value is guarded with certain

[racket-users] get the contract of a (or any) function - or find matching functions

2016-07-16 Thread mattapiroglu
Hi, Thanks again and again for all the work on racket. Great language / implementation. I wonder if there's a way to get the contract of functions in the libraries? PS. I'm trying to find target functions in the namespace that'll 'match' the values I have (i.e. that can 'work with' the values