
@asumu or others — has the racket PPA been updated to v7.8?

Is it possible in scribble to document two procedures with the same name (from different modules) in a single document/file?

It should just work, as long as the different modules are declared for the enclosing sections. They do have to be in different sections, though, since the module declaration is section-scoped.

Ok. I was trying to pull in names via (for-labels ...)
and defmodule
, when I should be using defmodule
only?

Oh, yes, that’s a catch. You can’t import conflicting bindings with for-label
. Simplest is to put the sections in different modules (and simplest for that is different “.scrbl” files), although it’s also possible to use macros and create different scopes within a module.

I think I can get away with not having the names imported for-label
. I’ll see how far I can get with that. Thanks!

(define-struct person (name age) #:transparent)
; I want to construct and use Person like this:
(define p (person "bob" 44))
(person-age p)
; But eventually I want to export the field name to go along with the data as a pair, e.g:
(person '(name . "bob") '(age . 44))
so is there a way to loop over all the field names and values of a struct definition? or is there a simpler way of doing this

Struct field names don’t exist at runtime, so no.

ahh kk thanks. I found struct->vector
to get all the values out. I’ll just copy and paste the list of field names and map them

If you have the compile-time binding person
, you can use struct-field-info-list
to get field names.

Alternatively, you can just use a third party struct-like forms whose printing includes field names, like https://docs.racket-lang.org/rebellion/Record_Types.html

Do note that it’s printing, so you will get string representation, not values.

when i try to run the example, it doesnt work? (require racket/struct-info)
(struct foo (x))
(struct bar foo (y z))
(define-syntax (get-bar-field-names stx)
#`'#,(struct-field-info-list (syntax-local-value #'bar)))
error: . struct-field-info-list: reference to an unbound identifier
at phase: 1; the transformer environment
context...:
matching binding...:
common scopes...: in: struct-field-info-list
how would i import it?

What Racket version do you have?

This function was just added in 7.8

Oh

You also need to require for-syntax

(require (for-syntax racket/struct-info))
(struct foo (x))
(struct bar foo (y z))
(define-syntax (get-bar-field-names stx)
#`'#,(struct-field-info-list (syntax-local-value #'bar)))

What happens if you rename-in
the for-label
imports?

The names were not rendered as the original names iirc.