-
Notifications
You must be signed in to change notification settings - Fork 987
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
define-record-type methods and interfaces #596
base: main
Are you sure you want to change the base?
Conversation
…er enhancements and bug fixes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool! CSUG updates coming?
I suppose theoretically all of the edited files that have the standard copyright / license header should have the copyright date updated.
Will there be a way to ask if an object implements an interface without walking the result of |
已收到
|
@jltaylor-us I will add csug updates and a release note when and if we decide to proceed with this. Thanks for the fixes, which will be incorporated in my next commit. |
@gwatt |
Would the facilities for custom readers, writers, hash functions, and equality tests that are currently present in Chez Scheme be made part of this interface facility? |
interfaces; added new open-interface form; various other changes. see LOG for details.
@sunderroy Yes, there's nothing preventing operations on records in general from working on records with methods. |
…ization; added tests of same
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a little typo I spotted :)
(error? ; invalid syntax | ||
(define-interface (rat israt?) (methods a b c))) | ||
(error? ; invalid syntax | ||
(define-interface rat (mehtods))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(define-interface rat (mehtods))
should be
(define-interface rat (methods))
This pull request extends
define-record-type
with methods, effectively convertingdefine-record-type
into a class-definition form in support of object-oriented programming. It adds adefine-interface
form and adefine-record-type
implements
clause to support multiple interface inheritance. While object-oriented programming obscures control flow, tends to encourage an overly imperative style of programming, and is often overused when it's available, it has its uses when used judiciously. This particular OOP subsystem, at least, supports a functional style of programming: allocation and initialization is inexpensive as well as functional, and fields are immutable by default. The essentials of the implementation come from adefine-class
form that Oscar Waddel and I designed and implemented many years ago, the code for which had been sitting in mats/oop.ss; only its recasting into an extension ofdefine-record-type
is new.The pull request adds a couple of other things that are useful independently of the support for methods and interfaces; these are described in the LOG.