blerner
2020-9-30 10:01:40

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


samdphillips
2020-9-30 16:28:10

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


mflatt
2020-9-30 16:44:30

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.


samdphillips
2020-9-30 17:02:09

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


mflatt
2020-9-30 18:17:49

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.


samdphillips
2020-9-30 18:56:21

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!


jestarray
2020-9-30 19:52:43

(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


jaz
2020-9-30 19:54:20

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


jestarray
2020-9-30 20:01:26

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


sorawee
2020-9-30 20:03:02

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


sorawee
2020-9-30 20:03:51

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


sorawee
2020-9-30 20:05:06

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


jestarray
2020-9-30 20:13:33

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?


sorawee
2020-9-30 20:16:36

What Racket version do you have?


sorawee
2020-9-30 20:16:53

This function was just added in 7.8


sorawee
2020-9-30 20:17:14

Oh


sorawee
2020-9-30 20:17:35

You also need to require for-syntax


sorawee
2020-9-30 20:17:46

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


notjack
2020-9-30 21:04:30

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


samdphillips
2020-9-30 23:09:31

The names were not rendered as the original names iirc.