Re: [racket-users] Catching syntax errors

2017-07-01 Thread Ryan Culpepper
Use `convert-syntax-error` from the `syntax/macro-testing` module: http://docs.racket-lang.org/syntax/macro-testing.html#(form._((lib._syntax%2Fmacro-testing..rkt)._convert-syntax-error)) Ryan On 06/30/2017 04:47 PM, Sam Waxman wrote: Hello, I'm trying to test whether or not certain

Re: [racket-users] break-thread + thread-wait can't be handled

2017-05-03 Thread Ryan Culpepper
On 5/3/17 10:41 PM, Eric Griffis wrote: Hello, I'm having trouble catching "terminate break" exceptions when combining break-thread with thread-wait. MWE 1: (with-handlers ([exn:break:terminate? writeln]) (let ([t (thread (lambda () (thread-wait (current-thread])

Re: [racket-users] Setting parameters between files does not work as expected

2017-04-25 Thread Ryan Culpepper
You might be interested in `dsn-connect` and the `data-source` structure (http://docs.racket-lang.org/db/connect.html#%28part._.Data_.Source_.Names%29). Ryan On 4/25/17 8:18 PM, David Storrs wrote: Great. Thanks, Phillip! On Tue, Apr 25, 2017 at 2:14 PM, Philip McGrath

Re: [racket-users] Reporting exceptions as though they came from the caller

2017-03-31 Thread Ryan Culpepper
On 03/31/2017 04:00 PM, David Storrs wrote: Imagine I have the following trivial module (ignore that things are defined out of sequence for clarity): #lang racket (define (foo arg) (_baz arg) ; do some checking, raise an exception if there's a problem ...do stuff... ) (define (bar

[racket-users] Re: prepared queries

2017-03-17 Thread Ryan Culpepper
On 3/15/17 12:41 AM, George Neuner wrote: Hi Ryan, Hope you enjoyed the snow day. Lost power here for a while, but fortunately no damage. I did :) My neighborhood didn't get much snow by volume, but what it did get was then rained/sleeted nearly into ice. On 3/13/2017 11:09 PM, Ryan

[racket-users] Re: prepared queries

2017-03-13 Thread Ryan Culpepper
On 03/13/2017 06:30 PM, George Neuner wrote: Hi Ryan, On 3/13/2017 5:43 PM, Ryan Culpepper wrote: Racket's db library always prepares a statement before executing it, even if there are no query parameters. When allowed, instead of closing the prepared statement immediately after executing

Re: [racket-users] Virtual connections, threads, and DSN extraction, oh my!

2017-03-13 Thread Ryan Culpepper
On 03/13/2017 04:56 PM, George Neuner wrote: On 3/13/2017 3:41 PM, David Storrs wrote: On Mon, Mar 13, 2017 at 2:04 PM, Ryan Culpepper <ry...@ccs.neu.edu <mailto:ry...@ccs.neu.edu>> wrote: If you are using `prepare` just for speed, it might help to know that most base conn

Re: [racket-users] Virtual connections, threads, and DSN extraction, oh my!

2017-03-13 Thread Ryan Culpepper
On 03/13/2017 03:16 PM, David Storrs wrote: [...] On Mon, Mar 13, 2017 at 2:49 PM, George Neuner > wrote: - It's also fine to pass the VC into other threads. It will be shared state between the threads, but the CP will keep their

Re: [racket-users] Virtual connections, threads, and DSN extraction, oh my!

2017-03-13 Thread Ryan Culpepper
On 03/13/2017 12:49 PM, David Storrs wrote: [...] Assuming I've understood all that correctly, my last question would be how to get around the 'can't do prepare with a virtual connection' issue for situations where I've been passed a connection (perhaps from third party code) and it might or

Re: [racket-users] Detecting EOT when reading a TCP port

2017-02-22 Thread Ryan Culpepper
read-line returns eof when the port is closed, which is completely different from sending byte 04 (or any other byte or sequence of bytes) over the port. ;; set up {client,server}-{in,out} ports (write-byte 4 client-out) (flush-output client-out) (read-byte server-in) ;; => 4

Re: [racket-users] Fun with keyword-apply

2017-02-08 Thread Ryan Culpepper
On 02/08/2017 04:41 PM, Dan Liebgold wrote: Hi all - I have an odd syntax I'm trying to maintain backward compatibility with, but I'd like to take advantage of keyword parameters to accommodate the presence/absence/ordering of those parameters. Here's an example of what I'm trying to do:

Re: [racket-users] Re: How to change text alignment in a text-field% and how to make text-field% read-only but still copy-able

2016-12-03 Thread Ryan Culpepper
On 12/03/2016 02:15 PM, Winston Weinert wrote: I managed to resolve the alignment question with the following lines: (define e (send my-text-field get-editor)) (send e auto-wrap #t) (send e set-paragraph-alignment 0 'center) However, I'm still at a loss how to make the text-field% read-only

[racket-users] server downtime

2016-11-20 Thread Ryan Culpepper
We will be performing maintenance on one of the PLT servers Monday afternoon. Some services will be unavailable during that time, including PLaneT, mailing list archives, and the old bug database. The main web pages, the package server, and the user and dev mailing lists should be unaffected.

Re: [racket-users] syntax-class composed of literals

2016-11-16 Thread Ryan Culpepper
On 11/16/2016 08:24 PM, Dan Liebgold wrote: FWIW, Eric Dobson wrote a very nice `define-literal-syntax-class` macro that is used extensively inside TR. https://github.com/racket/typed-racket/blob/master/typed-racket-lib/typed-racket/utils/literal-syntax-class.rkt Hmm... I can't quite

Re: [racket-users] syntax-class composed of literals

2016-11-16 Thread Ryan Culpepper
On 11/16/2016 07:51 PM, Vincent St-Amour wrote: FWIW, Eric Dobson wrote a very nice `define-literal-syntax-class` macro that is used extensively inside TR. https://github.com/racket/typed-racket/blob/master/typed-racket-lib/typed-racket/utils/literal-syntax-class.rkt Its companion

Re: [racket-users] syntax-class composed of literals

2016-11-16 Thread Ryan Culpepper
On 11/16/2016 07:42 PM, Dan Liebgold wrote: Literal sets can include datum-literals: (define-literal-set lits #:datum-literals (a b c) (d e)) Ah, oops I missed that keyword parameter. For question 1, that's probably the best way. If you want to suppress the printing of all of the

Re: [racket-users] syntax-class composed of literals

2016-11-16 Thread Ryan Culpepper
On 11/16/2016 06:11 PM, Dan Liebgold wrote: Hi, A couple questions about literals in syntax-parse: 1. I'd like to make a syntax-class that is just a set of literals (with a clear error for something not matching any literal). Is there a better way than this: http://pasterack.org/pastes/86722

Re: [racket-users] find-seconds daylight saving

2016-11-08 Thread Ryan Culpepper
On 11/08/2016 11:24 PM, George Neuner wrote: [...] - I need to turn the UTC datetimes on all the results back into local times with the right time zone Does the following do what you want? (require srfi/19) ;; date-at-tz : Date Integer -> Date ;; Returns date of equivalent instant in

Re: [racket-users] postgresql sql-timestamp problem - test.rkt (0/1)

2016-11-06 Thread Ryan Culpepper
On 11/06/2016 09:42 PM, George Neuner wrote: [...] The following in Racket gets it wrong. e.g., [...] => #(struct:sql-timestamp 2016 5 1 5 0 0 0 0) -> "2016-05-01 05:00:00Z" "2016-05-01 00:00:00-05" -> #(struct:sql-timestamp 2016 5 1 0 0 0 0 -18000) #(struct:sql-timestamp 2016 6 12 5 0 0 0 0)

Re: [racket-users] Identifier equality of identifiers stashed in preserved syntax properties

2016-10-25 Thread Ryan Culpepper
On 10/25/2016 08:04 PM, Alexis King wrote: That makes sense; thank you for your quick reply. It might be possible to do something like what you describe, but I do have a little more context that makes this sort of tricky. I’m trying to not just store identifiers but also store prefab structs

Re: [racket-users] Re: racket command line parameter

2016-10-25 Thread Ryan Culpepper
On 10/25/2016 06:16 PM, Dan Liebgold wrote: On Tuesday, October 25, 2016 at 2:09:59 PM UTC-7, Ryan Culpepper wrote: racket -e '(enter! "your-module.rkt")' -i BTW, any luck putting a line like this in csh shell script, alias, or windows batch file? For scripting, if your in

Re: [racket-users] Re: racket command line parameter

2016-10-25 Thread Ryan Culpepper
On 10/25/2016 04:57 PM, Dan Liebgold wrote: On Tuesday, October 25, 2016 at 1:43:28 PM UTC-7, Alexis King wrote: bound... You need to put the -i flag first, so the command should look like: racket -iI -l Hmm... that give the REPL the proper language but no access to the contents of

Re: [racket-users] unit testing syntax errors

2016-10-24 Thread Ryan Culpepper
See `convert-compile-time-error` and `convert-syntax-error` from the `syntax/macro-testing` library. I should fix the docs to say that the type of the exception can change, so they work best for testing the contents of the exception message. For examples, there are tests for invalid uses of

Re: [racket-users] degenerate performance in syntax-parse

2016-10-24 Thread Ryan Culpepper
On 10/24/2016 02:15 PM, Dan Liebgold wrote: On Sunday, October 23, 2016 at 1:14:56 PM UTC-7, Ryan Culpepper wrote: [...] 1. A term like `(a <- blend)` will match the first pattern and treat `blend` as a `remap:id`. If you don't want that to happen, there are two ways to prevent it.

Re: [racket-users] degenerate performance in syntax-parse

2016-10-23 Thread Ryan Culpepper
On 10/21/2016 05:50 PM, Dan Liebgold wrote: Hi all - In the process of putting together a somewhat complex application using syntax-parse, I discovered that when I specified a repeated pattern in a syntax-class (which was incorrect) AND I had a certain usage of the syntax transformer with an

Re: [racket-users] Constructing unicode surrogates

2016-10-08 Thread Ryan Culpepper
Does one of the `string-normalize-*` functions do what you want? Ryan On 10/08/2016 01:06 PM, Jens Axel Søgaard wrote: Hi All, The following interaction shows how the reader can be used to construct a surrogate character: > (string-ref "\ud800\udc00" 0) #\ Given the two

Re: [racket-users] Using schemas with the 'db' module

2016-10-06 Thread Ryan Culpepper
In PostgreSQL, clusters contain databases contain schemas. I think the answer is to use "SET SCHEMA" or the more general "SET search_path". See https://www.postgresql.org/docs/current/static/ddl-schemas.html https://www.postgresql.org/docs/current/static/sql-set.html Ryan On 10/06/2016

Re: [racket-users] How to get non-prefab struct values from manually-expanded syntax?

2016-10-04 Thread Ryan Culpepper
On 10/03/2016 06:38 PM, Jack Firth wrote: So I'm reading a file in as code and expanding it, then looking for values in a certain syntax property that macros in the expanded code attach. This works fine for prefab structs, but I can't seem to get it to work with transparent structs. The issue

Re: [racket-users] syntax-parse #:with and error messages

2016-09-29 Thread Ryan Culpepper
On 09/28/2016 02:33 PM, 'William J. Bowman' via Racket Users wrote: I recently ran into a problem that took me hours to diagnose. It turns out that a `#:with` clause in a syntax-parse was not matching, but I would never have guessed that from the error message I got. Here is a simplified

Re: [racket-users] syntax-properties, local-expand, and a struct

2016-09-28 Thread Ryan Culpepper
On 9/28/16 12:04 PM, William J. Bowman wrote: On Fri, Sep 23, 2016 at 02:58:23PM -0400, Ryan Culpepper wrote: It appears that the constructor macro (implemented by self-ctor-transformer in racket/private/define-struct.rkt) transfers the syntax properties from the macro use to its expansion (see

Re: [racket-users] syntax-properties, local-expand, and a struct

2016-09-23 Thread Ryan Culpepper
On 09/23/2016 02:43 PM, 'William J. Bowman' via Racket Users wrote: Under certain conditions, the value of a syntax property is duplicated. I can't figure out why, or if this is a bug, and any advice would be appreciated. I've attached the smallest program that generates this behavior that

Re: [racket-users] equivalence relation for hash keys

2016-08-04 Thread Ryan Culpepper
See `define-custom-hash-types` in `racket/dict`. Note that you'll need to use `dict-ref` instead of `hash-ref`, etc. Ryan On 08/04/2016 12:34 PM, Jos Koot wrote: Hi As far as I can see a hash has three options only for the equivalence relation comparing keys: eq?, eqv? and equal?. Would it

Re: [racket-users] Is my model of (values) accurate?

2016-07-22 Thread Ryan Culpepper
On 07/22/2016 07:58 PM, David Storrs wrote: Thanks Jon, I appreciate the clear explanation. I'm using call-with-values in database code in order to turn a list into an acceptable set of bind parameters. Here's an example: (query-exec conn "insert into foo (bar, baz) values ($1, $2)"

Re: [racket-users] Typed Racket is Unsound because of module->namespace

2016-07-19 Thread Ryan Culpepper
It seems that a typed module needs to be as *protected* as TR itself, but not as *powerful* (or privileged) as TR. Otherwise one could define a malicious typed module that uses the power TR grants it to break sandboxing. Is the combination of protected but not powerful possible in the current

Re: [racket-users] Typo in syntax-class documentation?

2016-05-11 Thread Ryan Culpepper
On 05/11/2016 03:16 AM, Tim Brown wrote: I found this in the documentation for syntax-class (Link to this section with @secref["stxparse-attrs" #:doc '(lib "syntax/scribblings/syntax.scrbl")]): Consider the following code: (define-syntax-class quark (pattern (a b ...)))

Re: [racket-users] Re: for/list in-query

2016-05-11 Thread Ryan Culpepper
You might find this function helpful (from the implementation of in-query): (define (in-list/vector->values vs) (make-do-sequence (lambda () (values (lambda (p) (vector->values (car p))) cdr vs pair? #f #f Ryan On 05/04/2016 09:46 AM, Denis

[racket-users] Racket v6.5

2016-04-28 Thread Ryan Culpepper
Søgaard, John Clements, Leandro Facchinetti, Lehi Toskin, Leif Andersen, Łukasz Dąbek, Marc Kaufmann, Matthew Flatt, Matthias Felleisen, Michael McConville, Mike Sperber, Paul Stansifer, Philippe Meunier, Robby Findler, Rodrigo Setti, Ryan Culpepper, Sam Caldwell, Sam Tobin-Hochstadt, Sorawee

Re: [racket-users] drracket / postgresql error when opening connection for syntax

2016-04-06 Thread Ryan Culpepper
The problem was a use of (system-type 'machine) in racket/unix-socket. I've pushed a fix. Ryan On 04/06/2016 08:06 AM, WarGrey Gyoudmon Ju wrote: I met this problem before. (system-type 'machine) uses the output of `uname`. On Wed, Apr 6, 2016 at 5:47 PM, Tim Brown

Re: [racket-users] Calling a procedure from mysql

2016-03-28 Thread Ryan Culpepper
On 03/24/2016 06:17 PM, Ty Coghlan wrote: I have the following simple code: (require db) (define mdb (mysql-connect #:user user #:password password)) (query-exec mdb "use starwarsfinal") (query mdb "CALL track_character(?)" "Chewbacca") (disconnect mdb). Where track_character is a procedure

Re: [racket-users] Setup/teardown for unit testing

2016-03-09 Thread Ryan Culpepper
I think it would be more (Racket-)idiomatic to make account a parameter (as in make-parameter) and have something that can update the parameter around a test case. Here is my preferred extension, by example: (define account (make-parameter #f)) (define (call/open-bank proc) (parameterize

Re: [racket-users] Which html-parsing package?

2016-02-17 Thread Ryan Culpepper
On 02/17/2016 10:39 AM, Brian Adkins wrote: On Wednesday, February 17, 2016 at 10:35:44 AM UTC-5, Brian Adkins wrote: On Wednesday, February 17, 2016 at 10:20:21 AM UTC-5, Neil Van Dyke wrote: Brian Adkins wrote on 02/17/2016 10:04 AM: http://www.neilvandyke.org/racket-html-parsing/ takes me

Re: [racket-users] Re: Debug help with Unix Write

2016-02-15 Thread Ryan Culpepper
On 02/12/2016 07:33 PM, Ty Coghlan wrote: Both of you were correct, I had to flush my output and newline terminate it. The final result looks like: (define (broadcast source destination type message port) (let ([h (hash 'source source 'dest destination 'type type 'message

Re: [racket-users] Re: using ryanc's oauth2 package with Google?

2016-02-15 Thread Ryan Culpepper
On 02/14/2016 12:02 PM, Fred Martin wrote: So... even though I chose "Other" as the client type, my API credentials were created with a secret. I had to copy the secret into my client constructor request. From my reading of the oauth 2 API docs, I thought "installed app" clients weren't

Re: [racket-users] Re: how to transform syntax post-expansion?

2016-02-15 Thread Ryan Culpepper
On 02/14/2016 11:07 PM, Nota Poin wrote: I suppose I could do something like this: (define-syntax (transform-post-expansion stx) (syntax-case (expand stx) () (...))) The macro should use `local-expand` rather than `expand`. See the docs for `local-expand`, since it takes more

Re: [racket-users] Debug help with Unix Write

2016-02-12 Thread Ryan Culpepper
Unix socket ports are block-buffered, so after writing to them you need to flush the output. Something like (write-json data port) (flush-output port) Your code on github has calls to flush-output without the port argument. That doesn't flush the unix socket port; it flushes the current

[racket-users] Racket v6.4

2016-02-08 Thread Ryan Culpepper
Racket version 6.4 is now available from http://racket-lang.org/ - We fixed a security vulnerability in the web server. The existing web server is vulnerable to a navigation attack if it is also enabled to serve files statically; that is, any file readable by the web server is

Re: [racket-users] Top Level Variables or List of Shared Libraries

2016-01-28 Thread Ryan Culpepper
The openssl library uses scheme_register_process_global to make sure it initializes the openssl foreign library only once. See the end of openssl/mzssl.rkt. Ryan On 01/28/2016 02:33 PM, Leif Andersen wrote: Since a lot of people were at POPL last week, I think it's worth pinging this list

Re: [racket-users] Store value with unsupported type in Postgres?

2016-01-19 Thread Ryan Culpepper
On 01/17/2016 06:35 PM, Alexis King wrote: The DB docs for SQL type conversions[1] note that not all Postgres types are supported by Racket, and it recommends using a cast to work around this. It even uses the inet type as an example right at the start of the page. However, I want to store an

[racket-users] Racket v6.3

2015-11-23 Thread Ryan Culpepper
Racket version 6.3 is now available from http://racket-lang.org/ - Racket's macro expander uses a new representation of binding called "set of scopes". The new binding model provides a simpler explanation of how macros preserve binding, especially across module boundaries and in

Re: [racket-users] inconsistency/bug in math/array

2015-10-21 Thread Ryan Culpepper
I think I've run into this problem before. The type of array-slice-ref is (Array A) (Listof Slice-Spec) -> (Array A) where Slice-Spec = (U (Sequenceof Integer) Integer ) The problem is that integers are also sequences, so the contract generated for Slice-Spec just discards the Integer

Re: [racket-users] Iterating Through Database

2015-09-29 Thread Ryan Culpepper
On 09/29/2015 12:28 PM, Tim Roberts wrote: I'm coming to Racket after many decades of programming in other languages. One of the things that still gives me trouble is being able to know exactly what type of "thing" I have at any given point. Let me give you an example, which is actually quire

Re: [racket-users] interface to unix sockets

2015-09-03 Thread Ryan Culpepper
I think someone was working on listener code for unix sockets a year or so ago, but I don't remember who or how far they got. Pull requests are welcome. Ryan On 8/31/15 2:36 PM, qwe-te...@yandex.ru wrote: Racket provides unix-socket-connect and lacks listener. Is it going to be added in

Re: [racket-users] Lost in ellipsis depths

2015-09-03 Thread Ryan Culpepper
Here's one more solution, using "template metafunctions" (inspired by Redex's metafunctions). And yes, most of the point of template metafunctions is to have something that cooperates with ellipses like you want. > (require syntax/parse syntax/parse/experimental/template

Re: [racket-users] problems with sql-timestamp and date*

2015-08-22 Thread Ryan Culpepper
On 08/22/2015 06:18 PM, George Neuner wrote: On 8/22/2015 5:50 PM, Jon Zeppieri wrote: On Sat, Aug 22, 2015 at 4:36 PM, George Neunergneun...@comcast.net wrote: The latter code using date works properly (modulo the time zone field) and gives consistent results, but the former using date*

[racket-users] Racket v6.2.1

2015-08-10 Thread Ryan Culpepper
Racket version 6.2.1 is now available from http://racket-lang.org/ Version 6.2.1 patches the recent v6.2 release in three small ways: * For the How to Design Programs teaching languages, DrRacket offers an option to use the old style for printing the constants `true`, `false`, and

Re: [racket-users] stops in Macros that Work Together

2015-07-06 Thread Ryan Culpepper
On 07/06/2015 10:04 PM, Anthony Carrico wrote: I've been working through Macros that Work Together (on my way to working through Sets-of-Scopes). I've come across something that is slightly unclear to me in the section on local-expand: E ::= a mapping from name to transform I don't believe

Re: [racket-users] db: nested transactions

2015-06-24 Thread Ryan Culpepper
On 06/24/2015 07:46 AM, George Neuner wrote: Hi Ryan, On 6/23/2015 12:20 PM, Ryan Culpepper wrote: Yes, that should be fine. One note about your sample code: the isolation mode of inner transactions must be #f (the default); you can't change isolation levels once you've started an outer

Re: [racket-users] db: nested transactions

2015-06-23 Thread Ryan Culpepper
Yes, that should be fine. One note about your sample code: the isolation mode of inner transactions must be #f (the default); you can't change isolation levels once you've started an outer transaction. Also keep in mind that nested transactions are not supported for ODBC connections. Ryan

[racket-users] Racket v6.2

2015-06-19 Thread Ryan Culpepper
Racket version 6.2 is now available from http://racket-lang.org/ With this release we are taking a major step forward to get our user community even more involved than in the past. Over the past six months, we have re-organized the Racket code base into a small core code repo and many other

Re: [racket-users] Macro-introducing macros with inter-macro communication channel

2015-06-19 Thread Ryan Culpepper
On 06/19/2015 03:07 PM, Thomas Dickerson wrote: Hi All, I'm trying to figure out how best to implement the following pattern of macro behavior: Let's say we are writing Loop macro that implements a looped computation over a specified body. I would like to then be able to (a) introduce

<    1   2