Re: [racket-users] [racket users] Pollen tag question

2020-10-30 Thread Matthew Butterick
> On Oct 30, 2020, at 1:46 PM, Kevin Forchione wrote: > > Thanks, Matthew! Understanding dawns. So the padding of lines is relative to > the “{“ and not from the beginning of the editor line as I was assuming. How > very clever. That makes alignment much easier than I’d thought! > > Is

Re: [racket-users] [racket users] Pollen tag question

2020-10-30 Thread Matthew Butterick
> On Oct 29, 2020, at 9:04 PM, Kevin Forchione wrote: > > I’ve noticed that the elements being sent to a pollen tag don’t preserve the > spacing when the text spans multiple lines for any space occurring before > characters on the subsequent line, although does preserve the spacing between

Re: [racket-users] Font bearing - lining up texts and outlines

2020-07-21 Thread Matthew Butterick
The `fontland` library does not have an official public API but it will give you the answer, which is 1446. #lang racket (require fontland fontland/ttf-glyph) (define f (open-font "/System/Library/Fonts/Supplemental/Arial Unicode.ttf")) ;; `layout` uses OpenType positioning & substitution tables

Re: [racket-users] br-parser-tools question

2020-06-08 Thread Matthew Butterick
`br-parser-tools` has some patches needed to make `brag` work, e.g., using the srcloc structure. I forked rather than patch the underlying `parser-tools` package because I didn't want to destroy the fragile ancient artifact. I fixed a few bugs; the others persist. I notice, for example, that

Re: [racket-users] Exception throwing in web-server

2020-05-25 Thread Matthew Butterick
AFAICT this is the intended behavior. To me it is consistent with the usual policy: an uncaught error stops the program. If you want the program to keep running, then you have to catch the error and make other arrangements. All my servlet routes are surrounded by a top-level `with-handlers`

Re: [racket-users] Starting a language after Beautiful Racket

2020-04-10 Thread Matthew Butterick
Three options: 1) Implement your language in `#lang br` now (and optionally convert to `racket/base` later) [1] 2) Import the `br/datum` module into a `#lang racket/base` program to get `format-datum` [2] 3) Reimplement `format-datum` your own way. You can see the underlying code by

Re: [racket-users] Suggestions for "The Racket Guide"

2020-04-08 Thread Matthew Butterick
I use the same Clipboard.js library on Beautiful Racket to support code copying. (I use v.1.5.15, though apparently the lib is now at 2.0.6). I've not had any problems or complaints. One wrinkle in implementation is that you don't want to pass formatted HTML to the clipboard. Obviously, what

Re: [racket-users] racket/draw: how to extract the path from a font% object?

2020-04-02 Thread Matthew Butterick
The thorny issue that `fontconfig` handles is mapping from a high-level specification of a font (e.g., family, weight, slant) — that is, how a user would typically specify a font — to an actual font file on disk. The shortcoming with font filenames is that they don't reliably tell you

Re: [racket-users] racket/draw: how to extract the path from a font% object?

2020-04-01 Thread Matthew Butterick
to amass a list of possible fonts and then 2) finding a match for a certain query pattern, say a family name. > On Mar 31, 2020, at 4:52 PM, Matthew Butterick wrote: > > IIUC every `font%` object must correspond to a particular font file on disk. > > If so, given a `font%` object, h

[racket-users] racket/draw: how to extract the path from a font% object?

2020-03-31 Thread Matthew Butterick
IIUC every `font%` object must correspond to a particular font file on disk. If so, given a `font%` object, how do I extract the path to that file? -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop

Re: [racket-users] how to adapt BC code for Racket CS?

2020-02-25 Thread Matthew Butterick
> On Feb 25, 2020, at 7:05 AM, Matthew Flatt wrote: > > * CS has a single heap with a single-threaded, stop-the-world GC --- > so allocation and GC easily become a bottleneck. > > If GHC's experience is any guide, making the GC itself multithreaded > may address much of this problem. >

Re: [racket-users] how to adapt BC code for Racket CS?

2020-02-25 Thread Matthew Butterick
What can you say about places & parallelism under CS vs. BC? This is one area that I find CS to reliably underperform BC (by about a factor of 2). Place creation seems slower under CS. More interestingly however, the utilization of multiple cores seems inefficient. For instance, when I run a

[racket-users] how to adapt BC code for Racket CS?

2020-02-22 Thread Matthew Butterick
Of the convergence of Racket BC and CS performance, Matthew Flatt wrote: [1] > development to date has been aimed at making Racket CS match the performance > of Racket BC on a code base that was developed and tuned for Racket BC, and > that obviously gives Racket BC an advantage. For example,

