The package server builds the manual for noise
. The result is here: https://docs.racket-lang.org/manual@noise/index.html Seaching for “noise” on http://docs.racket-lang.org\|docs.racket-lang.org doesn’t turn up anything.
Is the problem that the manual is named “manual.scbrl”? https://github.com/jpverkamp/noise
I seem to remember something like that!
Or two packages could not have docs with the same name?
Something like that. But I can’t find a reference.
I looked in the slack archive - unsuccessful
Conflicts be the cause? https://pkg-build.racket-lang.org/conflicts.txt\|https://pkg-build.racket-lang.org/conflicts.txt
Nothing in conflicts that I could see :(
There is this line: doc "manual":
Ibkre bystroTeX cbor noise print-debug ratchet riff simply-scheme
I’ll make a PR to the noise package changing the filename.
I’m wondering if a warning could be added to raco pkg
?
And if it is in Scribble manual
The package server could detect that particular problem.
Better to catch it early.
Sorry there’s no search yet… works been busy
I just used google with the site:
argument
Forgot about that. I can add a link to that kind of search im pretty sure
so, a macro pattern in CL is something like… (defmacro (... &body body)
(let (($ (intern "$" *package*)))
`(let ((,$ some-value-derived-from-...))
,@body)))
And now inside body
the symbol $
can be used.
I’d like to do the same in Racket. For example, I’m thinking of something like threading (~>
), but where instead of assuming the threaded value is the first or last argument, it can be woven using predefined symbol like %
:
(%~> 3 (* %) sqrt (format "sqrt(~a * ~a) = ~a" % % %) displayln)
But for the life of me I’m not seeing how to use syntax-case
in order to accomplish it. I’ve been trying to use the literal-id
binding in syntax-case
, but to no avail (as it fails when using ...
following it). Just wondering if someone with some better scheme-macro-fu can show me what little tidbit I’m missing?
In the simplest case: #lang racket
(define-syntax (foo stx)
(syntax-case stx ()
[(_foo . body)
(let ()
(with-syntax ([$ (datum->syntax stx '$)])
(syntax/loc stx
(let ([$ 42])
. body))))]))
(foo (+ $ 1))
The call (datum->syntax stx '$)
gives $ the lexical context of stx.
Thanks. I’ll run with that and see where I get. :slightly_smiling_face:
The (let () ...)
is not needed btw. I had another version without with-syntax.
It’s common practice to define $ before foo
to something that throws an error, when used outside foo. (define-syntax ($ stx)
#'(raise-syntax-error '$ "used outside context"))
For a more direct solution, look at syntax parameters: https://docs.racket-lang.org/reference/stxparam.html
The idea is the same: 1. Use define-syntax-parameter
to make $ a syntax parameter (like the (define-syntax ($ stx) ...)
as before) 2. In foo
use syntax-parameterize
to change the meaning of $ inside the body. (like the explicit let in the definition of foo
above)
how are structs layed out in memory in racket? is it a linked list or is it more like how C lays it out?
They’re contiguous
nice
btw & fwiw, Racket recommends syntax-parse
over syntax-case
for better error reporting (and IMO expressiveness of the pattern language)
Here is an example of syntax parameters. It lets you locally adjust the macro transformer associated with a binding. https://github.com/syntax-objects/Summer2021/issues/20
Such “capturing an identifier in the body” is a classic example of “hygiene bending” — but it comes with composition problems and syntax parameters solved them as explained in https://scholar.google.com/citations?view_op=view_citation&hl=en&user=kOCAgCoAAAAJ&citation_for_view=kOCAgCoAAAAJ:roLk4NBRz8UC