soegaard2
2021-9-11 09:18:11

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


spdegabrielle
2021-9-11 09:42:02

I seem to remember something like that!


spdegabrielle
2021-9-11 09:44:40

Or two packages could not have docs with the same name?


soegaard2
2021-9-11 09:48:53

Something like that. But I can’t find a reference.


spdegabrielle
2021-9-11 09:54:04

I looked in the slack archive - unsuccessful



spdegabrielle
2021-9-11 09:58:28

Nothing in conflicts that I could see :(


soegaard2
2021-9-11 09:58:39

There is this line: doc "manual": Ibkre bystroTeX cbor noise print-debug ratchet riff simply-scheme


soegaard2
2021-9-11 09:59:18

I’ll make a PR to the noise package changing the filename.


spdegabrielle
2021-9-11 10:01:39

I’m wondering if a warning could be added to raco pkg ?


spdegabrielle
2021-9-11 10:02:21

And if it is in Scribble manual


soegaard2
2021-9-11 10:03:14

The package server could detect that particular problem.


spdegabrielle
2021-9-11 10:22:04

Better to catch it early.


ben.knoble
2021-9-11 12:31:34

Sorry there’s no search yet… works been busy


spdegabrielle
2021-9-11 12:50:53

I just used google with the site: argument


ben.knoble
2021-9-11 12:51:30

Forgot about that. I can add a link to that kind of search im pretty sure


massung
2021-9-11 16:04:42

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?


soegaard2
2021-9-11 16:11:02

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


soegaard2
2021-9-11 16:11:42

The call (datum->syntax stx '$) gives $ the lexical context of stx.


massung
2021-9-11 16:11:59

Thanks. I’ll run with that and see where I get. :slightly_smiling_face:


soegaard2
2021-9-11 16:12:56

The (let () ...) is not needed btw. I had another version without with-syntax.


soegaard2
2021-9-11 16:15:33

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


soegaard2
2021-9-11 16:18:10

For a more direct solution, look at syntax parameters: https://docs.racket-lang.org/reference/stxparam.html


soegaard2
2021-9-11 16:21:04

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)


jestarray
2021-9-11 23:09:27

how are structs layed out in memory in racket? is it a linked list or is it more like how C lays it out?


samth
2021-9-11 23:34:55

They’re contiguous


jestarray
2021-9-11 23:44:07

nice


shu--hung
2021-9-12 00:48:16

btw & fwiw, Racket recommends syntax-parse over syntax-case for better error reporting (and IMO expressiveness of the pattern language)


shu--hung
2021-9-12 00:49:37

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


shu--hung
2021-9-12 00:52:26

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