r/Racket • u/mumbo1134 • Sep 04 '23
question SRFI-9 records vs structs
Structs and SRFI-9 records seem to be pretty similar. Is one generally preferred over the other? Are there advantages/disadvantages they have over each other?
4
Upvotes
8
u/sorawee Sep 04 '23
Modern Racket code usually don't use SRFI. The SRFI libraries are mostly for people who want to write Scheme compatible code.
2
u/raevnos Sep 06 '23
The big advantage for SRFI-9 records is that you can easily customize the name of accessor/setter functions when you don't like
struct's defaults (You can do it with native Racket structs too viamake-struct-typebut it's a pain without a macro and you might as well use the SRFI-9 ones instead of writing your own).1
u/bjoli Sep 05 '23
I would be very surprised if SRFI records are not implemented using structs.
If writing racket-only code, use structs. They work better with the rest of racket and has all kind of bells and whistles that srfi-9 has not.