I have searched the documentation for Racket (the language; non-typed) and have been unable to decide if it is possible to have optional arguments for a non-mutable struct. I would like to be able to do:
(struct q-a-website (name interest-value #syntax? some-optional-field))
... (q-a-website "stack-overflow" 42 "My name is Jon Skeet") ...
... (q-a-website "quora" -inf.0) ...
In this pseudo-example, #syntax?
is just a placeholder for where I suspect some special syntax might reside to make the following field optional. Is there a way to make your everyday, immutable, run-of-the-mill struct have optional arguments in base Racket?
Clarification: If a struct is created without the optional parameter, it is filled in with a default value that must be supplied at creation time. In this instance, that information would have to be contained inside of the (perhaps poorly named) #syntax?
block.
(Note: I have reservations regarding the inclusion of the struct
tag to this question as it mentions the C family of languages to which Racket does not belong...)