> On Jan 29, 2016, at 21:55, Brian Adkins wrote:
>
> Was any consensus reached on this? I've been working through some exercises
> in Racket that a friend is implementing in Elixir, and I just came across a
> "method chaining" situation. I ended up simply writing a
> I'm not sure whether I should have known that the #:auto value would be the
> same object, so to speak, across all instances. Is there a bigger picture, in
> that respect, or is it just that structs happen to work that way, and other
> data structures might not?
A part of me just wants to
I’ve been using the Racket web server, and I’m very pleased with how
easy it’s been to get a simple working application. However, so far, I
haven’t been using send/suspend or any of the other features that
leverage continuations.
I’ve been wondering: since I’m not using send/back (just returning
For what it’s worth, I ran into this myself during my recent
experimentation with the webserver, and I was similarly surprised. Even
seeing something like “200 Okay” struck me as different, since most
servers seem to use the “200 OK” spelling. I’d always been curious about
how those strings were
Perfect! That was my hope. One more question: if I did want to opt-in to
continuations for just a single portion of my application, could I? The
way I’ve been structuring my application is to have a module that serves
as an entry point that calls serve/servlet and passes a dispatch
function
I have a macro that creates a transformer binding. This binding has
prop:procedure on it, so when used, it functions as a macro and expands
into something else. This works great, but I have another requirement:
when this binding is provided, I actually want to provide an entirely
different value
The documentation for module* would seem to indicate that submodules
declared with module* can require their parent modules:
> Like module, but only for declaring a submodule within a module,
> and for submodules that may require the enclosing module.
However, this doesn’t seem to actually work
It might be worth noting that there was a thread on the racket-dev list
a little while back that covered a similar topic about submodules and
search paths:
https://groups.google.com/d/msg/racket-dev/8BFT-RBDp9E/Y1xOCyf3nIMJ
> On Mar 12, 2016, at 10:22, Jay McCarthy
> However, my problem is still not resolved because in all the suggestions
> above, I still need to explicitly pass all the arguments to mysyn such as:
> (mysyn 1 2 3). Is there a way to pass a list l by its name and not its
> values.
> For instance, If l is '(1 2 3)
> I want to be able to
Honestly, judging from the responses in this thread, it would seem there
may be a hole in Racket’s toolbox. Nothing I’ve seen so far is
particularly stellar, especially since this is a problem that does not
seem like it should be hard.
It may be overkill for this use case, but I would probably
> That's why I think of `match` as special: it has its own means of extending
> its interface, namely with match expanders.
>
> What I'm curious about is the more general situation of composing macros that
> hold identifiers.
It is my understanding that this is what Jack Firth’s
Is there any way to create a new syntax object containing a list without
recursively converting the list’s elements to syntax objects as well? I
have some code where I wanted to use syntax objects as a convenient
mechanism to tag arbitrary datums with source location information (and
they will be
This is not the first time I have asked about the binding arrows on this
mailing list, but I seem to have run into a new problem that has me
completely stumped. I have written a #lang that uses an entirely custom
implementation of read-syntax (it does not wrap Racket’s read-syntax in
any way), and
> So, the bindings are fine, and the syntax-original? property is fine. Is the
> source location good, including the `syntax-source` field?
>
> I had a similar issue once, and it turned out that it was because the
> `syntax-source` part of the source location was wrong. I had been using
>
> I'm not sure if this helps you, but if you have complete control over what
> happens to it, you could wrap it in a struct first
Yeah, that’s a good point, and it’s one I actually did think of after
sending the email, though. Unfortunately, at that point, there’s little
reason for me to be
It is not uncommon for me, as a macro writer, to need to perform
syntax-local-value on some identifier, then record the disappeared use
in the resulting expansion. The syntax-local-value/record helper makes
this much easier, but it still requires some manual failure logic. I was
thinking it would
Has anyone written an HTML sanitizer in Racket? A naïve one is not too
difficult, given that it’s possible to create a very simple whitelist of
elements and attributes, but getting it completely right isn’t as easy
at it seems. For example, I’d like to allow elements for
the most part, but I’d
I don’t think you want to use a macro to do this.
You could detect, at compile-time, whether or not the provided argument
is a string within the macro. The best way to do this would probably be
to use the “str” syntax class, which detects strings within a
syntax-parse pattern. However, this has a
> On Aug 8, 2016, at 1:19 AM, Normal Loone wrote:
>
> I tried using override instead of augment, and it works.
> Problem is: It overrides it now ofc, which means the program is no longer
> evaluated.
If you want to override a method, but still perform its behavior,
Just for fun, if you want to be a little bit naughty, you can define
a custom #%top transformer that will make unbound identifiers that
are fully qualified automatically resolve to their imported values.
Just do a little bit of processing on the unbound identifiers:
#lang racket
(require
First of all, +1 for this stuff being confusing. I’ve been implementing
a language lately that needs its own lexer, reader, runtime
configuration, etc., and while the Racket docs are usually very good,
this stuff is sprawled out across the guide, the reference, the docs for
syntax/module-reader,
> On Feb 1, 2017, at 3:02 PM, Dan Liebgold
> wrote:
>
> Actually I mean -j to racket.exe, as in --no-jit (for your last
> invocation)
Ah! Unfortunately, no, that does not help; the errortrace instrumentation
never actually gets inserted at all when doing a parallel
Syntax templates used in syntax transformers are effectively at “phase
-1” relative to the phase they are defined at. For that reason, you need
to insert a for-template require in your utils submodule:
(module utils racket
(require (for-template racket/base))
(provide bar-impl)
I’m working on a project where having errortrace would be nice, but it’s
a little too big to want to run without compiling anything at all. From
the errortrace documentation, it seemed like `raco setup --mode
errortrace` was just what I wanted, so I gave it a shot with a simple
program. Here are
> On Feb 1, 2017, at 10:45 AM, Dan Liebgold wrote:
>
> Out of curiosity, does the -j option help here?
Yes, good suggestion; it seems like maybe --mode doesn’t work with
the parallel build. However, using -j 1 produces an error:
$ raco setup -j 1 --mode
Given that Turnstile makes extremely heavy use of local-expand,
it’s easy to imagine that the macro expander could traverse a single
piece of syntax dozens of times when it really only needs to traverse
it once. Looking at the docs, it seems like syntax-local-expand-expression
is precisely
I don’t use the GUI stuff much, so take this with a grain of salt,
but my guess is that you will definitely want to use framework if
you need syntax coloring. The color:text% component does a lot of
work to implement syntax coloring on top of the relatively primitive
text% component (which is
Alright, I’m finally taking a look at this (and looping the users
list back in). I think, unfortunately, your (Alex’s) change isn’t
quite sufficient: having access to the get-info function isn’t
enough. The read and read-syntax functions need access to the lambda
returned by the base language’s
> Unfortunately, there are probably many such buggy macros, since I don't think
> most people have a clear idea when to copy properties when using
> datum->syntax.
This is key, and unfortunately I’m becoming more and more convinced
that there’s no one good answer in the presence of the
When using make-meta-reader from syntax/module-reader, is it possible
to access the “base” language’s get-info function from within the
read or read-syntax wrapping functions? I’d like to adjust how a
particular meta language is read based on a property on the base
language.
Currently, my guess
The #%plain-app identifier is just a renamed version of #%app from
'#%kernel, so it’s actually named #%app when initially defined. The
racket/base version of #%app exists to handle keyword arguments, so
racket/base exports the underlying version of #%app as #%plain-app. Of
course, fully expanded
> On Oct 25, 2016, at 1:33 PM, Dan Liebgold wrote:
>
> I use -I, -l, then -i but the resulting REPL has no #%top-interaction
> bound...
You need to put the -i flag first, so the command should look like:
racket -iI -l
The reason for this is buried towards
> On Oct 25, 2016, at 2:09 PM, Ryan Culpepper wrote:
>
> It sounds like you want the behavior of the `enter!` command. You can kind of
> do that from the command line like this:
>
> racket -e '(enter! "your-module.rkt")' -i
>
> Ryan
Note that if you have a #lang that
The short answer is “no, but you can use -I to achieve a similar
effect for some languages”.
The longer answer is as follows. The way the REPL is configured is
different from the way modules’ readers are configured. The #lang
protocol is relatively simple — you provide read and read-syntax —
but
> On Oct 25, 2016, at 17:27, Ryan Culpepper wrote:
>
> Consider that (eval (list 'quote #'+)) also evaluates to a symbol, for about
> the same reason.
Yes, this does make sense, even if I couldn’t put it quite so nicely. :)
> Try local-expanding either of these terms
In the language I am working on, I store identifiers in preserved
syntax properties to attach type information to pieces of syntax.
More specifically, I store identifiers inside prefab structs, which
are then stored within preserved syntax properties. This seems to
work fine when my program spans
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 containing
identifiers. The issue I’m running
As a small followup to this, I managed to come up with the following
hacky workaround, which seems to be working alright so far.
Specifically, it’s a function that converts arbitrary preservable values
into expressions that evaluate to themselves:
(define preservable-property->expression
The `raco pkg config` options are documented here:
http://docs.racket-lang.org/pkg/cmdline.html#%28part._raco-pkg-config%29
(It might be a good idea to add the names of the individual options to
the index so they can be searchable.)
Specifically, the format is a series of username:password
First of all, #lang racket is not Scheme, nor does it claim to be.
However, #lang r5rs does attempt to be Scheme, and it exhibits the same
behavior as #lang racket in this case, so your question is still valid.
I would argue that, in this case, Racket gets it right, and Bigloo and
Kawa are
This appears to be an issue with the comments on the first three lines
interfering with the shebang line. Don’t include them, they’re only in
the docs for illustrative purposes. In the meantime, I’ll update the
documentation to remove that issue with the example.
> On Oct 29, 2016, at 22:31,
I have a macro that does something that approximates binding. It looks
like this:
(∀ [α] (→ α α))
Obviously, I’d really like it if the αs had binding arrows drawn to
them. The trouble, unfortunately, is that ∀ does not expand to a binding
form at all; it is parsed in a single macro step to a
Take a look at convert-compile-time-error and convert-syntax-error
from syntax/macro-testing[1], which make it possible to defer syntax
errors to runtime. The docs include examples for using them with
rackunit’s check-exn form to make assertions about syntax errors.
[1]:
> On Oct 24, 2016, at 9:58 AM, Matthias Felleisen
> wrote:
>
> This is an interesting class of errors. As Dimitry says, you might
> be able to leave behind enough source code info when you generate
> that code, so that it looks like
>
> (define foo (if (empty? blah) (error
> On Oct 19, 2016, at 4:06 AM, Robby Findler
> wrote:
>
> That's the best approach we currently have. Of course, we could support a new
> property that was "connect srclocs" or something.
Do you think it would make sense to have a property that uses
I have a function that requires a parameter be set to a value satisfying
a particular contract, but I don’t see any direct way to specify that
constraint using the contract system. It seems possible to emulate using
#:pre from ->* and ->i, but this has two problems: it doesn’t produce
very good
That sounds promising, yes. Not being familiar with the guts of
parameters, is there any way to implement this as a derived concept
using the existing support in chaperone-procedure? As far as I can
tell, parameters do not expose the continuation marks they use, and
they also create thread cells,
Many of the other answers here are good, but I want to try and give a
couple more options and a little more context.
First of all, in Racket, the phrase “syntactically correct” is a little
bit vague. It could mean that a program is successfully parsed from text
to s-expressions, which is the
You have the order wrong for ->*. The #:rest option should come
after the positional argument contracts, just before the return
contract. Since this function has no positional optional arguments,
you can either omit the optional positional argument contracts
entirely:
(->* () #:rest (listof
I have a rather strange macro. My macro works just like lambda, except
that it only accepts one argument, and inside the body of the lambda, it
annotates all uses of that argument with a syntax property. The macro
looks like this:
(require (for-syntax racket/syntax
> On Dec 13, 2016, at 11:23 AM, 'William J. Bowman' via Racket Users
> wrote:
>
> Notice that #'x is not the same identifier as x, and thus does not
> have the same syntax-properties.
I’m not convinced this is correct.
If you insert println statements in the body
Many thanks to both of you for the explanation and examples. I admit
I’ve seen that paper before, but I haven’t really taken the time
to understand it. I haven’t spent the effort to understand all the
notation being used, so much of the paper is pretty opaque to me.
Maybe once I get some time I’ll
This question comes from someone else on Stack Overflow, which they
asked here: http://stackoverflow.com/q/41144374/465378
I think it’s likely that the people who can answer this are probably
only on the mailing list, though, so I figured I’d ask it here.
Basically, the ->i contract applies
> On Dec 14, 2016, at 7:14 AM, Matthew Flatt wrote:
>
> To summarize, don't try to attach syntax objects as property values
> like that. I know this advice sounds ironic, given that the original
> use of properties was for syntax-valued keys like 'origin. Properties
> like
> On Dec 16, 2016, at 9:53 AM, Robby Findler
> wrote:
>
> Picky would never assign blame to m1. The places where m1 would be
> blamed would instead fall on, I think, m2.
Ahh, I see. I was confused because I wasn’t paying enough attention
to the blame information in
> On Dec 15, 2016, at 3:16 PM, Robby Findler
> wrote:
>
> But if you want to know more about how they could be different, you
> might want to consider this example from section 1 of the paper. It
> will (randomly) assign blame to any of the three submodules.
Hmm.
Basically, the difference is as follows: #:literals compares
identifiers using free-identifier=?, but #:datum-literals compares
them by using syntax-e and eq?.
You can observe the difference using two extremely simple macros
that only differ in their use of #:literals or #:datum-literals:
> On Dec 1, 2016, at 21:43, David Storrs wrote:
>
> The difference between a dictionary and a structure being that dictionaries
> are easily extensible on the fly and structures are not? I'm curious -- what
> are the elements of that design and what are the reasons?
> On Dec 1, 2016, at 16:29, David Storrs wrote:
>
> - This function returns #t because it is a simple test function intended to
> get the hang of hash contracts...
> - This function takes one argument...
> - Which is a hash...
> - Which has keys 'success, 'file-id,
David’s explanation is good. Let me add a little bit more context. It is
a common mistake to think that ' can be used as a shorthand form of the
`list` function, but this is not the case. The quote form is a
primitive, and it has very specific (if fairly simple) behavior with
respect to
I have run into a few situations lately where I would really
appreciate stack traces for errors in my compile-time code. However,
I can’t figure out how to get errortrace to work with errors that
occur at compile-time. For example, here’s a simple program:
#lang racket
(begin-for-syntax
> On Dec 20, 2016, at 07:54, Alex Knauth wrote:
>
> Oooh, that's pretty cool. Much better than my super-slow attempt.
>
> Should you make this into a package (I would certainly use it a lot)
> or would it make more sense to add in a pull request to the existing
>
One relatively easy solution would be to just compile patterns to
regular expressions and use Racket’s built-in match form. Writing this
as a match-expander is fairly straightforward:
#lang racket
(require (for-syntax racket/string
syntax/parse/experimental/template)
The unlib package is an old PLaneT package, so it won’t show up
when you run `raco pkg show`. It’s a dependency of the snooze package
(also from PLaneT), which you appear to have installed. Unfortunately,
the unlib package appears to have bitrotted, so it won’t build on
modern Racket (due to
This is wonderful. I have not read through everything, but the bits that
I have read are well-written, insightful, and fun. I don’t know if a
book like this is enough to get people interested in building DSLs, but
if it isn’t, I’m not sure what is. I’m a tiny bit sad (or should I say
“bummed
You can use convert-syntax-error from syntax/macro-testing to convert
the syntax error to a runtime error, which can be caught by RackUnit:
http://docs.racket-lang.org/syntax/macro-testing.html#%28form._%28%28lib._syntax%2Fmacro-testing..rkt%29._convert-syntax-error%29%29
Alexis
> On Apr 25,
> On Aug 17, 2017, at 21:52, Sam Waxman wrote:
>
> On a related note, I've read that read-syntax is supposed to return a
> syntax-object whose lexical context is stripped. Why is that? Doesn't
> that make it impossible for the language to know the difference
> between the
As written, the simple answer to your question is to use begin0 or
begin, depending on if you are using ~> or ~>>.
> (~> 3 (begin0 (displayln "hi!")) (* 2))
hi!
6
But as Greg mentions, this is not very useful, and it probably isn’t
what you want, since the evaluated expression can
> On May 25, 2017, at 1:16 PM, David Storrs wrote:
>
> 1) What can I do with a thread descriptor?
The section on Threads in the reference[1] includes all sorts of
functions that operate on thread descriptors, including but not
limited to thread-suspend, thread-resume,
> On Oct 13, 2017, at 18:52, Geoffrey Knauth wrote:
>
> Maybe do undisputedly?-evil name-mangling now to get things working,
> then become a saint with a better solution down the road. Sometimes
> I don't realize how to do something the "good" way until I've traveled
> down
> On Oct 15, 2017, at 08:59, David Christiansen
> wrote:
>
> What about keeping type bindings separate from program bindings as a
> matter of phase? This seems to me to fit in with the Hindley-Milner
> program, where types exist only at compile time only, and programs
I ended up spending the majority of my weekend working on this, and even
after two days, it still doesn’t work quite right. My verdict is that
it seems impossible to do perfectly seamlessly, but it seems possible
(but maybe hard) to get 85% there. Here’s a (rather long) overview of
what I tried
This is a cool demo! Unfortunately, I have been thinking about the
problem you describe since last night, and I am still totally stumped.
This is something that seems difficult or impossible to paper over with
more macros because #%require and #%provide are, ultimately, given
special treatment by
In discussions with some people at (seventh RacketCon), I managed to
solve a few open problems I had in my implementation of Hackett. One
thing I didn’t get a good answer for, however, is implementing a
language with multiple namespaces. Hackett is not dependently-typed, so
it is pointless and
> On Oct 12, 2017, at 1:46 PM, Matthew Flatt wrote:
>
> You could put all the type exports in a submodule. Then, you do need
> your own variant of `require`, but that variant can mostly just check
> for the presence of a type submodule, much the way that TR or
> `plai-typed`
My understanding is that quoted values are effectively interned, so
they’ll never be garbage collected as long as the code containing the
quoted expression is loaded. Here’s a program that hints at this:
(define (make-quoted-value)
'(1 . 2))
(eq? (make-quoted-value)
> On Sep 12, 2017, at 7:57 AM, Matthias Felleisen
> wrote:
>
> A word of caution on parallelism in general. Not too long ago, someone
> in CS at an Ivy League school studied the use of parallelism across
> different uses and applications. The goal was to find out how much
Yesterday, a user asked a question on Stack Overflow[1] about attempting
to parallelize a solution to the n-queens problem. The program in
question is short, so I can reproduce it here in its entirety:
#lang racket
; following returns true if queens are on diagonals:
(define
You almost certainly want to do SSL termination at the Apache level if
you are running a Racket server behind Apache. This means that Apache
will serve as a reverse proxy to your Racket web server, and all
communications between Apache and the Racket process will be ordinary
HTTP. When an HTTPS
> On Sep 26, 2017, at 5:04 PM, Matthew Butterick wrote:
>
> What about the new HTTP port that the Racket web server has opened?
> Should that be secured somehow (e.g., firewall)?
Yes. For any server exposed to the internet, you want to make sure to
only whitelist the
> On Oct 11, 2017, at 2:56 PM, George Neuner wrote:
>
> Hmm. For completeness? I'm having trouble imaging why you'd want to
> match a literal hash table. Or boxes. The other options make more
> sense. Oh well.
Imagine you’re parsing some JSON. You could parse the
> On Oct 11, 2017, at 11:10 AM, George Neuner
> wrote:
>
> My (maybe wrong) reading of the docs suggests that to match a hash
> table, the table must be defined inline in the match clause.
This isn’t really accurate. The hash-table match pattern matches a hash
table
I’ve noticed that the Racket macro system seems to have a reputation for
being impenetrably complicated, which I do not fully understand. Hackett
has, indeed, exposed a great deal of complexity, but Hackett is not an
ordinary macro, and I found writing macros with syntax/parse to be quite
pleasant
I’ve been continuing to work on this for the past two days, and I’ve
managed to get a lot more working. I figured I’d write a (somewhat
shorter) summary of what I have and haven’t solved.
1. The issue with module language imports still seems hopeless.
2. I managed to solve the submodule
> On Oct 17, 2017, at 20:11, Philip McGrath
> wrote:
>
> It wouldn't solve the problem with shadowing `require`d identifiers,
> but would having `#%module-begin` introduce the `require` (with proper
> lexical context information), instead of doing it with the reader,
>
> On Oct 18, 2017, at 8:09 AM, Matthias Felleisen
> wrote:
>
> Wouldn’t something like this work for Hackett?
I don’t think so. Perhaps it would be better illustrated with an
example.
First, consider the Hackett definition of, say, the `Maybe` type:
(data (Maybe a)
> On Nov 11, 2017, at 08:17, Robby Findler
> wrote:
>
> One example that lives on (in a zombie-like state) is the "search in
> files" functionality
Sort of off-topic, but I use the Search in Files option all the time,
so don’t think nobody’s finding it useful!
> On Oct 18, 2017, at 1:08 PM, Matthias Felleisen
> wrote:
>
> What I imagined was that you’d define @h-examples, which would
> translate the former into the latter. — Matthias
I finally did this and got everything working, mostly. I have opened a
pull request with the
Your composex macro is very similar to the various forms from the (as far as I
can tell) fairly well-known threading package:
http://docs.racket-lang.org/threading/index.html
Disclaimer: I am the author of the threading package.
In any case, there are some differences, but it has the same
The short answer is that you need a (require (for-template racket/base))
in your utilities submodule:
(module utilities racket/base
(provide compile-test)
(require (for-template racket/base))
(define (compile-test)
#`(lambda (i) (displayln `(input: ,i)
But this answer
In addition to what Matthias says, you can also sometimes break these
kinds of cycles using lazy-require, which defers the requiring the other
module until it is first needed. This is simpler than using units and
provides stronger guarantees than using callbacks, but it is a bit more
ad-hoc than
I second ~r. It will round when given a precision.
> On May 7, 2018, at 18:56, Stephen Chang wrote:
>
> Oops, I didnt see the rounding.
>
> On Mon, May 7, 2018 at 7:53 PM, Ben Greenman
> wrote:
>> I use this:
>>
This behavior is intentional, though it could perhaps be more clearly
documented. The behavior is hinted at in the documentation for
syntax/loc:
> Like syntax, except that the immediate resulting syntax object takes
> its source-location information from the result of stx-expr (which
> must
This isn’t a direct answer to your question, but as Matthias notes, my
struct-update package already implements a macro that generates
functional setters from structure definitions. Here’s a link to the
documentation:
http://docs.racket-lang.org/struct-update/index.html
Of course, that isn’t
-to-hackett/
And with that, I’ll stop bumping this thread if nobody else replies to
it — I just wanted to record the details of my solution to the problem
for posterity. :)
Thanks to everyone who helped,
Alexis
> On Oct 25, 2017, at 10:33 AM, Alexis King <lexi.lam...@gmail.com>
> w
Based on your question, why not just use dynamic-wind in combination
with with-handlers? Just keep in mind that the post-thunk could be
called multiple times if there is a continuation jump into value-thunk,
so you should also wrap the whole thing with
call-with-continuation-barrier if it’s
> On Jan 25, 2018, at 16:45, Robby Findler
> wrote:
>
> Isn't the last form already required to not be a definition?
In that example, yes, but not always, and splicing-parameterize can’t
be sure one way or the other. In this example, containing exclusively
> On Jan 24, 2018, at 12:57 AM, Ryan Culpepper
> wrote:
>
> It might make sense to `(set! new-parameterization #f)` at the end so
> that the parameterization (and the values it holds) can be GC'd sooner
> when splicing-parameterize is used at top level or module level.
The
I have some library that provides a function that produces a string:
char* make_string(void);
…and the library expects that I will eventually free the returned memory
using a custom deallocator:
void free_string(char*);
…can and should I use the _string C type with ffi/unsafe to call
Maybe this isn’t really a direct response to the direction this thread
has taken, but given the question proposed in the original message, I
think it’s relevant to share a particular design pattern for parameters
that seems to work well. In a number of different APIs provided by
Racket, a
101 - 200 of 304 matches
Mail list logo