Skip to content

Commit

Permalink
Prevent users from accidentally intercept initialize method
Browse files Browse the repository at this point in the history
  • Loading branch information
shirok committed Jan 12, 2025
1 parent ba7e04c commit ba00e84
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
6 changes: 6 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
2025-01-11 Shiro Kawai <[email protected]>

* src/libobj.scm (initialize): Define locked method for <top> and
<object> to prevent user code accidentally overrides them.
https://github.com/shirok/Gauche/issues/1085

2025-01-10 Shiro Kawai <[email protected]>

* lib/control/pmap.scm: Make sure all worker threads are joined,
Expand Down
9 changes: 9 additions & 0 deletions src/libobj.scm
Original file line number Diff line number Diff line change
Expand Up @@ -746,6 +746,15 @@
(cond [(assq slot-name (slot-ref class 'accessors)) => cdr]
[else #f]))

;;----------------------------------------------------------------
;; Generic initialize

;; These prevent users accidentally define `initialize` on <top>.
(define-method initialize :locked ((obj <top>) initargs)
(next-method))
(define-method initialize :locked ((obj <object>) initargs)
(next-method))

;;----------------------------------------------------------------
;; Generic coercion
;; (should this be in separate file, e.g. coerce.scm?
Expand Down

0 comments on commit ba00e84

Please sign in to comment.