Re: [racket-users] Re: I can translate a word but how can I translate a setence with drrakket

2017-06-25 Thread Philip McGrath
At this point it is mostly a question of how restrictive your teacher wishes to be by requiring that you implement this as a single function. If you are using full Racket, it is possible to define a helper function inside of a larger function. Here is the most direct way to translate your existing

Re: [racket-users] Consulting parameters in #lang web-server servlets

2017-06-22 Thread Philip McGrath
gt; continuations. > > - Web parameters would work the same way as normal parameters and not help > you. > > - The stateless Web language guarantees that the parameters will have > values they had when the servlet was initialized. > > - I think that you may want to use a thread-c

[racket-users] Contracts for generic interfaces (or struct type properties?)

2017-05-22 Thread Philip McGrath
I'm running into trouble in trying to give contracts to methods from generic interfaces (in the sense of racket/generic) that assign blame to the implementor of a bad method implementation. This seems like it's probably a common problem, so I'm hoping a solution exists. For an example, consider

Re: [racket-users] making a language that can return the body of a function

2017-05-23 Thread Philip McGrath
I think you will probably want to define an applicable struct type with custom printing behavior and then replace Racket's lambda with your own macro to create instances of that struct type. I think what you want may be more complex than this, but here's an example that simply carries along its

Re: [racket-users] Html to text, how to obtain a rough preview

2017-05-30 Thread Philip McGrath
I would handle this by adding some special cases to ignore the content of script tags, extract alt text for images when it's provided, etc. This gets meaningful content from both nytimes.com and cnn.com (though CNN seems to only have their navigation links accessible without JavaScript): #lang

Re: [racket-users] Racket Webserver add routes outside of dispatch-rules

