Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Guards for record types #204

Open
jackfirth opened this issue Sep 10, 2019 · 0 comments
Open

Guards for record types #204

jackfirth opened this issue Sep 10, 2019 · 0 comments
Labels
enhancement New feature or request

Comments

@jackfirth
Copy link
Owner

Part of #42. Record types should allow guards. The signature of a record guard should match the contract (-> record-type? (-> any/c ... any)), accepting information about the record type (for error reporting purposes) and the proposed value for each field of the record. It should return one actual value to use for each field. The acceptance of the record type information and the individual fields should be separated by a partial application barrier in order to allow first-order checks on the record type (such as those used by record-guard/c, described below) without incurring check penalties on each instance construction. The fields should be processed in keyword-sorted order, in the same manner that keyword-apply and make-keyword-procedure handle keywords.

Then, the make-record-implementation function and the define-record-type macro should both accept a #:guard parameter containing a function matching the record guard contract. In order to prevent users from having to deal with field order directly, a (record-guard/c #:<kw> contract ...) contract combinator should statically sort the contracts by field keyword and construct the guard procedure. It should also use the record-type? supplied to the guard to check that the keywords given to record-guard/c match up exactly with the field names in the record type.

@jackfirth jackfirth mentioned this issue Sep 10, 2019
3 tasks
@jackfirth jackfirth added the enhancement New feature or request label Sep 10, 2019
@jackfirth jackfirth added this to the Datatypes Alpha Release milestone Sep 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant