Next: Package License, Previous: labels, Up: Top [Contents][Index]
Friend functions are used to access private, public and protected members of a record–type from outside of the record–type’s methods.
Define a function like define/checked
would do, but give
private access to the members of the record–type ?type for the
argument ?subject.
The new function is not a member of the record–type, so it does not influence the compliance of the record–type with interface types.
Usage example:
(define-record-type <duo> (private (fields one two))) (define/friend ({add <number>} {O <duo>}) (+ (.one O) (.two O))) (define O (new <duo> 1 2)) (add O) ⇒ 3