2017-06-02 Thread Philip McGrath
The dispatch pattern is special syntax, not an expression, so you need to write a macro. To get started, (define-syntax-rule (add-route route method proc) (dispatch-rules! main-container [route #:method method (proc)])) would work. You can get better error reporting if you

Re: [racket-users] Apropos contracts: simple predicates and switching on and off

2017-05-07 Thread Philip McGrath
I was also surprised by the-unsupplied-arg ( http://docs.racket-lang.org/reference/function-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fbase..rkt%29._the-unsupplied-arg%29%29) when I first encountered it: perhaps it should not be the very last thing in the documentation for ->i? If

[racket-users] #lang languages and cyclic dependencies

2017-04-30 Thread Philip McGrath
I'm working on a #lang for configuration files for a larger project I'm working on, and I'm trying to find a setup that meets my (largely cosmetic) goals without producing a "standard-module-name-resolver: cycle in loading" error. Given the following directory structure: - my-project/ -

Re: [racket-users] Re: #lang languages and cyclic dependencies

2017-05-01 Thread Philip McGrath
ile read)) > > Than just use `assoc` to find the values for the parameters. > > Best Regards, > Alex. > > On Monday, May 1, 2017 at 9:03:45 AM UTC+8, Philip McGrath wrote: > > I'm working on a #lang for configuration files for a larger project I'm > wor

Re: [racket-users] Apropos contracts: simple predicates and switching on and off

2017-05-02 Thread Philip McGrath
Here's the "quick" way I'd write the real-sqrt in Racket, combined with an illustration of one of the advantages of using the established contract combinators: here they gracefully report a kind of error that in the original would have caused an error in the error-checking code. (define/contract

[racket-users] Error reporting with (flat?) contracts

2017-05-02 Thread Philip McGrath
While trying to express in the contract system Daniel Prager's check that a possibly-buggy square root function actually returns the square root of its argument (and in particular the nice error messages, I ran into a few things that weren't quite as I expected. My first attempt, using

Re: [racket-users] Contracts for generic interfaces (or struct type properties?)

2017-05-24 Thread Philip McGrath
being blamed. > > This is not a great solution, because you'd have to do this for every > instance of the generic interface, but the class of boundaries you have > in mind cannot currently be described, I think. > > Vincent > > > > > On Mon, 22 May 2017 22:31:25 -0500, > Phili

[racket-users] syntax-parse attributes in macro-generated macros

2017-09-16 Thread Philip McGrath
Hi everyone, I'm writing a macro-generating macro where the generated macro uses `syntax-parse`, and I can't figure out how to work with attributes using the dot syntax where the base identifier is generated by the outer macro. For example, consider the following macro: (define-syntax

Re: [racket-users] Benefits of Racket-on-Chez for laymen

2017-09-15 Thread Philip McGrath
futures and places, I think you mean -Philip On Fri, Sep 15, 2017 at 4:44 PM, Robby Findler wrote: > Racket already has two ways to do this: futures and threads. (There was a > recent discussion on the mailing lists about futures.) > > The guide has more

Re: [racket-users] syntax-parse attributes in macro-generated macros

2017-09-18 Thread Philip McGrath
to generate the documentation automatically. -Philip On Mon, Sep 18, 2017 at 4:41 PM, Ryan Culpepper <ry...@ccs.neu.edu> wrote: > On 09/17/2017 01:00 AM, Philip McGrath wrote: > >> [...] >> >> I have a macro like `example-macro`, but more complicated and with many,

Re: [racket-users] Intro and projects inquiry

2017-10-12 Thread Philip McGrath
On Thu, Oct 12, 2017 at 4:09 PM, James wrote: > > 5. #lang R or some other method to combine Racket and R - We need to go to > R for computational work because that's what is trusted in the field. I published a package called opencpu (

Re: [racket-users] indentation under for for/list for/vector for/hash ...

2017-10-12 Thread Philip McGrath
In the DrRacket Preferences window, under the Editing > Indenting tab, you want these forms to be recognized as "Lambda-like Keywords", either by explicitly including them on the list or by having them match the "Extra regexp". I believe the default settings recognize the Racket-provided

Re: [racket-users] Need help improving a macro

2017-08-29 Thread Philip McGrath
I would love to see some library provide better abstractions for fairly common cases of keywords like this, but here is how I might write this: #lang racket (require (for-syntax syntax/parse syntax/define )) (define-syntax (register-nvim-function! stx)

Re: [racket-users] Need help improving a macro

2017-08-30 Thread Philip McGrath
On Wed, Aug 30, 2017 at 11:08 AM, wrote: > How did other people learn Racket meta programming? > I don't consider myself a huge expert in macros, but personally I found the "Examples" section of the syntax/parse documentation very helpful (

[racket-users] Strange binding arrows in #lang web-server

2017-09-09 Thread Philip McGrath
I've been noticing some strange binding arrows in DrRacket when using #lang web-server. In the following (obviously contrived) example, hovering over the first use of `term` shows an arrow to the second use, hovering over the second use of `term` shows an arrow from the first use and an arrow to

Re: [racket-users] Do futures actually work? What are they useful for?

2017-09-12 Thread Philip McGrath
It may well be much too early to say, but is there a chance that the planned move to Chez will result in fewer operations blocking futures? From what I read of the plans ( https://groups.google.com/d/msg/racket-dev/2BV3ElyfF8Y/UaHcKAHcCAAJ): > > Chez exposes OS-level threads with limited safety

Re: [racket-users] namespace-anchor->namespace and eval

2017-10-01 Thread Philip McGrath
I have no explanation, but I can get a longer version of the error message. If you change the definitions to: #lang racket (new object%) (define-namespace-anchor nsa) (define ns (namespace-anchor->namespace nsa)) And then evaluate at the REPL: > (eval '(new object%) ns) You get this error

Re: [racket-users] Connecting a language and its reader

2017-10-01 Thread Philip McGrath
Using `mylang/semantics` will work as long as you have the `mylang` collection installed, which is necessary for `#lang` to work anyway. In cases when it is sensible to use your new language without the custom reader (e.g. for languages which don't have a custom reader), it is often pleasant to

Re: [racket-users] Re: Racket dotenv file loading

2017-08-28 Thread Philip McGrath
Submodules declared with `module+` are spliced together: http://docs.racket-lang.org/reference/module.html?q=module%2B#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._module%2B%29%29 So it is a (loose) convention to write (module+ test (require rackunit)) at the top of the file, with the

[racket-users] pkgs.racket-lang.org log in is down

2017-08-28 Thread Philip McGrath
Attempting to log in to pkgs.racket-lang.org fails with a 503 Proxy Error:Proxy Error The proxy server received an invalid response from an upstream server. The proxy server could not handle the request *GET /pkgn/login *. Reason: *Error reading from

Re: [racket-users] Generate function defintions at compile time

2017-08-23 Thread Philip McGrath
On Wed, Aug 23, 2017 at 8:49 PM, Alex Harsanyi wrote: > > I think Racket is a really good language and can be directly used to write > useful applications. Yet new users are encouraged to start using the most > difficult to understand feature of Racket for their simplest

Re: [racket-users] Mapping over pattern variables

2017-09-01 Thread Philip McGrath
See also `in-syntax`: http://docs.racket-lang.org/reference/sequences.html?q=in-syntax#%28def._%28%28lib._racket%2Fsequence..rkt%29._in-syntax%29%29 -Philip On Fri, Sep 1, 2017 at 9:25 AM, Jens Axel Søgaard wrote: > One more: > > (begin-for-syntax > (define

Re: [racket-users] Re: Racket Web servlet performance benchmarked and compared

2017-09-02 Thread Philip McGrath
The Racket web server does not make use of multiple CPU cores, but with stateless continuations you can run multiple instances behind a reverse proxy. See https://groups.google.com/d/topic/racket-users/TC4JJnZo1U8/discussion ("it is exactly node.js without callbacks"). -Philip On Sat, Sep 2,

Re: [racket-users] Submodules & Hygiene

2017-10-09 Thread Philip McGrath
I don't have a comprehensive answer, but, in this case, `define` comes from `racket/base`, but the initial import of `racket/base` into the submodule has macro-introduced scope, so it isn't visible to the `form`s. It is the same principle as why this doesn't work: #lang racket (define-syntax-rule

Re: [racket-users] Multiple namespaces in Racket

2017-10-17 Thread Philip McGrath
On Tue, Oct 17, 2017 at 10:02 PM, Alexis King wrote: > > > 1. The issue with module language imports still seems hopeless. It wouldn't solve the problem with shadowing `require`d identifiers, but would having `#%module-begin` introduce the `require` (with proper lexical

Re: [racket-users] Examples of in-source documentation?

2017-11-24 Thread Philip McGrath
For an example of scribble/srcdoc, you can see .../pkgs/gui-lib/framework/main.rkt and the corresponding Scribble files in .../pkgs/gui-doc/scribblings/framework/ (I haven't really used scribble/srcdoc, I just happen to know that framework uses it.) -Philip On Fri, Nov 24, 2017 at 4:59 PM,

Re: [racket-users] Re: #lang languages and cyclic dependencies

2017-11-28 Thread Philip McGrath
server exist and just raising an error if not, rather than having to make everything in every configuration file run on every machine. -Philip On Mon, May 1, 2017 at 7:01 AM, Philip McGrath <phi...@philipmcgrath.com> wrote: > I have often done it that way, too. In this case I dec

Re: [racket-users] Advantage of ->d over ->i

2017-12-01 Thread Philip McGrath
On Fri, Dec 1, 2017 at 10:08 PM, Ben Greenman wrote: > Let me make sure I understand: > > 1. A converter is like a two-way function, lets say (A . <-> . B) > 2. If someone composes two incompatible converters, like (integer? . > <-> . symbol?) and (string? . <-> .

Re: [racket-users] Re: Best way to deploy to the package server if the module relies on a DB?

2017-12-15 Thread Philip McGrath
It's worth noting that, if your code support sqlite as a back-end, I believe you could use that for tests on the package server. On Thu, Dec 14, 2017 at 7:05 AM, David Storrs wrote: > On Wed, Dec 13, 2017 at 6:41 PM, Jack Firth wrote: > > In my

Re: [racket-users] structs vs classes

2017-12-06 Thread Philip McGrath
> 1) At least one of the fields must be set at creation > What does it mean for one of the fields not to be set at creation? Is there implicitly some not-initialized value like #f that is also valid for the constructor? Do you want your accessor functions to raise an error if someone tries to

[racket-users] scheme-script executable?

2017-12-10 Thread Philip McGrath
This morning I stumbled across Appendix D to R6RS ( http://www.r6rs.org/final/html/r6rs-app/r6rs-app-Z-H-6.html), which suggests that implementations provide an executable named scheme-script for the purpose of executing portable scripts. It seems that Racket does not currently provide such an

[racket-users] Re: scheme-script executable?

2017-12-10 Thread Philip McGrath
s/run.rkt: [running body] (Adding a space between the `#!` and `/usr/bin/env` doesn't help.) -Philip On Sun, Dec 10, 2017 at 9:34 AM, Philip McGrath <phi...@philipmcgrath.com> wrote: > This morning I stumbled across Appendix D to R6RS ( > http://www.r6rs.org/final/html/r6rs-app/r6rs-

[racket-users] Advantage of ->d over ->i

2017-12-01 Thread Philip McGrath
I recently encountered a case where a contract that (as far as I can tell) cannot be written using ->i can be easily expressed using ->d. This surprised me, since I thought that ->i was strictly better than ->d (given that the docs for ->d say, "This contract is here for backwards compatibility;

Re: [racket-users] Macro confusion with syntax-parse

2017-10-20 Thread Philip McGrath
Using `~literal` matches by binding, so when `add` is bound by a user's program (shadowing the binding `provide`d from your `calc` module), it no longer matches. You can use `~datum` instead to match `add` symbolically — if you do that in combination with providing an error-raising macro for

Re: [racket-users] Racket application quits after hiding gui window

2018-04-27 Thread Philip McGrath
I know that, on Mac at least, it's expected behavior for the application to exit when all windows are hidden with `(send frame show #f)`. I personally think this is a great default, because it prevents the annoying behavior of other applications that hang around open even when you mean to have

[racket-users] Strange "insufficient information to typecheck" error

2018-05-09 Thread Philip McGrath
The following program fails with an "Error in macro expansion -- insufficient type information to typecheck.", but it seems like there are no other type annotations that could be added: #lang typed/racket (: any- (Listof Float) (Listof Float) Boolean)) (define (any- (Listof Float) (Listof Float)

Re: [racket-users] github for third-party racket packages

2018-05-23 Thread Philip McGrath
In regard to "non-commercial stuff that you're not ready to release" (I have a lot of that), I believe GitHub requires a paid account to host private repositories. (I'd be delighted to hear otherwise.) I host some of my non-public code on BitBucket, which provides private repositories for free. It

Re: [racket-users] ?Unbound identifier in module in: make-temporary-file

2018-05-16 Thread Philip McGrath
On Wed, May 16, 2018 at 4:09 PM, Neil Van Dyke wrote: > Sam answered your question. Here's how one can usually answer the more > general question... > > * The documentation for most Racket modules will usually say what > `require` form you need to import it, assuming that

[racket-users] How much unsafety with unsafe-require/typed for polymorphic structs?

2018-05-03 Thread Philip McGrath
I have some polymorphic struct types defined in untyped Racket that I'd like to be able to work with from Typed Racket. I see that struct type variables only work with `unsafe-require/typed`; I'm trying to understand just what unsafety I would be signing myself up for if I were to use that so I

Re: [racket-users] What is the right way to generate HTML from the web server?

2018-01-04 Thread Philip McGrath
FWIW, I use `response/xexpr` in production with a `#:preamble` of `#"\n"`, and I haven't run into problems. The biggest non-obvious thing, since I see you're generating a script element, is that `response/xexpr` (and the underlying `xexpr->string`/` write-xexpr`) properly escape < and & in body

Re: [racket-users] What is the right way to generate HTML from the web server?

2018-01-04 Thread Philip McGrath
ut that makes sense. > > Now if we just had a Racket library that shoveled snow... > > On Thu, Jan 4, 2018 at 2:07 PM, Philip McGrath <phi...@philipmcgrath.com> > wrote: > >> FWIW, I use `response/xexpr` in production with a `#:preamble` of >> `#"> html>

[racket-users] opt/c behaves inconsistently with respect to flat-contract?-ness

2017-12-23 Thread Philip McGrath
I've recently noticed some surprising behavior from `opt/c` with regards to whether it produces a `flat-contract?` when its argument is flat: sometimes it does, and sometimes it doesn't, even when given the same contract. The following program is the best I've come up with at demonstrating the

Re: [racket-users] How to get around unintuitive unwrapping of a seal when passing parametric argument to contract's range-maker?

2018-01-17 Thread Philip McGrath
I noticed that this sort of works: (define/contract h (parametric->/c {α} (->i ([x α] [P (-> α contract?)] [f {P} (->d ([x α]) [_ (P x)])]) [_ {P x} (P x)])) (λ (x P f) (f x))) (h 42 (λ _ string?) number->string) The "sort of" part is

Re: [racket-users] How to get around unintuitive unwrapping of a seal when passing parametric argument to contract's range-maker?

2018-01-17 Thread Philip McGrath
) (bad-h 42 (λ _ string?) number->string) -Philip On Wed, Jan 17, 2018 at 9:08 AM, Philip McGrath <phi...@philipmcgrath.com> wrote: > I noticed that this sort of works: > (define/contract h > (parametric->/c >{α} >(->i ([x α] > [P (

Re: [racket-users] Re: React on place channel messages

2018-01-14 Thread Philip McGrath
Below I have re-worked the example program you sent yesterday to send all the work to an explicitly-created place-channel, from which all of the worker places can get work. I also saw your question about sending procedures to places. The module web-server/lang/serial-lambda provides the

Re: [racket-users] net/smtp. want to send a e-mail.

2018-01-19 Thread Philip McGrath
This is a working example (except, of course, that it does not include an actual email account or password, and, for Gmail in particular, you need to take extra steps to enable plain SMTP): #lang racket (require net/smtp net/head openssl) (let ([to "y...@example.com"]

Re: [racket-users] Re: React on place channel messages

2018-01-15 Thread Philip McGrath
y looking at the > work remaining and letting the child places send the main place the 'done > signal and when all places are 'done and I don't have any more work to > distribute, I am done. > The downside with this idea would be, that I would not know, if a child > place has somehow skip

Re: [racket-users] A very simple #lang

2018-01-25 Thread Philip McGrath
You may just want to use #lang exact-decimal racket (see: http://docs.racket-lang.org/exact-decimal-lang/index.html). I have encountered a similar problem with six arguments to read-syntax before, and I remember there being a good reason that was explained in some obscure corner of the

Re: [racket-users] Understanding prop:impersonator-of

2018-01-25 Thread Philip McGrath
This is because `prop:impersonator-of` only applies to two instances that inherit the property from the same structure type. (As the docs put it, "The result value must have the same prop:impersonator-of and prop:equal+hash property values as the original structure, if any, and the property values

[racket-users] Building GUI launcher icons with raco setup

2018-01-26 Thread Philip McGrath
I have a Racket package that creates a GUI launcher using gracket-launcher-names and gracket-launcher-libraries in the info.rkt file. The package includes a module that programmatically generates the icons for the GUI launcher at the expected paths ("my-application.png" and so forth). I would

Re: [racket-users] Strange window behavior in OSX Yosemite DrRacket

2018-01-27 Thread Philip McGrath
. -Philip On Thu, Jan 25, 2018 at 2:21 PM, Robby Findler <ro...@eecs.northwestern.edu> wrote: > On Thu, Jan 25, 2018 at 2:17 PM, Philip McGrath <phi...@philipmcgrath.com> > wrote: > >> I took the steps you described and I no longer get the doubled program >> c

[racket-users] Symbolic links and filesystem-change-evt

2018-02-14 Thread Philip McGrath
It appears that a `filesystem-change-evt` created with a path referring to a symbolic link effectively watches the target of the link for changes, not the link itself. For example, deleting the link and creating a new link that points to a different target does not cause the event to become ready

Re: [racket-users] Reverse proxy in racket

2018-02-17 Thread Philip McGrath
I have implemented a small reverse proxy in Racket, also based on http-sendrecv/url. It is mostly for a specific application (I know there are some considerations I have not addressed), but I can list some considerations I've encountered along the way: - A proxy is supposed to remove

Re: [racket-users] How to check if a symbol is defined before calling it?

2018-02-17 Thread Philip McGrath
You could do it with dynamic-require: (let ([point-pict (dynamic-require 'plot 'point-pict (λ () #f))]) (when point-pict (point-pict ...))) -Philip On Sat, Feb 17, 2018 at 7:57 PM, Alex Harsanyi wrote: > > The recent plot library introduces a new function,

Re: [racket-users] Re: Non-blocking place get

2018-02-22 Thread Philip McGrath
I've found the paper "Kill-Safe Synchronization Abstractions" ( https://www.cs.utah.edu/plt/publications/pldi04-ff.pdf) useful for getting a sense of how to work with events and sync. (Note that a few things have slightly different names than in the paper, like "thread" instead of "spawn".) More

Re: [racket-users] Generating automatic testsuites using a macro

2018-02-23 Thread Philip McGrath
Here is a version that works, with explanation following: #lang racket (require rackunit rackunit/text-ui (for-syntax syntax/parse)) (define-syntax gen-testsuite (syntax-parser [(_ n:exact-nonnegative-integer) #`(test-suite "Automated suite"

Re: [racket-users] Generating automatic testsuites using a macro

2018-02-23 Thread Philip McGrath
f the cases I wanted to without needing to dive into the more intimidating parts of the documentation for quite a while. -Philip On Fri, Feb 23, 2018 at 8:13 AM, Paulo Matos <pmatos@linki.tools> wrote: > > > On 23/02/18 15:07, Philip McGrath wrote: > > > > I also used s

Re: [racket-users] Using S-Expressions as Persistence

2017-12-26 Thread Philip McGrath
Rather than a module to be run, you can also persist data using `write` and `read` (perhaps in combination with `serialize` and `deserialize`). -Philip On Tue, Dec 26, 2017 at 7:14 AM, Zelphir Kaltstahl < zelphirkaltst...@gmail.com> wrote: > Hm that's a point. > It is only data for a blog,

Re: [racket-users] Trying to understand the module system.

2018-08-04 Thread Philip McGrath
There are several different issues here, but I'll try to touch on a few of them. On Sat, Aug 4, 2018 at 9:33 AM, Alex Gian wrote: > Say I have written a little library, perhaps of various maths utilities. > … I have also made this an installable #lang, lets's call it '#lang rat' > (for

Re: [racket-users] parameterize and keyword - doable?

2018-08-04 Thread Philip McGrath
On Sat, Aug 4, 2018 at 3:18 PM, Sanjeev Sharma wrote: > but as long as one is defaulting #:unless > PLUS #unless is common to all the for's across some arbitrary scope, > ideally one could elide it from each of the for's within that scope. > Local macros might be part of what you want: #lang

Re: [racket-users] Re: parameterize and keyword - doable?

2018-08-04 Thread Philip McGrath
On Sat, Aug 4, 2018 at 5:26 AM, George Neuner wrote: > On Sat, 4 Aug 2018 00:08:46 -0500, Philip McGrath > wrote: > > >You can call a function with dynamically calculated keyword arguments > using > >keyword-apply > ><http://docs.racket-lang.org/reference/p

Re: [racket-users] Re: parameterize and keyword - doable?

2018-08-04 Thread Philip McGrath
I remembered there is also a paper by Matthew Flatt and Eli Barzilay about the design of Racket's keyword argument system, including some of the limitations of symbols-as-keywords systems (especially in sections 6 and 7, "Experience" and "Related Work"). I obviously found it very persuasive.

Re: [racket-users] ‘with-limits’ doesn’t stop subprocesses

2018-08-05 Thread Philip McGrath
I thought `current-subprocess-custodian-mode` would be the solution, but when I just tried your code (with Racket 6.12 on Mac OS), it first printed "Timed out", then printed “Finished” after a brief delay. I get the same result if I put the `parameterize` directly around the call to `system`, and

Re: [racket-users] parameterize and keyword - doable?

2018-08-03 Thread Philip McGrath
I'm still not sure that I understand what the original questioner is trying to do. It might help to see an example in code to be clear that we're all talking about the same thing. A few points for the list, though: On Fri, Aug 3, 2018 at 10:53 PM, George Neuner wrote: > (define mykey

[racket-users] Converting Windows line-endings for arbitrary ports

2018-08-16 Thread Philip McGrath
I would like to apply the same line-ending conversion that open-input-file with a #:mode of 'text does on Windows to arbitrary input ports, like Racket-level pipes (in the sense of make-pipe). Specifically, I have an external program that I invoke with system* which reads from and writes to

Re: [racket-users] How to handle define forms in a scribble-like language

2018-08-16 Thread Philip McGrath
You probably want to partially expand the expressions, collect the definitions, and lift them to the module level. -Philip On Thu, Aug 16, 2018 at 11:58 PM, Vityou wrote: > I'm attempting to make a language similar to scribble. I'm using the > `make-at-reader` that scribble provides, and have

Re: [racket-users] Question about style

2018-08-16 Thread Philip McGrath
With just a few more parentheses, I have a macro that lets you write: (def [x 0] [y 1] [z 2] ;; or even [(f x) (/ (+ x y) z)]) http://docs.racket-lang.org/adjutor/Stable.html#(form._((lib._adjutor%2Fmain..rkt)._def)) I like explicit delimiters, but I agree that a bunch of one-line

Re: [racket-users] How to handle define forms in a scribble-like language

2018-08-16 Thread Philip McGrath
t can > tell if something is a top-level declaration? > > On Thursday, August 16, 2018 at 6:44:53 PM UTC-6, Philip McGrath wrote: >> >> You probably want to partially expand the expressions, collect the >> definitions, and lift them to the module level. >> >>

Re: [racket-users] Hierarchically-correct Scribble documentation

2018-08-05 Thread Philip McGrath
To rebuild an installed package/collection, including documentation, you want the `raco setup` command. In general, `raco setup my-collection` builds everything for `my-collection`. You will often also want the `--doc-index` flag to rebuild the index for the local documentation. The full range of

Re: [racket-users] Racket koans module language bug

2018-08-26 Thread Philip McGrath
ake that > to heart. > > Finally, all-from-out rackunit is an obvious improvement, so no worries on > adding that. > > Had a little trouble following the rest, but that's just a matter of > needing to read more. Appreciate your narrowing this down for me. Will > follow-up

Re: [racket-users] Racket koans module language bug

2018-08-26 Thread Philip McGrath
In Racket 7, at least, the first error I get is: has-blanks: arity mismatch; the expected number of arguments does not match the given number expected: 0 given: 1 After fixing that, it looks like, in your `read-syntax`, the `with-handlers` form catching `has-blanks?` emits a `module` form

Re: [racket-users] How to handle define forms in a scribble-like language

2018-08-17 Thread Philip McGrath
The error is `set!` reporting that `doc` is undefined, because the `doc` identifier from `md-module-begin` is introduced hygienically. Also, I believe your pattern for `md-module-begin` has an extra set of parentheses. Here is a working version: #lang racket/base #lang racket/base (module lang

[racket-users] FFI Trouble (file streams, variadic functions)

2018-08-27 Thread Philip McGrath
I am hoping for some help debugging a problem I'm having writing FFI bindings for libxml2. I am trying to use the function `xmlValidateDtd`, which (predictably) validates an XML document against a DTD. To support error reporting, the first argument to the function is a pointer to an

Re: [racket-users] FFI Trouble (file streams, variadic functions)

2018-08-27 Thread Philip McGrath
wrote: > On 08/27/2018 02:13 PM, Philip McGrath wrote: > > I am hoping for some help debugging a problem I'm having writing FFI > > bindings for libxml2. > > > > I am trying to use the function `xmlValidateDtd`, which (predictably) > > validates an XML documen

Re: [racket-users] why do these port ops behave differently?

2018-08-26 Thread Philip McGrath
`read-syntax` has two optional arguments: `(test read-syntax)` is effectively calling `(read-syntax (open-input-string "str"))`, which is equivalent to `(read-syntax (open-input-string "str") (current-input-port))`. -Philip On Sun, Aug 26, 2018 at 8:43 PM Matthew Butterick wrote: > With

Re: [racket-users] FFI Trouble (file streams, variadic functions)

2018-08-27 Thread Philip McGrath
That is extremely good advice that I absolutely intend to follow. Here's a bit about what I'm doing: At Digital Ricoeur (https://digitalricoeur.org/), we have a corpus of hundreds of XML documents and growing, some of them book-length. These must be validated against a custom DTD that is derived

Re: [racket-users] MIT/Chicken/Chibi Scheme style ir-macro-transformer in Racket

2018-08-29 Thread Philip McGrath
For future reference, you should try the wonderful macro stepper in DrRacket, which shows you exactly how expansion happens. It can even handle buggy, non-terminating examples like the version of `test` you wrote. -Philip On Wed, Aug 29, 2018 at 7:20 AM Philip McGrath wrote: > I'm not famil

Re: [racket-users] MIT/Chicken/Chibi Scheme style ir-macro-transformer in Racket

2018-08-29 Thread Philip McGrath
I'm not familiar with how `ir-macro-transformer` is supposed to work, but your macro is currently fails for essentially the same reason as: (define-syntax (diverge stx) stx The `expr` given to `test` is a syntactic list beginning with the identifier `test`, so including it in the output

Re: [racket-users] Where to put scribblings in 'multi package?

2018-08-29 Thread Philip McGrath
On Wed, Aug 29, 2018 at 6:29 AM Erich Rast wrote: > The reason why I want this to be a multi-collection package is that the > framework without anything gui-related is fairly small and should be > required by default as (require appy). The GUI-related extensions on > the other hand import and

Re: [racket-users] Security of continuation web server?

2018-09-01 Thread Philip McGrath
I can't address all of the considerations you raise, but I can report on a bit of experience using stateless #lang web-server servlets. (I have no real experience with the stateful version, which I believe presents different considerations.) My understanding is that continuation URIs are not

[racket-users] #%module-begin with module+

2018-09-04 Thread Philip McGrath
Is there a way to control what version of `#%module-begin` is introduced for a `module+` submodule? I have a DSL that is implemented by doing some fairly strange things with `#%module-begin`, but I want to reuse `module+` in the DSL. The submodules should be able to see all of the bindings from

[racket-users] Re: #%module-begin with module+

2018-09-04 Thread Philip McGrath
. This strikes me as very strange, and there are probably deeper subtleties it doesn't address, but it solves my immediate issues. -Philip On Tue, Sep 4, 2018 at 6:19 PM Philip McGrath wrote: > Is there a way to control what version of `#%module-begin` is introduced > for a `module+` sub

Re: [racket-users] Racket and OS X Finder

2018-09-05 Thread Philip McGrath
I have built toy application as a learning project that opens files in Finder as a default app. I haven't worked on it in a while, so I may be forgetting some things, but I'll report what I remember. It is a #lang racket/gui program, built by `raco setup` in response to

Re: [racket-users] Scribble how to fix red underline keywords?

2018-09-04 Thread Philip McGrath
Have you used `defmodule` or `declare-exporting`? -Philip On Tue, Sep 4, 2018 at 8:28 AM Erich Rast wrote: > Hi! I'm new to scribble and try to fix keywords that are underlined in > red. My package is called appy and appy/gui. These export all classes > and other bindings of the package. > >

Re: [racket-users] Path to file in dynamic-place

2018-01-23 Thread Philip McGrath
When the thing you want to refer to at runtime is specifically a module, using define-runtime-module-path-index or define-runtime-module-path (also from racket/runtime-path) may be even better choice than define-runtime-path. -Philip On Tue, Jan 23, 2018 at 10:03 PM, Jack Firth

Re: [racket-users] Places, output, input and error port

2018-01-13 Thread Philip McGrath
There are a few other problems with the code, but, most fundamentally, there is no call `message-processing-loop`, so each place starts up, handles the `'initialize` message, and terminates. -Philip On Sat, Jan 13, 2018 at 4:37 PM, Zelphir Kaltstahl < zelphirkaltst...@gmail.com> wrote: > I

Re: [racket-users] Places, output, input and error port

2018-01-13 Thread Philip McGrath
(place-output "Place ~s is going to finish now." place-id)] [bad-message (place-output "Place ~s did not understand message: ~a." place-id bad-message)] -Philip On Sat, Jan 13, 2018 at 4:54 PM, Philip

Re: [racket-users] Struct initialization?

2018-03-13 Thread Philip McGrath
I've written an experimental macro `structure` that tries to make it convenient to write custom wrappers for the constructor and the match expander that use the name of the struct: http://docs.racket-lang.org/adjutor/Experimental.html#%28form._%28%28lib._adjutor%2Fmain..rkt%29._structure%29%29 If

Re: [racket-users] any reason why slideshow is still its own executable?

2018-03-06 Thread Philip McGrath
Writing Racket tools for a small team of non-Racketeers (some of them basically non-programmers with limited command-line skills), I discovered that some of them (I don't remember how) managed to install Racket so that raco was in their PATH but executables created using racket-launcher-names were

Re: [racket-users] Why is there a space in the path to the Racket application on MacOSX?

2018-04-03 Thread Philip McGrath
One way the student languages from HtDP are different from most Racket DSLs and langs is that, in the service of regularity and nice error messages, they take away many convenient and powerful features of the full Racket language. There is not really an "escape hatch" into full Racket, other than

Re: [racket-users] IEEE 754 single precision float support

2018-04-11 Thread Philip McGrath
>From one following along who knows fairly little about floating-point math (the Toronto/McCarthy paper looks very informative!): On Tue, Apr 10, 2018 at 12:13 AM, George Neuner <gneun...@comcast.net> wrote: > As Philip McGrath mentioned already, you can specify single precisio

Re: [racket-users] typed/racket surprises

2018-04-09 Thread Philip McGrath
Thanks for your helpful reply. I've created GitHub issues https://github.com/racket/typed-racket/issues/691 and https://github.com/racket/typed-racket/issues/692 to track the bugs, and I will try my hand at a pull request for `parse-command-line` if I have time before you do. On Fri, Apr 6, 2018

Re: [racket-users] IEEE 754 single precision float support

2018-04-09 Thread Philip McGrath
Hopefully someone who's tried this sort of thing will be able to give you a better answer, but, from my quick poking around, it seems that, while there is not a special library like racket/flonum for single-precision, Racket's generic number operations (like +) work on single-precision floats and

[racket-users] Racket "google" package

2018-04-11 Thread Philip McGrath
Does anyone actively use the "google" Racket package? ( https://pkgs.racket-lang.org/package/google) There are some things I'm interested in doing, especially with the Google Drive API, but I see that the latest commit to the GitHub repository is from 2016, which seems like a long time ago in

Re: [racket-users] Re: Experience with REST APIs in Racket

2018-04-11 Thread Philip McGrath
I can second having used net/url to call simple REST APIs, though apparently slightly differently than Alex: I typically use `http-sendrecv/url` to do the data-fetching (rather than `get-pure-port`, and I build instances of the `url` struct directly rather than using `format` and `string->url`.

<    1   2   3   4   >