laurent.orseau
2021-11-16 09:58:51

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)


cperivol
2021-11-16 11:46:46

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


soegaard2
2021-11-16 11:52:44

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.


samdphillips
2021-11-16 11:57:03

Those are both nice.


cperivol
2021-11-16 12:00:23

this example is very useful, thank you


cperivol
2021-11-16 12:00:54

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


cperivol
2021-11-16 12:00:55

?



cperivol
2021-11-16 12:03:20

excellen! thank you very much!


samdphillips
2021-11-16 12:05:08

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


rokitna
2021-11-16 12:11:55

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



rokitna
2021-11-16 12:24:26

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


laurent.orseau
2021-11-16 12:28:17

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


cperivol
2021-11-16 13:52:52

Thanks very much all of you


cperivol
2021-11-16 14:05:40

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


cperivol
2021-11-16 14:06:50

this does not work with ~var either


cperivol
2021-11-16 14:13:29

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


samth
2021-11-16 14:43:36

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


marsmxm
2021-11-16 15:41:36

Thanks for the information!


badkins
2021-11-16 16:05:07

@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.


rostislav.svoboda
2021-11-16 16:05:26

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


badkins
2021-11-16 16:33:58

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.


ben.knoble
2021-11-16 16:40:16

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.)


badkins
2021-11-16 17:50:16

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.


alexharsanyi
2021-11-16 21:48:56

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


kellysmith12.21
2021-11-17 00:15:58

@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.


d_run
2021-11-17 02:56:17

: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


popa.bogdanp
2021-11-17 05:56:48

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.