Re: [racket-users] Web server + authentication

2020-01-22 Thread Matthew Butterick
I concur on Postmark. For 2+ yrs I've used it with the Racket web server for mbtype.com . I pass the server settings to `smtp-send-message` from `net/smtp `. > On 22 Jan 20, at 3:00 AM, Bogdan Popa wrote: > > I like using Postmark[0] for this. Their free plan lets you

[racket-users] perplexed by macro-expansion behavior near #%module-begin

2020-01-13 Thread Matthew Butterick
Below, the two modules `test1` and `test2` use the same expander `exp` and otherwise differ only in the presence of the string "foo" as the second datum in `test2`. The syntax objects passed to #%module-begin are more different than that, however: the syntax passed to the first is

Re: [racket-users] Limiting consecutive identical elements with match

2019-12-04 Thread Matthew Butterick
> On Dec 4, 2019, at 3:26 PM, 'Joel Dueck' via Racket Users > wrote: > > I like the trick of using list* to match _ on any number of trailing > elements. The grammar given in the docs doesn't seem to include it; I'm > curious by what rule is it "allowed" as a pattern? It's a synonym for the

Re: [racket-users] Limiting consecutive identical elements with match

2019-12-04 Thread Matthew Butterick
> On Dec 4, 2019, at 2:39 PM, 'Joel Dueck' via Racket Users > wrote: > > So it seems easy to match "at least N identical elements". > But is there a method for matching "no more than N identical elements"? ? #lang racket (require rackunit) (define (super-cool? lst) (match lst [(and

Re: [racket-users] xml library clarification - "" symbol parsing

2019-11-21 Thread Matthew Butterick
> On Nov 21, 2019, at 9:51 AM, Kira wrote: > > I tested sxml. And it is producer rigth (for me) output. > > I feel that this is wrong behavior. Because this symbols is direct > part of one and whole element content. And must be read as "\"test qoute\"". > > Can please someone explain

Re: [racket-users] Efficient idiom for converting key-set of a hash-map into a hash-set

2019-10-26 Thread Matthew Butterick
> On Oct 25, 2019, at 7:28 AM, Thomas Dickerson > wrote: > > For reasons that are unclear to me, hash-keys and dict-keys both return a > list? instead of a set?(frankly, this seems like a bug in the API...). A dict doesn't guarantee unique keys. So `dict-keys` returns a list, not a set.

Re: [racket-users] Rhombus project plan

2019-10-03 Thread Matthew Butterick
Fantastic! In these confusing times, this fills my mind with warmth and optimism. > On Oct 2, 2019, at 12:27 PM, Matthew Flatt wrote: > > Rhombus is about building on the good parts of Racket and advancing the > frontier of Racket-style language-oriented programming. A significant > part of

Re: [racket-users] Can someone help me understand why my tokenizer (made with Brag) doesn't work?

2019-09-23 Thread Matthew Butterick
> > On 23 Sep 19, at 9:10 PM, Cistian Alejandro Alvarado Vázquez > wrote: > > Can anyone help me understand how my tokenizer should work? I'm truly truly > lost and reading the documentation has only added to my confusion! What your parser parses is a sequence of tokens. If you don't pass

Re: [racket-users] Is it possible to sell commercial use rights to an open source Racket package?

2019-08-27 Thread Matthew Butterick
> On 27 Aug 19, at 9:27 AM, Sam Tobin-Hochstadt wrote: > > 4. The interpretation of the LGPL as it relates to Racket that appears > on the download page is our (the Racket leadership) interepretation, > not the SFCs. None of us are lawyers, but that remains our > interpretation. So Racket's

Re: [racket-users] Is it possible to sell commercial use rights to an open source Racket package?

2019-08-23 Thread Matthew Butterick
Bradley Kuhn, director of the SFC, has explained why FLOSS projects don't need CLAs, along with some underlying legal truths about FLOSS contributions. [1] [1] https://sfconservancy.org/blog/2014/jun/09/do-not-need-cla/ > On 23

Re: [racket-users] Is it possible to sell commercial use rights to an open source Racket package?

2019-08-23 Thread Matthew Butterick
You're omitting some key facts. So no, I don't agree with your legal analysis. But the underlying point remains: there is unnecessary murkiness around Racket's licensing status. > On 23 Aug 19, at 11:24 AM, Alexis King wrote: > > AFAIK, copyright of the Racket codebase is not the Racket

Re: [racket-users] Is it possible to sell commercial use rights to an open source Racket package?

2019-08-23 Thread Matthew Butterick
> On Aug 23, 2019, at 6:24 AM, Sage Gerard wrote: > > Has someone tried to release an open source Racket project under a license > that enforces paid commercial use of that project? Light Googling suggests > this would be antithetical to the LGPL if not open source in general, but >

