diff --git a/am/bootstrap.am b/am/bootstrap.am index df6d19bfe..79be24ad6 100644 --- a/am/bootstrap.am +++ b/am/bootstrap.am @@ -160,6 +160,7 @@ SOURCES = \ ice-9/match.scm \ ice-9/networking.scm \ ice-9/null.scm \ + ice-9/object-properties.scm \ ice-9/occam-channel.scm \ ice-9/optargs.scm \ ice-9/peg.scm \ diff --git a/module/ice-9/boot-9.scm b/module/ice-9/boot-9.scm index 98ba4660b..5a8415059 100644 --- a/module/ice-9/boot-9.scm +++ b/module/ice-9/boot-9.scm @@ -823,30 +823,6 @@ VALUE." (define call/cc call-with-current-continuation) - - -;;; {General Properties} -;;; - -;; Properties are a lispy way to associate random info with random objects. -;; Traditionally properties are implemented as an alist or a plist actually -;; pertaining to the object in question. -;; -;; These "object properties" have the advantage that they can be associated with -;; any object, even if the object has no plist. Object properties are good when -;; you are extending pre-existing objects in unexpected ways. They also present -;; a pleasing, uniform procedure-with-setter interface. But if you have a data -;; type that always has properties, it's often still best to store those -;; properties within the object itself. - -(define (make-object-property) - ;; Weak tables are thread-safe. - (let ((prop (make-weak-key-hash-table))) - (make-procedure-with-setter - (lambda (obj) (hashq-ref prop obj)) - (lambda (obj val) (hashq-set! prop obj val))))) - - ;;; {Arrays} diff --git a/module/ice-9/buffered-input.scm b/module/ice-9/buffered-input.scm index 56b1d87cb..767dadab0 100644 --- a/module/ice-9/buffered-input.scm +++ b/module/ice-9/buffered-input.scm @@ -1,6 +1,6 @@ ;;;; buffered-input.scm --- construct a port from a buffered input reader ;;;; -;;;; Copyright (C) 2001, 2006, 2010 Free Software Foundation, Inc. +;;;; Copyright (C) 2001, 2006, 2010, 2025 Free Software Foundation, Inc. ;;;; ;;;; This library is free software; you can redistribute it and/or ;;;; modify it under the terms of the GNU Lesser General Public @@ -17,6 +17,7 @@ ;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA (define-module (ice-9 buffered-input) + #:use-module (ice-9 object-properties) #:export (make-buffered-input-port make-line-buffered-input-port set-buffered-input-continuation?!)) diff --git a/module/ice-9/deprecated.scm b/module/ice-9/deprecated.scm index d7f7a6104..e0434da98 100644 --- a/module/ice-9/deprecated.scm +++ b/module/ice-9/deprecated.scm @@ -17,8 +17,10 @@ (define-module (ice-9 deprecated) #:use-module (ice-9 guardians) + #:use-module (ice-9 object-properties) #:export ((make-guardian* . make-guardian) - module-observe-weak)) + module-observe-weak + (make-object-property* . make-object-property))) #; (define-syntax-rule (define-deprecated name message exp) @@ -40,3 +42,9 @@ from (ice-9 guardians) instead.") (issue-deprecation-warning "module-observe-weak is deprecated. Use module-observe instead.") (module-observe module proc)) + +(define (make-object-property*) + (issue-deprecation-warning + "make-object-property in the default environment is deprecated. Import +it from (ice-9 object-properties) instead.") + (make-object-property)) diff --git a/module/ice-9/object-properties.scm b/module/ice-9/object-properties.scm new file mode 100644 index 000000000..6c751a524 --- /dev/null +++ b/module/ice-9/object-properties.scm @@ -0,0 +1,43 @@ +;;; Copyright (C) 2025 Free Software Foundation, Inc. +;;; +;;; This library is free software: you can redistribute it and/or modify +;;; it under the terms of the GNU Lesser General Public License as +;;; published by the Free Software Foundation, either version 3 of the +;;; License, or (at your option) any later version. +;;; +;;; This library is distributed in the hope that it will be useful, but +;;; WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;;; Lesser General Public License for more details. +;;; +;;; You should have received a copy of the GNU Lesser General Public +;;; License along with this program. If not, see +;;; . + +;;; Commentary: +;;; +;;; Properties are a lispy way to associate random info with random +;;; objects. Traditionally properties are implemented as an alist or a +;;; plist actually pertaining to the object in question. +;;; +;;; These "object properties" have the advantage that they can be +;;; associated with any object, even if the object has no plist. Object +;;; properties are good when you are extending pre-existing objects in +;;; unexpected ways. They also present a pleasing, uniform +;;; procedure-with-setter interface. But if you have a data type that +;;; always has properties, it's often still best to store those +;;; properties within the object itself. +;;; +;;; Code: + + +(define-module (ice-9 object-properties) + ;; FIXME: Change to #:export when deprecated bindings removed. + #:replace (make-object-property)) + +(define (make-object-property) + ;; Weak tables are thread-safe. + (let ((prop (make-weak-key-hash-table))) + (make-procedure-with-setter + (lambda (obj) (hashq-ref prop obj)) + (lambda (obj val) (hashq-set! prop obj val))))) diff --git a/module/language/elisp/boot.el b/module/language/elisp/boot.el index f55722a9a..608c7c960 100644 --- a/module/language/elisp/boot.el +++ b/module/language/elisp/boot.el @@ -1,6 +1,6 @@ ;;; Guile Emacs Lisp -*- lexical-binding: t -*- -;;; Copyright (C) 2011 Free Software Foundation, Inc. +;;; Copyright (C) 2011, 2025 Free Software Foundation, Inc. ;;; This library is free software; you can redistribute it and/or modify ;;; it under the terms of the GNU Lesser General Public License as @@ -505,7 +505,8 @@ (defun lax-plist-put (plist property value) (%plist-put plist property value #'equal)) -(defvar plist-function (funcall (@ (guile) make-object-property))) +(defvar plist-function + (funcall (@ (ice-9 object-properties) make-object-property))) (defun symbol-plist (symbol) (funcall plist-function symbol)) diff --git a/module/scripts/frisk.scm b/module/scripts/frisk.scm index ae636d82d..81bbe6378 100644 --- a/module/scripts/frisk.scm +++ b/module/scripts/frisk.scm @@ -1,6 +1,6 @@ ;;; frisk --- Grok the module interfaces of a body of files -;; Copyright (C) 2002, 2006, 2010, 2011, 2020 Free Software Foundation, Inc. +;; Copyright (C) 2002, 2006, 2010, 2011, 2020, 2025 Free Software Foundation, Inc. ;; ;; This program is free software; you can redistribute it and/or ;; modify it under the terms of the GNU Lesser General Public License @@ -97,6 +97,7 @@ (define-module (scripts frisk) #:use-module (ice-9 getopt-long) + #:use-module (ice-9 object-properties) #:use-module ((srfi srfi-1) :select (filter remove)) #:export (frisk make-frisker diff --git a/module/web/http.scm b/module/web/http.scm index b65fa91c1..9270cd0f9 100644 --- a/module/web/http.scm +++ b/module/web/http.scm @@ -1,6 +1,6 @@ ;;; HTTP messages -;; Copyright (C) 2010-2017, 2023 Free Software Foundation, Inc. +;; Copyright (C) 2010-2017, 2023, 2025 Free Software Foundation, Inc. ;; This library is free software; you can redistribute it and/or ;; modify it under the terms of the GNU Lesser General Public @@ -30,13 +30,14 @@ ;;; Code: (define-module (web http) - #:use-module (srfi srfi-9) - #:use-module (srfi srfi-19) - #:use-module (ice-9 rdelim) - #:use-module (ice-9 match) #:use-module (ice-9 binary-ports) - #:use-module (ice-9 textual-ports) #:use-module (ice-9 exceptions) + #:use-module (ice-9 match) + #:use-module (ice-9 object-properties) + #:use-module (ice-9 rdelim) + #:use-module (ice-9 textual-ports) + #:use-module (srfi srfi-19) + #:use-module (srfi srfi-9) #:use-module (web uri) #:export (string->header header->string