1

Is there a way to provide all of the functions associated with a struct without explicitly enumerating them?

For example, if I have foo.rkt:

#lang racket
(provide foo-struct) ; provide all functions, not just the constructor
(struct foo-struct (biz bop))

And then bar.rkt:

#lang racket
(require "foo.rkt")
(define foo (foo-struct 1 2)) ; works just fine
(foo-struct-biz foo) ; is undefined

Is there a way to provide foo-struct-biz and foo-struct-bop (and any other methods associated with the struct) without explicitly listing them?

2

1 Answer 1

3

Thanks to @PetSerAl in the comments, the way to do this is

(provide (struct-out foo-struct))

which will provide all of the methods associated with foo-struct.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.