Re: [racket-users] Using the top level to fix unbound identifier

2019-08-13 Thread Matthew Butterick
> On 13 Aug 19, at 7:03 PM, Jonathan Simpson wrote: > > In the following magic code, a new function(called a named query in magic) > tga-image is defined and later used inside the definition of the function > test-scope. The issue is that tga-image is an unbound identifier in > test-scope.

Re: [racket-users] Code generation options for a self-made compiler

2019-08-12 Thread Matthew Butterick
+ use the `raco-commands` key in "info.rkt" to create new `raco myprog ···` commands + use `racket/cmdline` to parse the input options to these commands. > On 12 Aug 19, at 7:34 AM, Dmitry Pavlov wrote: > > With C, everyone is happy with macros and built-in options, e. g. > > gcc -O3

Re: [racket-users] on reducing barriers in the Racket community

2019-07-25 Thread Matthew Butterick
Mr. Atlas, since this seems to be only your second contribution to the racket-users list (the first was yesterday) I'm reluctant to impute much weight to your views, since I can't verify that there's a sincere human behind them. In any case, I can agree with you on the value of education. But

Re: [racket-users] Message in the meantime?

2019-07-24 Thread Matthew Butterick
> On Jul 24, 2019, at 1:41 PM, Matthew Flatt wrote: > > it seems difficult to make switching syntax automatic and pervasive. I > think there would end up being a lot of overhead to maintaining > documentation and tools that can reliably toggle between notations. Support for alternative

[racket-users] on reducing barriers in the Racket community

2019-07-21 Thread Matthew Butterick
I'm not a member of Racket management. But I spend a lot of time using & promoting Racket. Most recently, I taught the Beautiful Racket Workshop as part of Racket Week 2019. I care a lot about Racket — the technology, but especially the human community that makes it possible. I've heard from

[racket-users] Conservancy policy vs. Racket policy

2019-07-15 Thread Matthew Butterick
[forked from "The case, and a proposal, for elegant syntax in #lang racket2"] > On 07 15 19, at 10:55 AM, Matthias Felleisen wrote: > > the word “diversity” is inherently political. It is designed as a wedge, a > tool to separate people into groups and then from each other. It is used as a >

Re: [racket-users] Racket plugin access the path of a file

2019-06-25 Thread Matthew Butterick
In your `get-info` function for your #lang, if `ip` is the input port passed as the first argument to `get-info`, then you can get the current document filename like so: (send (object-name ip) get-filename) And pass it as an argument to your button function. > On Jun 25, 2019, at 1:10 PM,

Re: [racket-users] managing competing access to filesystem within places

2019-06-22 Thread Matthew Butterick
> On 06 22 19, at 6:14 AM, Robby Findler wrote: > > One thing you can do, when the place-specific communication takes > multiple steps is to, like you did in the first example, put the > channels into a hash, but then on each iteration of the loop, pull all > of them out and put them into a

Re: [racket-users] managing competing access to filesystem within places

2019-06-21 Thread Matthew Butterick
> On 06 15 19, at 8:31 AM, Robby Findler wrote: > > A standard way to work with this is to send a channel over in the > first communication and then the communication that's specific to that > initial request happens on that channel. The precise way you set this > up depends on what invariants

Re: [racket-users] managing competing access to filesystem within places

2019-06-21 Thread Matthew Butterick
> On Jun 15, 2019, at 8:31 AM, Robby Findler wrote: > > A standard way to work with this is to send a channel over in the > first communication and then the communication that's specific to that > initial request happens on that channel. This is probably the crudest possible implementation of

Re: [racket-users] Re: Git-Backed Racket Packages, git archive

2019-06-17 Thread Matthew Butterick
> On Jun 17, 2019, at 10:23 AM, Eric Eide wrote: > > Communicate with users. I want to put the appropriate git hash into the > output > of my program (Xsmith-based random program generators) so that I can attempt > to > reproduce the output, if necessary. Once upon a time I tried to do the

Re: [racket-users] managing competing access to filesystem within places

