
and if it does not fail, is that an acceptable workaround for the scribble docs, or are you looking for a complete fix? If the latter, it’s possible that the issue may be due to some dynamic-require for GUI of plot-metrics or some parent module requiring it transitively. (I don’t have time to dig into this though, sorry)

Hi, I am learning about syntax-parse
and I see that the definition of define-syntax-class
allows the syntax class to have parameters, but their use is neither documented(?) nor can I find any examples of their use. Does anyone know about any package that uses them so that I can take a look at some code? Or even better if I am missing some documentation or examples

The documentation says: > A syntax class may have formal parameters, in which case they are bound as variables in the body. Syntax classes support optional arguments and keyword arguments using the same syntax as https://docs.racket-lang.org/reference/lambda.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._lambda%29%29\|lambda. The body of the syntax-class definition contains a non-empty sequence of https://docs.racket-lang.org/syntax/stxparse-specifying.html#%28form._%28%28lib._syntax%2Fparse..rkt%29._pattern%29%29\|pattern variants. I don’t know of many examples. I managed to find one from a random github repo: (define-syntax-class (-metavar-of nt)
#:attributes (data)
(pattern x:id
#:attr data (symbol->metavar nt (syntax-e #'x))
#:when (metavar? (attribute data))))
Here the argument nt
is used to set the initial value of the attribute data
.

Those are both nice.

this example is very useful, thank you

could you point me to its direction so I can see how it is being used on the “call site”

?


excellen! thank you very much!

Besides ~var
you can also use the pattern directive #:declare
to attach syntax classes with arguments to patterns.

I believe expr/c
is an example of a syntax class that has arguments. I use it with #:declare
.

here’s an example of using #:declare
https://github.com/lathe/lathe-comforts-for-racket/blob/0a91d936fddf3c356c35782384ec83ceaa29bf0d/lathe-comforts-lib/contract.rkt#L163\|https://github.com/lathe/lathe-comforts-for-racket/blob/0a91d936fddf3c356c35782384ec83ceaa29bf0d/lathe-comforts-lib/contract.rkt#L163

(the style I use to write Racket code is a little wacky, so I hope it’s not overly distracting)

You can find several more examples in the racket repo: https://github.com/racket/racket/search?q=define-syntax-class

Thanks very much all of you

I am having some trouble with #:declare
(and even ~var
) :
(define-syntax-class just-id
[pattern x:decl #:declare decl id])
complains that identifier in #:declare clause does not appear in pattern

this does not work with ~var
either

Never mind, I did not read the doc of #:declare
carefully enough

The library is not intended for external use, really. For information on how to adapt to the changes, I would contact Mike Sperber, at

Thanks for the information!

@jaz thanks for that promise example. I’m still trying to wrap my head around it :) I did a quick benchmark which confirmed my initial thoughts. The promise version is about 18x slower than stream->list ... partition ... in-list
version, and that’s probably in the best case where I just used (in-range 1000000)
to test with a pred of odd?
, so alternating odd/even.

Hi. Is there any online pollen playground? Something like the jsfiddle?

Ah… I should’ve looked at the doc for force
- it looked like either the “yes” or “no” value was lost, or thrown away, but calling force
again, on an already forced promise returns the same values.

I think a very general and probably not useful description is that parameterized syntax-classes are a lot like parameterized grammars—you get context-dependence. (Someone please correct me if I’m off-the-mark. Above CFGs, my formal languages understanding gets very fuzzy.)

I was fooling around with a version that used queues to store the evaluated, but not yet requested, elements, but I think I’d prefer a functional queue vs. the imperative one in data/queue
. Okasaki has a nice description of a functional one, so I may implement that.

The problem was of a different nature. It is fixed now and the PR is ready.

@ben.knoble I don’t think that parameterized syntax classes necessarily introduce context-dependency. Indeed, a non-parameterized syntax class can be context dependent via ~do
patterns that modify some parse state. I would describe a parameterized syntax class as a family of syntax classes that can be instantiated to particular class by providing all the arguments.

:wave: Question: How do I use https://pkgs.racket-lang.org/package/libsqlite3 ? Would like to distribute sqlite with an exe but unsure how to do so with that pkg

Installing the package then building a distribution with raco exe
followed by raco distribute
should be enough. The package puts the foreign lib in the right place and the db
lib uses define-runtime-path
to look it up so it should all work out.