2019-06-15 Thread Matthew Butterick
> On Jun 15, 2019, at 8:31 AM, Robby Findler wrote: > > Place channels are asynchronous, not syncronous (i.e. you don't have > two-way rendez-vous). So the call to put returns immediately in > `loopback-p` before the other end receives the result. And now the > next iteration of the loop's get

Re: [racket-users] managing competing access to filesystem within places

2019-06-15 Thread Matthew Butterick
> On Jun 14, 2019, at 8:15 PM, Matthew Butterick wrote: > > But even after approving a lock request from a certain rendering place, the > lock server would end up with repeat lock requests from there. BTW here's a minimal example showing the puzzling message-garbling behavior be

Re: [racket-users] managing competing access to filesystem within places

2019-06-14 Thread Matthew Butterick
> On Jun 14, 2019, at 4:34 PM, Matthew Flatt wrote: > > Sometimes, staying out of the error-triggering space is unavoidable, > and the possible errors are well enough defined by all filesystems, so > retrying is a workable solution. If you really have to be in that > space, then retry an

Re: [racket-users] managing competing access to filesystem within places

2019-06-14 Thread Matthew Butterick
> On Jun 13, 2019, at 6:43 PM, Matthew Flatt wrote: > > > Oh, don't do that. Unreliable workarounds to concurrency problems > really do come back to bite you later. To ask the second dumbest possible question, what error-recovery policies are reliable under concurrency? (Put another way,

Re: [racket-users] managing competing access to filesystem within places

2019-06-13 Thread Matthew Butterick
> On Jun 13, 2019, at 10:04 AM, Matthew Flatt wrote: > > I recommend a lock-serving place in Pollen to manage concurrency for > parallel rendering. Don't let multiple places try to read and/or write > to the same file, and don't try to use filesystem locks. Thanks for the suggestion. I see

[racket-users] managing competing access to filesystem within places

2019-06-13 Thread Matthew Butterick
To Pollen, I've recently added a parallel-rendering facility with places, in emulation of how Racket docs are rendered in parallel. But it doesn't quite work — I get intermittent / inconsistent errors from the filesystem (for instance, certain files that should exist do not, or certain files

[racket-users] `fontconfig` through the FFI: best practice?

2019-06-11 Thread Matthew Butterick
If I want to call functions in the `fontconfig` library through the FFI, should I be relying on the incantations in "cairo-lib.rkt"? [1] Or are those somehow specific to the `racket/draw` system? Why does the `fontconfig-lib` definition there include libraries that are not `libfontconfig`?

Re: [racket-users] Trouble writing unhygienic macro

2019-05-28 Thread Matthew Butterick
> On May 28, 2019, at 7:11 AM, Jonathan Simpson wrote: > > Both the function definition and function calls are created by similar > looking macros which pass strings as the function name. I've now taken steps > to break hygiene in the defining macro, but the calling macro just converts > the

Re: [racket-users] how do you read, manipulate, debug scope sets?

2019-05-06 Thread Matthew Butterick
> On May 6, 2019, at 7:53 AM, zeRusski wrote: > > Are there any tutorials that show you how to use things documented in Syntax > Transformers chapter of the Reference? > > How do you debug these scope games? I agree there is something of a gap in the Racket docs / tooling, because scopes are

Re: [racket-users] Module not updating on the package server?

2019-05-01 Thread Matthew Butterick
> On Apr 30, 2019, at 12:18 PM, David Storrs wrote: > > I just pushed an update to the test-more module. On the package server it > was marked as 'New!' and was up to the latest commit, but the build status > was 'fails'. The compilation report is from April 18. I thought I'd take a >

Re: [racket-users] how do I clear this FFI-related build error?

2019-04-25 Thread Matthew Butterick
> On Apr 25, 2019, at 9:35 AM, Matthew Flatt wrote: > > Assuming that you're using > > https://github.com/greghendershott/travis-racket > > > then I think "install-racket.sh" has to change so that you have the > option to add "-natipkg"

Re: [racket-users] how do I clear this FFI-related build error?

2019-04-25 Thread Matthew Butterick
> On Apr 25, 2019, at 8:54 AM, Matthew Flatt wrote: > > You can use the "natipkg" Racket build to get Harfbuzz included for > testing, and that's what the pkg-build server does. Just beware that > users of the package may have to install/update Harfbuzz on their > machines. OK. Sorry to be a

Re: [racket-users] how do I clear this FFI-related build error?

2019-04-25 Thread Matthew Butterick
> On Apr 23, 2019, at 2:45 PM, Matthew Flatt wrote: > > At Tue, 23 Apr 2019 23:39:04 +0200, Ryan Culpepper wrote: >> It looks like natipkg Racket includes libharfbuzz.so.0, not >> libharfbuzz.so.1 (see [1]). So try changing the unix line to >> >> [(unix) (ffi-lib "libharfbuzz" '("0" ""))]

[racket-users] how do I clear this FFI-related build error?

2019-04-23 Thread Matthew Butterick
Some code relies on the `harfbuzz` library, like so: (define-runtime-lib harfbuzz-lib [(unix) (ffi-lib "libharfbuzz" '("1" ""))] [(macosx) (ffi-lib "libharfbuzz.0.dylib")] [(windows) (ffi-lib "libharfbuzz-0.dll")]) Though this works on my Mac machines, the doc server throws an error: [1]

Re: [racket-users] Inline tests for library and corresponding lang result in a loading cycle

2019-04-19 Thread Matthew Butterick
> On Apr 19, 2019, at 1:52 PM, zeRusski wrote: > > Made me curious. Maybe I'm dense, but do you suggest that I delete > foo/bar/lang and add this to foo/bar/main.rkt > > (module reader syntax/module-reader > foo/bar/main) > > If I do that though #lang foo/bar no longer works, compiler

Re: [racket-users] Inline tests for library and corresponding lang result in a loading cycle

2019-04-19 Thread Matthew Butterick
> On Apr 19, 2019, at 11:01 AM, zeRusski wrote: > One hypothesis I have is that the (module lang-test foo/bar ...) doesn't > resolve > to the language but rather to the foo/bar.rkt Right. "if the unquoted path contains no /, then require automatically adds a "/main" to the reference". [1]

Re: [racket-users] How to setup the #%module-begin form with the type-expander lib or #lang typed/racket ?

2019-04-15 Thread Matthew Butterick
`read-syntax` is special, because its job is to convert the surface notation of a #lang into S-expressions. So whatever is happening in `read-syntax` is happening during compile time, even if we're using functions rather than macros. In general, the reader is the most idiosyncratic part of the

Re: [racket-users] How to setup the #%module-begin form with the type-expander lib or #lang typed/racket ?

2019-04-15 Thread Matthew Butterick
> On Apr 12, 2019, at 6:00 PM, Raoul Schorer wrote: > > Is there a way to achieve expansion to typed/racket from my custom language, > please? With the caveat that I'm probably overlooking some wrinkle pertaining to Typed Racket — in general, the language of the expander module doesn't

Re: [racket-users] Is it necessary to print after expansion?

2019-04-08 Thread Matthew Butterick
> On Apr 7, 2019, at 9:54 PM, Raoul Schorer wrote: > > Thanks, indeed it does work. > Although if I am not mistaken, I did not see mention of > (current-print) > > in "Beautiful Racket" or in the doc tutorial on writing languages. Do I have > a special case, or is it routinely used but not

Re: [racket-users] Pattern: reusing the same name in macro-generated definitions

2019-04-05 Thread Matthew Butterick
> On Apr 5, 2019, at 3:23 AM, zeRusski wrote: > > Now about that error in the docs: I was skeptical, but I think you're right: "More generally, we can define binding based on subsets: A reference’s binding is found as one whose set of scopes is a subset of the reference’s own scopes (in

Re: [racket-users] Generics: delegate to a parent

2019-03-22 Thread Matthew Butterick
> On Mar 21, 2019, at 9:55 AM, Kees-Jochem Wehrmeijer wrote: > > It does? That sounds interesting. Do you have an example of that, or could > you point me to some docs? I thought object methods were called with send or > send-generic. Yes, you can attach generic interfaces to classes.

Re: [racket-users] Generics: delegate to a parent

2019-03-20 Thread Matthew Butterick
> On Mar 20, 2019, at 7:09 AM, zeRusski wrote: > > Both implement the same generic interface. Far as I can tell dispatch will > choose marlin's implementation on that kind of instance. Is there a way for > me to delegate to fish's method from inside marlin's method with the same > name? I

Re: [racket-users] How to fix typos in documentation?

2019-03-08 Thread Matthew Butterick
Perhaps this would be good material for a CONTRIBUTING.md at the top level of the repo, where it would be more likely to be found by future contributors. GitHub will automatically show a link to the file at arguably appropriate times. [1] [1]

Re: [racket-users] raise an exception in a generator

2019-02-20 Thread Matthew Butterick
> On Feb 20, 2019, at 4:29 PM, Kees-Jochem Wehrmeijer wrote: > > With your define/ideal-world form, is there a way to test whether something > was created using that form? E.g. by generating a predicate like ideal-world? > That way I can make sure with a contract that my function gets passed

Re: [racket-users] raise an exception in a generator

2019-02-20 Thread Matthew Butterick
> On Feb 20, 2019, at 8:47 AM, Kees-Jochem Wehrmeijer wrote: > > While this scheme works, it silently breaks if a user accidentally calls > (yield) instead of ((yield)). It might not be a big deal, but in an ideal > world I'd only allow the 'correct' way. You can make a new `define` form

Re: [racket-users] Bending use of include-template to my needs (or, macro results as macro arguments)

2019-02-19 Thread Matthew Butterick
> On Feb 19, 2019, at 2:33 PM, Brian Adkins wrote: > > Awesome - that did the trick. I'm confused as to why it helped to inject STR > into the lexical context - it ends up being just a string, and it was working > fine with respect to loading the template. I would think the fix would be to >

Re: [racket-users] Bending use of include-template to my needs (or, macro results as macro arguments)

2019-02-19 Thread Matthew Butterick
> On Feb 19, 2019, at 1:28 PM, Brian Adkins wrote: > > Oops - I spoke too soon. It appears the lexical context is unavailable to the > template when include-template is used in this manner. Ah right, one has to inject STR into the same lexical context, like so: #lang racket (require

Re: [racket-users] Bending use of include-template to my needs (or, macro results as macro arguments)

2019-02-19 Thread Matthew Butterick
> On Feb 19, 2019, at 8:25 AM, Brian Adkins wrote: > > But, I'm guessing that the include-template macro is unable to consume the > output of my view macro. Is there anything I can do to get (view login) to be > expanded prior to when include-template needs it? Wrap `include-template` with

Re: [racket-users] Racket Week’s website looks strange now that the registration is open

2019-02-01 Thread Matthew Butterick
This morning, I thought to myself "well, I probably have a couple days to fix that counter before someone notices ..." ;) Registration will be open soon. > On Feb 1, 2019, at 8:51 AM, 'Leandro Facchinetti' via Racket Users > wrote: > > See https://con.racket-lang.org/2019/

Re: [racket-users] sxml vs xexpr frustrations

2019-01-31 Thread Matthew Butterick
Stability is narrower than maintainability, which includes the idea of "can the software be improved to suit current needs". For instance: I'd be willing to look into adding SXML conversion functions to my `txexpr` package if you'd find them useful. But when I try to read Oleg's spec for

Re: [racket-users] sxml vs xexpr frustrations

2019-01-31 Thread Matthew Butterick
I (ab)use xexprs for Pollen because they're used in the Racket web server, and because at the time, SXML seemed largely abandoned — no traffic on its mailing list [1] and today, even Oleg's SXML page is a 404. [2] I wouldn't try to pry SXML from anyone's fingers. But dragging around

Re: [racket-users] [help?] Using match-define to generate lists of fields from a struct

2019-01-17 Thread Matthew Butterick
> On Jan 17, 2019, at 2:39 PM, David Storrs wrote: > > it would be nice to be able to do some slicing and dicing in the > parsing pattern as opposed to doing it manually afterwards. Is there > a way to do it? #lang racket (struct spec (type mode) #:transparent) ; cf 'cipher-spec' in crypto

Re: [racket-users] Scribble: ugly spacing due to missing SIntrapara

2019-01-14 Thread Matthew Butterick
I believe the `defthing` tags need an empty {} after them. > On Jan 13, 2019, at 11:51 PM, Sorawee Porncharoenwase > wrote: > > This seems to be a known and expected output, however. According to > https://docs.racket-lang.org/demo-manual-m2/Definition_Blocks.html: >

Re: [racket-users] triggering servlet on GET parameters

2019-01-06 Thread Matthew Butterick
Don't know if it would be an instructive example, but the Pollen project server [1], though not intended for production use, is a self-contained HTTP server that handles dynamic generation of HTML (it even works with Scribble files), which sounds similar to what you're trying to do. Jesse

Re: [racket-users] Help debugging a custom language read/expansion error

2018-12-30 Thread Matthew Butterick
> On Dec 30, 2018, at 8:41 PM, Jonathan Simpson wrote: > > I'm doing #1, so I think #2 is the explanation. 'type' is a function > available in expander.rkt so the literal will only match that binding. The > same is true for 'offset'. Both need to be provided. 'test' is not bound to >

Re: [racket-users] Help debugging a custom language read/expansion error

2018-12-30 Thread Matthew Butterick
> On Dec 30, 2018, at 3:13 PM, Jonathan Simpson wrote: > > Adding a '(provide type)' in expander.rkt (where 'line' is defined) gets me > past this error. Strangely, providing 'compare' or 'offset' doesn't seem to > be necessary. I'm interested in any theories as to why this might be the case.

Re: [racket-users] hackernews

2018-12-27 Thread Matthew Butterick
According to Brendan Eich, "The good parts of [JavaScript] go back to Scheme and Self" [1] combined with "a lot of stupid". [2] [1] https://www.jwz.org/blog/2010/10/every-day-i-learn-something-new-and-stupid/#comment-1089

Re: [racket-users] hackernews

2018-12-26 Thread Matthew Butterick
I agree that success stories are helpful. I'll go one better — I think it would be great to have a section of the main Racket website devoted to these stories that show who uses Racket and how / why (inside & outside academia). This could be done in an interview-style format, like Jesse Alama's

Re: [racket-users] Re: Using Racket behind proxy

2018-12-12 Thread Matthew Butterick
> On Dec 10, 2018, at 11:21 AM, making-a-racket wrote: > > Does anyone know if Racket is hard-coded to use git://? The URL that Racket uses to install a package is whatever the developer has listed on the package server — some begin with git://, some with https://, some with http://.

Re: [racket-users] How to disallow certain characters in identifiers?

2018-12-10 Thread Matthew Butterick
> On Dec 9, 2018, at 8:20 PM, default.kra...@gmail.com wrote: > Is there an easy way to disallow certain characters in identifiers? I > realized it's not just dots I want to disallow, but also operators like + > which might be interpreted as infix in certain contexts. Roughly, I imagine you'd

[racket-users] wrapping C datatypes

2018-11-28 Thread Matthew Butterick
To call my C rusty would be an insult to rust. I'm trying to write an FFI wrapper for certain datatypes in the Harfbuzz library: struct hb_language_impl_t { const char s[1]; }; typedef const struct hb_language_impl_t *hb_language_t; Is this the right interpretation? (define

Re: [racket-users] Obtain use-site source information

2018-11-21 Thread Matthew Butterick
> On Nov 21, 2018, at 6:44 PM, Shu-Hung You > wrote: >> (PS ignore "at L ..." — apparently `gensym` in RacketCS is broken.) Correction: it's not broken. I overlooked the fact that `gensym` is allowed to produce symbols that print the same way, though sometimes it does not. -- You received

Re: [racket-users] Obtain use-site source information

2018-11-21 Thread Matthew Butterick
(PS ignore "at L ..." — apparently `gensym` in RacketCS is broken.) > ;; Result: > ;; "at L (unsaved-editor:24.3) ; #f #f" > ;; "at L (unsaved-editor:25.3) ; #f #f" > ;; "at L (unsaved-editor:26.0) ; #f #f" > ;; "at L (unsaved-editor:27.0) ; #f #f" -- You received this message because you are

Re: [racket-users] Obtain use-site source information

2018-11-21 Thread Matthew Butterick
> On Nov 21, 2018, at 12:44 PM, Shu-Hung You > wrote: > > It works, but it would be better if (X 'USE) can log information about > its uses at B and C in addition to the source location A for debugging > purpose. If I don't want to change the implementation of USE, is there > a way for X to

Re: [racket-users] Destructuring a list in (for ...)

2018-11-21 Thread Matthew Butterick
> On Nov 21, 2018, at 9:30 AM, Brian Adkins wrote: > > Thanks guys. I think I can live with: > > (for ([(i j) (in-dict '(("a" . 1) ("b" . 20)))]) > (display (list i j))) > > I suppose I could also write something analogous to in-dict that would do > what I want. Maybe in-tuple ? Or

Re: [racket-users] Racket-on-Chez snapshot builds

2018-11-19 Thread Matthew Butterick
> 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

Re: [racket-users] Is there a way to eval a custom language from inside a module... without instantiating modules multiple times?

2018-11-16 Thread Matthew Butterick
You've mentioned that you want to "define a custom language" and evaluate it. But so far I don't see any sign that you're using Racket's dedicated facilities for doing this (especially `#%module-begin` and `module`). If this is a deliberate choice, carry on. If not, consider investigating them,

Re: [racket-users] How to eval a custom language from inside a module?

2018-11-12 Thread Matthew Butterick
> On Nov 12, 2018, at 2:11 PM, Andrew Wilcox wrote: > > How about providing eval-example from a module? > > ; eval-example.rkt > #lang racket > > (provide eval-example) > > (define example-namespace (make-base-empty-namespace)) > > (parameterize ((current-namespace example-namespace)) >

Re: [racket-users] how to make a cartesian supergenerator?

2018-10-21 Thread Matthew Butterick
> On Oct 21, 2018, at 3:49 PM, Jay McCarthy wrote: > > I think the best strategy would be to convert the generator to a > sequence and then the sequence to a stream, then write a stream > cartesian product. The stream will cache the results of the generator. Nice. #lang racket (require

[racket-users] Re: how to make a cartesian supergenerator?

2018-10-21 Thread Matthew Butterick
I suppose just putting in a hash isn't too bad. #lang racket (require racket/generator rackunit) (define/contract (make-cartesian-generator gens) ((listof generator?) . -> . generator?) (generator () (define solcache (make-hasheqv)) (let loop ([gens gens][genidx

[racket-users] how to make a cartesian supergenerator?

2018-10-21 Thread Matthew Butterick
The sample below tries to make a "cartesian supergenerator" that takes several smaller generators and combines them into a larger generator that yields cartesian combinations of the results. This works on the first pass (when the result of g1=1). But when the result of g1=2, the g2 generator

[racket-users] arbitrary currying at run time?

2018-10-12 Thread Matthew Butterick
I know about `curry` and `curryr`, of course. But is there a way to accomplish arbitrary currying at run time (not just at the ends of the argument list)? (Or is it called partial application?) Let's suppose we have `f`: (define f (λ (a b c d) (+ a b c d))) (f 1 2 3 4) ; 10 And we want to

Re: [racket-users] [Racket Users] Macros and literals question

2018-09-17 Thread Matthew Butterick
> On Sep 17, 2018, at 11:57 AM, Kevin Forchione wrote: > > In a nutshell I’m working with some hash tables whose keys are symbol and > whose values may be other keys or values such as identifiers, and I got a bit > tired of quoting all my symbols for functions and decided to use some macros

Re: [racket-users] [Racket Users] Macros and literals question

2018-09-17 Thread Matthew Butterick
> On Sep 17, 2018, at 10:21 AM, Kevin Forchione wrote: > > That seems to be the nature of macros, and I’m not sure what the solution to > that paradox is, apart from perhaps building a symbol/function hash table as > part of a define. Presumably Racke does something like that for eva & >

Re: [racket-users] [Racket Users] Macros and literals question

2018-09-16 Thread Matthew Butterick
> On Sep 16, 2018, at 2:13 PM, Kevin Forchione > wrote: > > Thanks! That’s just what I wanted. Is there a way in Racket to determine if a > quoted symbol has an associated procedure? #lang racket (require rackunit) (define-syntax (bound-to-proc? stx)

Re: [racket-users] using `define-runtime-path` inside macros

2018-08-31 Thread Matthew Butterick
> On Aug 31, 2018, at 4:14 PM, Alex Harsanyi wrote: > > Thanks for this solution, it works. While I understand what is being done, I > do not understand why it is necessary >From the docs: "The path is normally computed by taking a relative path result from expr and adding it to a path

Re: [racket-users] using `define-runtime-path` inside macros

2018-08-31 Thread Matthew Butterick
> On Aug 31, 2018, at 3:25 AM, Alex Harsanyi wrote: > > Is there a way to write this macro such that the runtime path is defined > relative to the location of the file that uses `define-sql-statement`? One option, using `syntax-source` to get the starting directory: #lang racket (require

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

2018-08-26 Thread Matthew Butterick
> On Aug 26, 2018, at 6:48 PM, Philip McGrath wrote: > > `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))`. Yes of

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

2018-08-26 Thread Matthew Butterick
> On Aug 26, 2018, at 5:15 PM, Sage Gerard wrote: > > The intent is to reject code with blanks, and to treat code without blanks as > Racket code that still might not compile There's more than one way to go about it, of course. It could be simpler to make a wrapper around the usual

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

2018-08-26 Thread Matthew Butterick
With `read`, both `for/list` expressions evaluate the same way. With `read-syntax`, the first `for/list` works as expected, but the second doesn't: it ignores the port argument and waits for something to happen on standard input. ;;; #lang racket (require rackunit)

Re: [racket-users] Do I need macros to flag unbound identifiers as failing unit tests?

2018-08-11 Thread Matthew Butterick
> On Aug 11, 2018, at 9:00 AM, Sage Gerard wrote: > > I'm starting to think writing these kind of exercises in a friendly way is > only possible with macros, but before I go that far, is it possible for me to > catch a module-level unbound identifier error and print a rackunit failure >

Re: [racket-users] Announcing Event-lang

2018-05-22 Thread Matthew Butterick
I'm sure I'm not the only one who would like to see these (and other examples you have handy) added to your `event-lang` docs. > On May 22, 2018, at 7:29 AM, Eric Griffis wrote: > > Here's a variety of small examples. -- You received this message because you are subscribed

[racket-users] why doesn't this macro produce an "identifier already defined" error?

2018-05-21 Thread Matthew Butterick
I must be missing something obvious. But I've developed short-term macro blindness. The idea is that the `foo` identifier is packaged into the call to `submac` as a syntax property. When I retrieve this property from inside `mac`, it returns the expected 'module-foo value. But when I

Re: [racket-users] How to handle circular 'requires'

2018-05-14 Thread Matthew Butterick
To add to your pile of options, because you said "certain error conditions": perhaps you might `raise` an exception in the db code that gets caught by the network code (using `with-handlers`). In this way the dependency only runs one direction (network module imports db module) but the db

  1   2   3   4   >