diff --git a/.gitignore b/.gitignore index e186b71..884f07b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,7 @@ +# SPDX-FileCopyrightText: 2015 Arthur A. Gleckler +# +# SPDX-License-Identifier: MIT + *~ *.swp *.import.scm diff --git a/.reuse/dep5 b/.reuse/dep5 new file mode 100644 index 0000000..dcf4359 --- /dev/null +++ b/.reuse/dep5 @@ -0,0 +1,10 @@ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: SRFI 116 +Upstream-Contact: Arthur A. Gleckler +Source: https://github.com/scheme-requests-for-implementation/srfi-116 + +# Sample paragraph, commented out: +# +# Files: src/* +# Copyright: $YEAR $NAME <$CONTACT> +# License: ... diff --git a/LICENSE b/LICENSE deleted file mode 100644 index a7b94ba..0000000 --- a/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (C) John Cowan (2015, 2016). All Rights Reserved. - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -of the Software, and to permit persons to whom the Software is furnished to do -so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/LICENSES/LicenseRef-SRFI1.txt b/LICENSES/LicenseRef-SRFI1.txt new file mode 100644 index 0000000..8d0f46a --- /dev/null +++ b/LICENSES/LicenseRef-SRFI1.txt @@ -0,0 +1,4 @@ +Copyright (c) 1998, 1999 by Olin Shivers. You may do as you please with +this code as long as you do not remove this copyright notice or +hold me liable for its use. Please send bug reports to shivers@ai.mit.edu. + -Olin diff --git a/LICENSES/MIT.txt b/LICENSES/MIT.txt new file mode 100644 index 0000000..2071b23 --- /dev/null +++ b/LICENSES/MIT.txt @@ -0,0 +1,9 @@ +MIT License + +Copyright (c) + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.org b/README.org index 2e3fe6e..eee9639 100644 --- a/README.org +++ b/README.org @@ -1,3 +1,7 @@ +# SPDX-FileCopyrightText: 2015 Arthur A. Gleckler +# +# SPDX-License-Identifier: MIT + * SRFI 116: Immutable List Library ** by John Cowan diff --git a/ilists/ilists-base.scm b/ilists/ilists-base.scm index 4312801..d7015c9 100644 --- a/ilists/ilists-base.scm +++ b/ilists/ilists-base.scm @@ -1,3 +1,8 @@ +;;;; SPDX-FileCopyrightText: 1998 - 1999 Olin Shivers +;;;; SPDX-FileCopyrightText: 2014 John Cowan +;;;; +;;;; SPDX-License-Identifier: LicenseRef-SRFI1 AND MIT + ;;;; Enhancements and hooks in Olin's SRFI-1 code to make it work for ilists ;;; The basic ilist cell diff --git a/ilists/ilists-impl.scm b/ilists/ilists-impl.scm index 38c8ad1..7b5c17f 100644 --- a/ilists/ilists-impl.scm +++ b/ilists/ilists-impl.scm @@ -1,3 +1,8 @@ +;;;; SPDX-FileCopyrightText: 1998 - 1999 Olin Shivers +;;;; SPDX-FileCopyrightText: 2014 John Cowan +;;;; +;;;; SPDX-License-Identifier: LicenseRef-SRFI1 AND MIT + ;;; SRFI-116 ilist-processing library -*- Scheme -*- ;;; Sample implementation ;;; diff --git a/ilists/ilists-test.scm b/ilists/ilists-test.scm index 0c995f4..53ff7e0 100644 --- a/ilists/ilists-test.scm +++ b/ilists/ilists-test.scm @@ -1,3 +1,7 @@ +;;;; SPDX-FileCopyrightText: 2014 John Cowan +;;;; +;;;; SPDX-License-Identifier: MIT + (use test) (use srfi-116) diff --git a/ilists/ilists.scm b/ilists/ilists.scm index 897d126..f55c232 100644 --- a/ilists/ilists.scm +++ b/ilists/ilists.scm @@ -1,3 +1,7 @@ +;;;; SPDX-FileCopyrightText: 2014 John Cowan +;;;; +;;;; SPDX-License-Identifier: MIT + (module srfi-116 () (import scheme) ;(import srfi-128) diff --git a/ilists/ilists.sld b/ilists/ilists.sld index ef40f94..5d58aa2 100644 --- a/ilists/ilists.sld +++ b/ilists/ilists.sld @@ -1,3 +1,7 @@ +;;;; SPDX-FileCopyrightText: 2014 John Cowan +;;;; +;;;; SPDX-License-Identifier: MIT + (define-library (ilists ilists) (import (scheme base)) (import (srfi 128)) diff --git a/index.html b/index.html index 9238204..e3a1508 100644 --- a/index.html +++ b/index.html @@ -1,3 +1,9 @@ + + diff --git a/srfi-116-1.1.html b/srfi-116-1.1.html index 634c371..4265a6d 100644 --- a/srfi-116-1.1.html +++ b/srfi-116-1.1.html @@ -1,3 +1,9 @@ + + diff --git a/srfi-116-1.3.html b/srfi-116-1.3.html index 74d2294..5a08a5c 100644 --- a/srfi-116-1.3.html +++ b/srfi-116-1.3.html @@ -1,3 +1,9 @@ + + @@ -178,7 +184,7 @@

Table of contents

-
  • Quotation
  • +
  • Quotation
  • The procedures -
  • Sample Implementation -
  • Acknowledgements +
  • Sample Implementation +
  • Acknowledgements
  • References & links
  • Copyright
  • @@ -205,27 +211,27 @@

    Table of contents

    Abstract

    -Scheme currently does not provide immutable pairs corresponding to its existing mutable pairs, although most uses of pairs do not exploit their mutability. The Racket system takes the radical approach of making Scheme's pairs immutable, and providing a minimal library of mutable pairs with procedures named mpair?, mcons, mcar, mcdr, set-mcar!, set-mcdr!. This SRFI takes the opposite approach of leaving Scheme's pairs unchanged and providing a full set of routines for creating and dealing with immutable pairs. The sample implementation is portable (to systems with SRFI 9) and efficient.

    - -

    Rationale

    -

    The first question about this library is why it should exist at all. Why not simply eliminate mutability from Scheme's ordinary pairs and use a version of SRFI-1 that treats the linear-update procedures (with !) as identical to their functional counterparts, as Racket does? The main answer is that this approach breaks R5RS and R7RS-small. All the data structures in these versions of Scheme are inherently mutable, and portable code is allowed to depend on that property.

    - -

    R6RS segregates set-car! and set-cdr! into a separate library, thus allowing implementations to provide immutable Scheme pairs if this library is not (transitively) imported into a program, and mutable ones if it is. However, it is not possible to write portable R6RS programs that differentiate between mutable and immutable pairs, for example by using immutable pairs most of the time and mutable pairs where necessary.

    - -

    Because of the Liskov Substitution Principle, it is not possible to treat mutable pairs as either a subtype or a supertype of mutable ones; they must be distinct, and if operations are to apply to both, they can do so only by ad hoc polymorphism of the kind that Scheme traditionally avoids for several reasons, including clarity, efficiency, and flexibility. This proposal, therefore, treats mutable and immutable pairs separately, while allowing easy conversion from one to the other.

    +Scheme currently does not provide immutable pairs corresponding to its existing mutable pairs, although most uses of pairs do not exploit their mutability. The Racket system takes the radical approach of making Scheme's pairs immutable, and providing a minimal library of mutable pairs with procedures named mpair?, mcons, mcar, mcdr, set-mcar!, set-mcdr!. This SRFI takes the opposite approach of leaving Scheme's pairs unchanged and providing a full set of routines for creating and dealing with immutable pairs. The sample implementation is portable (to systems with SRFI 9) and efficient.

    + +

    Rationale

    +

    The first question about this library is why it should exist at all. Why not simply eliminate mutability from Scheme's ordinary pairs and use a version of SRFI-1 that treats the linear-update procedures (with !) as identical to their functional counterparts, as Racket does? The main answer is that this approach breaks R5RS and R7RS-small. All the data structures in these versions of Scheme are inherently mutable, and portable code is allowed to depend on that property.

    + +

    R6RS segregates set-car! and set-cdr! into a separate library, thus allowing implementations to provide immutable Scheme pairs if this library is not (transitively) imported into a program, and mutable ones if it is. However, it is not possible to write portable R6RS programs that differentiate between mutable and immutable pairs, for example by using immutable pairs most of the time and mutable pairs where necessary.

    + +

    Because of the Liskov Substitution Principle, it is not possible to treat mutable pairs as either a subtype or a supertype of mutable ones; they must be distinct, and if operations are to apply to both, they can do so only by ad hoc polymorphism of the kind that Scheme traditionally avoids for several reasons, including clarity, efficiency, and flexibility. This proposal, therefore, treats mutable and immutable pairs separately, while allowing easy conversion from one to the other.

    +

    +Rather than attempting to design this library from scratch, I have chosen the conservative option of modifying SRFI 1. Consequently, most of the rationale given in that document applies to this one as well. I have made the following changes:

    + +
    • Removed all linear-update procedures ending in !
    • +
    • Removed all references to circular lists (there will be a future SRFI for immutable bidirectional cycles).
    • +
    • Removed the O(n2) lists-as-sets procedures (there will be a future SRFI supporting O(log n) immutable sets).
    • +
    • Inserted an i at a judicious place in each identifier, usually at the beginning. However, because "icons" means something else in both ordinary English and computer jargon, the basic constructor and its immediate relatives are named ipair, xipair and ipair* instead.
    • +
    • Added procedures for conversion between ordinary and immutable pairs, lists, and trees.
    • +
    • Added an analogue of apply for applying a procedure to an immutable list of arguments.
    • +
    • Added SRFI 114 comparators for immutable pairs, lists, and dotted lists.
    +

    -Rather than attempting to design this library from scratch, I have chosen the conservative option of modifying SRFI 1. Consequently, most of the rationale given in that document applies to this one as well. I have made the following changes:

    - -
    • Removed all linear-update procedures ending in !
    • -
    • Removed all references to circular lists (there will be a future SRFI for immutable bidirectional cycles).
    • -
    • Removed the O(n2) lists-as-sets procedures (there will be a future SRFI supporting O(log n) immutable sets).
    • -
    • Inserted an i at a judicious place in each identifier, usually at the beginning. However, because "icons" means something else in both ordinary English and computer jargon, the basic constructor and its immediate relatives are named ipair, xipair and ipair* instead.
    • -
    • Added procedures for conversion between ordinary and immutable pairs, lists, and trees.
    • -
    • Added an analogue of apply for applying a procedure to an immutable list of arguments.
    • -
    • Added SRFI 114 comparators for immutable pairs, lists, and dotted lists.
    - -

    -Note: In the prose, immutable pairs and lists are known as ipairs and ilists throughout. +Note: In the prose, immutable pairs and lists are known as ipairs and ilists throughout.

    Procedure Index

    @@ -251,7 +257,7 @@

    Procedure Index

    Selectors
    -
    icar icdr ... icddadr icddddr ilist-ref
    +
    icar icdr ... icddadr icddddr ilist-ref
     ifirst isecond ithird ifourth ififth isixth iseventh ieighth ininth itenth
     icar+icdr
     itake       idrop/ilist-tail
    @@ -304,28 +310,28 @@ 

    Procedure Index

    ialist-cons ialist-delete
    -
    Replacement -
    -
    replace-icar replace-icdr
    -
    - -
    Conversion -
    -
    pair->ipair  ipair->pair
    -list->ilist  ilist->list
    -tree->itree  itree->tree
    -gtree->itree gtree->tree
    -
    - -
    Procedure application -
    -
    iapply
    -
    - -
    Comparators -
    -
    ipair-comparator        ilist-comparator
    -make-ilist-comparator   make-improper-ilist-comparator
    +
    Replacement +
    +
    replace-icar replace-icdr
    +
    + +
    Conversion +
    +
    pair->ipair  ipair->pair
    +list->ilist  ilist->list
    +tree->itree  itree->tree
    +gtree->itree gtree->tree
    +
    + +
    Procedure application +
    +
    iapply
    +
    + +
    Comparators +
    +
    ipair-comparator        ilist-comparator
    +make-ilist-comparator   make-improper-ilist-comparator
     make-icar-comparator    make-icdr-comparator
     
    diff --git a/srfi-116-1.4.html b/srfi-116-1.4.html index 71174b0..d4a1579 100644 --- a/srfi-116-1.4.html +++ b/srfi-116-1.4.html @@ -1,3 +1,9 @@ + + @@ -178,7 +184,7 @@

    Table of contents

    -
  • Quotation
  • +
  • Quotation
  • The procedures -
  • Sample Implementation -
  • Acknowledgements +
  • Sample Implementation +
  • Acknowledgements
  • References & links
  • Copyright
  • @@ -205,27 +211,27 @@

    Table of contents

    Abstract

    -Scheme currently does not provide immutable pairs corresponding to its existing mutable pairs, although most uses of pairs do not exploit their mutability. The Racket system takes the radical approach of making Scheme's pairs immutable, and providing a minimal library of mutable pairs with procedures named mpair?, mcons, mcar, mcdr, set-mcar!, set-mcdr!. This SRFI takes the opposite approach of leaving Scheme's pairs unchanged and providing a full set of routines for creating and dealing with immutable pairs. The sample implementation is portable (to systems with SRFI 9) and efficient.

    - -

    Rationale

    -

    The first question about this library is why it should exist at all. Why not simply eliminate mutability from Scheme's ordinary pairs and use a version of SRFI-1 that treats the linear-update procedures (with !) as identical to their functional counterparts, as Racket does? The main answer is that this approach breaks R5RS and R7RS-small. All the data structures in these versions of Scheme are inherently mutable, and portable code is allowed to depend on that property.

    - -

    R6RS segregates set-car! and set-cdr! into a separate library, thus allowing implementations to provide immutable Scheme pairs if this library is not (transitively) imported into a program, and mutable ones if it is. However, it is not possible to write portable R6RS programs that differentiate between mutable and immutable pairs, for example by using immutable pairs most of the time and mutable pairs where necessary.

    - -

    Because of the Liskov Substitution Principle, it is not possible to treat mutable pairs as either a subtype or a supertype of mutable ones; they must be distinct, and if operations are to apply to both, they can do so only by ad hoc polymorphism of the kind that Scheme traditionally avoids for several reasons, including clarity, efficiency, and flexibility. This proposal, therefore, treats mutable and immutable pairs separately, while allowing easy conversion from one to the other.

    +Scheme currently does not provide immutable pairs corresponding to its existing mutable pairs, although most uses of pairs do not exploit their mutability. The Racket system takes the radical approach of making Scheme's pairs immutable, and providing a minimal library of mutable pairs with procedures named mpair?, mcons, mcar, mcdr, set-mcar!, set-mcdr!. This SRFI takes the opposite approach of leaving Scheme's pairs unchanged and providing a full set of routines for creating and dealing with immutable pairs. The sample implementation is portable (to systems with SRFI 9) and efficient.

    + +

    Rationale

    +

    The first question about this library is why it should exist at all. Why not simply eliminate mutability from Scheme's ordinary pairs and use a version of SRFI-1 that treats the linear-update procedures (with !) as identical to their functional counterparts, as Racket does? The main answer is that this approach breaks R5RS and R7RS-small. All the data structures in these versions of Scheme are inherently mutable, and portable code is allowed to depend on that property.

    + +

    R6RS segregates set-car! and set-cdr! into a separate library, thus allowing implementations to provide immutable Scheme pairs if this library is not (transitively) imported into a program, and mutable ones if it is. However, it is not possible to write portable R6RS programs that differentiate between mutable and immutable pairs, for example by using immutable pairs most of the time and mutable pairs where necessary.

    + +

    Because of the Liskov Substitution Principle, it is not possible to treat mutable pairs as either a subtype or a supertype of mutable ones; they must be distinct, and if operations are to apply to both, they can do so only by ad hoc polymorphism of the kind that Scheme traditionally avoids for several reasons, including clarity, efficiency, and flexibility. This proposal, therefore, treats mutable and immutable pairs separately, while allowing easy conversion from one to the other.

    +

    +Rather than attempting to design this library from scratch, I have chosen the conservative option of modifying SRFI 1. Consequently, most of the rationale given in that document applies to this one as well. I have made the following changes:

    + +
    • Removed all linear-update procedures ending in !
    • +
    • Removed all references to circular lists (there will be a future SRFI for immutable bidirectional cycles).
    • +
    • Removed the O(n2) lists-as-sets procedures (there will be a future SRFI supporting O(log n) immutable sets).
    • +
    • Inserted an i at a judicious place in each identifier, usually at the beginning. However, because "icons" means something else in both ordinary English and computer jargon, the basic constructor and its immediate relatives are named ipair, xipair and ipair* instead.
    • +
    • Added procedures for conversion between ordinary and immutable pairs, lists, and trees.
    • +
    • Added an analogue of apply for applying a procedure to an immutable list of arguments.
    • +
    • Added SRFI 114 comparators for immutable pairs, lists, and dotted lists.
    +

    -Rather than attempting to design this library from scratch, I have chosen the conservative option of modifying SRFI 1. Consequently, most of the rationale given in that document applies to this one as well. I have made the following changes:

    - -
    • Removed all linear-update procedures ending in !
    • -
    • Removed all references to circular lists (there will be a future SRFI for immutable bidirectional cycles).
    • -
    • Removed the O(n2) lists-as-sets procedures (there will be a future SRFI supporting O(log n) immutable sets).
    • -
    • Inserted an i at a judicious place in each identifier, usually at the beginning. However, because "icons" means something else in both ordinary English and computer jargon, the basic constructor and its immediate relatives are named ipair, xipair and ipair* instead.
    • -
    • Added procedures for conversion between ordinary and immutable pairs, lists, and trees.
    • -
    • Added an analogue of apply for applying a procedure to an immutable list of arguments.
    • -
    • Added SRFI 114 comparators for immutable pairs, lists, and dotted lists.
    - -

    -Note: In the prose, immutable pairs and lists are known as ipairs and ilists throughout. +Note: In the prose, immutable pairs and lists are known as ipairs and ilists throughout.

    Procedure Index

    @@ -251,7 +257,7 @@

    Procedure Index

    Selectors
    -
    icar icdr ... icddadr icddddr ilist-ref
    +
    icar icdr ... icddadr icddddr ilist-ref
     ifirst isecond ithird ifourth ififth isixth iseventh ieighth ininth itenth
     icar+icdr
     itake       idrop/ilist-tail
    @@ -304,28 +310,28 @@ 

    Procedure Index

    ialist-cons ialist-delete
    -
    Replacement -
    -
    replace-icar replace-icdr
    -
    - -
    Conversion -
    -
    pair->ipair  ipair->pair
    -list->ilist  ilist->list
    -tree->itree  itree->tree
    -gtree->itree gtree->tree
    -
    - -
    Procedure application -
    -
    iapply
    -
    - -
    Comparators -
    -
    ipair-comparator        ilist-comparator
    -make-ilist-comparator   make-improper-ilist-comparator
    +
    Replacement +
    +
    replace-icar replace-icdr
    +
    + +
    Conversion +
    +
    pair->ipair  ipair->pair
    +list->ilist  ilist->list
    +tree->itree  itree->tree
    +gtree->itree gtree->tree
    +
    + +
    Procedure application +
    +
    iapply
    +
    + +
    Comparators +
    +
    ipair-comparator        ilist-comparator
    +make-ilist-comparator   make-improper-ilist-comparator
     make-icar-comparator    make-icdr-comparator
     
    diff --git a/srfi-116-1.5.html b/srfi-116-1.5.html index 8fe3364..daa9436 100644 --- a/srfi-116-1.5.html +++ b/srfi-116-1.5.html @@ -1,3 +1,9 @@ + + @@ -178,7 +184,7 @@

    Table of contents

    -
  • Quotation
  • +
  • Quotation
  • The procedures -
  • Sample Implementation -
  • Acknowledgements +
  • Sample Implementation +
  • Acknowledgements
  • References & links
  • Copyright
  • @@ -205,27 +211,27 @@

    Table of contents

    Abstract

    -Scheme currently does not provide immutable pairs corresponding to its existing mutable pairs, although most uses of pairs do not exploit their mutability. The Racket system takes the radical approach of making Scheme's pairs immutable, and providing a minimal library of mutable pairs with procedures named mpair?, mcons, mcar, mcdr, set-mcar!, set-mcdr!. This SRFI takes the opposite approach of leaving Scheme's pairs unchanged and providing a full set of routines for creating and dealing with immutable pairs. The sample implementation is portable (to systems with SRFI 9) and efficient.

    - -

    Rationale

    -

    The first question about this library is why it should exist at all. Why not simply eliminate mutability from Scheme's ordinary pairs and use a version of SRFI-1 that treats the linear-update procedures (with !) as identical to their functional counterparts, as Racket does? The main answer is that this approach breaks R5RS and R7RS-small. All the data structures in these versions of Scheme are inherently mutable, and portable code is allowed to depend on that property.

    - -

    R6RS segregates set-car! and set-cdr! into a separate library, thus allowing implementations to provide immutable Scheme pairs if this library is not (transitively) imported into a program, and mutable ones if it is. However, it is not possible to write portable R6RS programs that differentiate between mutable and immutable pairs, for example by using immutable pairs most of the time and mutable pairs where necessary.

    - -

    Because of the Liskov Substitution Principle, it is not possible to treat mutable pairs as either a subtype or a supertype of mutable ones; they must be distinct, and if operations are to apply to both, they can do so only by ad hoc polymorphism of the kind that Scheme traditionally avoids for several reasons, including clarity, efficiency, and flexibility. This proposal, therefore, treats mutable and immutable pairs separately, while allowing easy conversion from one to the other.

    +Scheme currently does not provide immutable pairs corresponding to its existing mutable pairs, although most uses of pairs do not exploit their mutability. The Racket system takes the radical approach of making Scheme's pairs immutable, and providing a minimal library of mutable pairs with procedures named mpair?, mcons, mcar, mcdr, set-mcar!, set-mcdr!. This SRFI takes the opposite approach of leaving Scheme's pairs unchanged and providing a full set of routines for creating and dealing with immutable pairs. The sample implementation is portable (to systems with SRFI 9) and efficient.

    + +

    Rationale

    +

    The first question about this library is why it should exist at all. Why not simply eliminate mutability from Scheme's ordinary pairs and use a version of SRFI-1 that treats the linear-update procedures (with !) as identical to their functional counterparts, as Racket does? The main answer is that this approach breaks R5RS and R7RS-small. All the data structures in these versions of Scheme are inherently mutable, and portable code is allowed to depend on that property.

    + +

    R6RS segregates set-car! and set-cdr! into a separate library, thus allowing implementations to provide immutable Scheme pairs if this library is not (transitively) imported into a program, and mutable ones if it is. However, it is not possible to write portable R6RS programs that differentiate between mutable and immutable pairs, for example by using immutable pairs most of the time and mutable pairs where necessary.

    + +

    Because of the Liskov Substitution Principle, it is not possible to treat mutable pairs as either a subtype or a supertype of mutable ones; they must be distinct, and if operations are to apply to both, they can do so only by ad hoc polymorphism of the kind that Scheme traditionally avoids for several reasons, including clarity, efficiency, and flexibility. This proposal, therefore, treats mutable and immutable pairs separately, while allowing easy conversion from one to the other.

    +

    +Rather than attempting to design this library from scratch, I have chosen the conservative option of modifying SRFI 1. Consequently, most of the rationale given in that document applies to this one as well. I have made the following changes:

    + +
    • Removed all linear-update procedures ending in !
    • +
    • Removed all references to circular lists (there will be a future SRFI for immutable bidirectional cycles).
    • +
    • Removed the O(n2) lists-as-sets procedures (there will be a future SRFI supporting O(log n) immutable sets).
    • +
    • Inserted an i at a judicious place in each identifier, usually at the beginning. However, because "icons" means something else in both ordinary English and computer jargon, the basic constructor and its immediate relatives are named ipair, xipair and ipair* instead.
    • +
    • Added procedures for conversion between ordinary and immutable pairs, lists, and trees.
    • +
    • Added an analogue of apply for applying a procedure to an immutable list of arguments.
    • +
    • Added SRFI 114 comparators for immutable pairs, lists, and dotted lists.
    +

    -Rather than attempting to design this library from scratch, I have chosen the conservative option of modifying SRFI 1. Consequently, most of the rationale given in that document applies to this one as well. I have made the following changes:

    - -
    • Removed all linear-update procedures ending in !
    • -
    • Removed all references to circular lists (there will be a future SRFI for immutable bidirectional cycles).
    • -
    • Removed the O(n2) lists-as-sets procedures (there will be a future SRFI supporting O(log n) immutable sets).
    • -
    • Inserted an i at a judicious place in each identifier, usually at the beginning. However, because "icons" means something else in both ordinary English and computer jargon, the basic constructor and its immediate relatives are named ipair, xipair and ipair* instead.
    • -
    • Added procedures for conversion between ordinary and immutable pairs, lists, and trees.
    • -
    • Added an analogue of apply for applying a procedure to an immutable list of arguments.
    • -
    • Added SRFI 114 comparators for immutable pairs, lists, and dotted lists.
    - -

    -Note: In the prose, immutable pairs and lists are known as ipairs and ilists throughout. +Note: In the prose, immutable pairs and lists are known as ipairs and ilists throughout.

    Procedure Index

    @@ -251,7 +257,7 @@

    Procedure Index

    Selectors
    -
    icar icdr ... icddadr icddddr ilist-ref
    +
    icar icdr ... icddadr icddddr ilist-ref
     ifirst isecond ithird ifourth ififth isixth iseventh ieighth ininth itenth
     icar+icdr
     itake       idrop/ilist-tail
    @@ -304,28 +310,28 @@ 

    Procedure Index

    ialist-cons ialist-delete
    -
    Replacement -
    -
    replace-icar replace-icdr
    -
    - -
    Conversion -
    -
    pair->ipair  ipair->pair
    -list->ilist  ilist->list
    -tree->itree  itree->tree
    -gtree->itree gtree->tree
    -
    - -
    Procedure application -
    -
    iapply
    -
    - -
    Comparators -
    -
    ipair-comparator        ilist-comparator
    -make-ilist-comparator   make-improper-ilist-comparator
    +
    Replacement +
    +
    replace-icar replace-icdr
    +
    + +
    Conversion +
    +
    pair->ipair  ipair->pair
    +list->ilist  ilist->list
    +tree->itree  itree->tree
    +gtree->itree gtree->tree
    +
    + +
    Procedure application +
    +
    iapply
    +
    + +
    Comparators +
    +
    ipair-comparator        ilist-comparator
    +make-ilist-comparator   make-improper-ilist-comparator
     make-icar-comparator    make-icdr-comparator
     
    diff --git a/srfi-116-test.scm b/srfi-116-test.scm index 9e67f3d..bf97ae7 100644 --- a/srfi-116-test.scm +++ b/srfi-116-test.scm @@ -1,4 +1,8 @@ -(import +;;;; SPDX-FileCopyrightText: 2014 John Cowan +;;;; +;;;; SPDX-License-Identifier: MIT + +(import (scheme base) (srfi 128) (ilists ilists)) diff --git a/srfi-116.html b/srfi-116.html index 62874ab..65b597a 100644 --- a/srfi-116.html +++ b/srfi-116.html @@ -1,3 +1,9 @@ + + @@ -181,7 +187,7 @@

    Table of contents

  • -
  • Quotation
  • +
  • Quotation
  • The procedures -
  • Sample Implementation -
  • Acknowledgements +
  • Sample Implementation +
  • Acknowledgements
  • References & links
  • Copyright
  • @@ -208,13 +214,13 @@

    Table of contents

    Abstract

    -Scheme currently does not provide immutable pairs corresponding to its existing mutable pairs, although most uses of pairs do not exploit their mutability. The Racket system takes the radical approach of making Scheme's pairs immutable, and providing a minimal library of mutable pairs with procedures named mpair?, mcons, mcar, mcdr, set-mcar!, set-mcdr!. This SRFI takes the opposite approach of leaving Scheme's pairs unchanged and providing a full set of routines for creating and dealing with immutable pairs. The sample implementation is portable (to systems with SRFI 9) and efficient.

    +Scheme currently does not provide immutable pairs corresponding to its existing mutable pairs, although most uses of pairs do not exploit their mutability. The Racket system takes the radical approach of making Scheme's pairs immutable, and providing a minimal library of mutable pairs with procedures named mpair?, mcons, mcar, mcdr, set-mcar!, set-mcdr!. This SRFI takes the opposite approach of leaving Scheme's pairs unchanged and providing a full set of routines for creating and dealing with immutable pairs. The sample implementation is portable (to systems with SRFI 9) and efficient.

    + +

    Rationale

    +

    The first question about this library is why it should exist at all. Why not simply eliminate mutability from Scheme's ordinary pairs and use a version of SRFI-1 that treats the linear-update procedures (with !) as identical to their functional counterparts, as Racket does? The main answer is that this approach breaks R5RS and R7RS-small. All the data structures in these versions of Scheme are inherently mutable, and portable code is allowed to depend on that property.

    + +

    R6RS segregates set-car! and set-cdr! into a separate library, thus allowing implementations to provide immutable Scheme pairs if this library is not (transitively) imported into a program, and mutable ones if it is. However, it is not possible to write portable R6RS programs that differentiate between mutable and immutable pairs, for example by using immutable pairs most of the time and mutable pairs where necessary.

    -

    Rationale

    -

    The first question about this library is why it should exist at all. Why not simply eliminate mutability from Scheme's ordinary pairs and use a version of SRFI-1 that treats the linear-update procedures (with !) as identical to their functional counterparts, as Racket does? The main answer is that this approach breaks R5RS and R7RS-small. All the data structures in these versions of Scheme are inherently mutable, and portable code is allowed to depend on that property.

    - -

    R6RS segregates set-car! and set-cdr! into a separate library, thus allowing implementations to provide immutable Scheme pairs if this library is not (transitively) imported into a program, and mutable ones if it is. However, it is not possible to write portable R6RS programs that differentiate between mutable and immutable pairs, for example by using immutable pairs most of the time and mutable pairs where necessary.

    -

    Because of the Liskov Substitution Principle, it is not possible to treat immutable pairs as either a subtype or a supertype of mutable ones; they must be distinct, and if operations are to apply @@ -224,18 +230,18 @@

    Rationale

    This proposal, therefore, treats mutable and immutable pairs separately, while allowing easy conversion from one to the other.

    -Rather than attempting to design this library from scratch, I have chosen the conservative option of modifying SRFI 1. Consequently, most of the rationale given in that document applies to this one as well. I have made the following changes:

    - -
    • Removed all linear-update procedures ending in !
    • -
    • Removed all references to circular lists (there will be a future SRFI for immutable bidirectional cycles).
    • -
    • Removed the O(n2) lists-as-sets procedures (there will be a future SRFI supporting O(log n) immutable sets).
    • -
    • Inserted an i at a judicious place in each identifier, usually at the beginning. However, because "icons" means something else in both ordinary English and computer jargon, the basic constructor and its immediate relatives are named ipair, xipair and ipair* instead.
    • -
    • Added procedures for conversion between ordinary and immutable pairs, lists, and trees.
    • -
    • Added an analogue of apply for applying a procedure to an immutable list of arguments.
    • -
    • Added SRFI 114 comparators for immutable pairs, lists, and dotted lists.
    - -

    -Note: In the prose, immutable pairs and lists are known as ipairs and ilists throughout. +Rather than attempting to design this library from scratch, I have chosen the conservative option of modifying SRFI 1. Consequently, most of the rationale given in that document applies to this one as well. I have made the following changes:

    + +
    • Removed all linear-update procedures ending in !
    • +
    • Removed all references to circular lists (there will be a future SRFI for immutable bidirectional cycles).
    • +
    • Removed the O(n2) lists-as-sets procedures (there will be a future SRFI supporting O(log n) immutable sets).
    • +
    • Inserted an i at a judicious place in each identifier, usually at the beginning. However, because "icons" means something else in both ordinary English and computer jargon, the basic constructor and its immediate relatives are named ipair, xipair and ipair* instead.
    • +
    • Added procedures for conversion between ordinary and immutable pairs, lists, and trees.
    • +
    • Added an analogue of apply for applying a procedure to an immutable list of arguments.
    • +
    • Added SRFI 114 comparators for immutable pairs, lists, and dotted lists.
    + +

    +Note: In the prose, immutable pairs and lists are known as ipairs and ilists throughout.

    Procedure Index

    @@ -261,7 +267,7 @@

    Procedure Index

    Selectors
    -
    icar icdr ... icddadr icddddr ilist-ref
    +
    icar icdr ... icddadr icddddr ilist-ref
     ifirst isecond ithird ifourth ififth isixth iseventh ieighth ininth itenth
     icar+icdr
     itake       idrop/ilist-tail
    @@ -314,28 +320,28 @@ 

    Procedure Index

    ialist-cons ialist-delete
    -
    Replacement -
    -
    replace-icar replace-icdr
    -
    - -
    Conversion -
    -
    pair->ipair  ipair->pair
    -list->ilist  ilist->list
    -tree->itree  itree->tree
    -gtree->itree gtree->tree
    -
    - -
    Procedure application -
    -
    iapply
    -
    - -
    Comparators -
    -
    ipair-comparator        ilist-comparator
    -make-ilist-comparator   make-improper-ilist-comparator
    +
    Replacement +
    +
    replace-icar replace-icdr
    +
    + +
    Conversion +
    +
    pair->ipair  ipair->pair
    +list->ilist  ilist->list
    +tree->itree  itree->tree
    +gtree->itree gtree->tree
    +
    + +
    Procedure application +
    +
    iapply
    +
    + +
    Comparators +
    +
    ipair-comparator        ilist-comparator
    +make-ilist-comparator   make-improper-ilist-comparator
     make-icar-comparator    make-icdr-comparator
     
    diff --git a/srfi-116.meta b/srfi-116.meta index bee7d23..f8a6f26 100644 --- a/srfi-116.meta +++ b/srfi-116.meta @@ -1,4 +1,7 @@ -;; -*- Hen -*- +;;;; -*- Hen -*- +;;;; SPDX-FileCopyrightText: 2014 John Cowan +;;;; +;;;; SPDX-License-Identifier: MIT ((egg "srfi-116.egg") ; List of files that should be bundled alongside egg diff --git a/srfi-116.release-info b/srfi-116.release-info index 1a2f3dd..f5f452e 100644 --- a/srfi-116.release-info +++ b/srfi-116.release-info @@ -1,3 +1,7 @@ +;;;; SPDX-FileCopyrightText: 2014 John Cowan +;;;; +;;;; SPDX-License-Identifier: MIT + (uri meta-file "https://raw.githubusercontent.com/scheme-requests-for-implementation/{egg-name}/CHICKEN-{egg-release}/{egg-name}.meta") (release "1.3") diff --git a/srfi-116.setup b/srfi-116.setup index 4ff1ed5..75a431c 100644 --- a/srfi-116.setup +++ b/srfi-116.setup @@ -1,4 +1,7 @@ -;; -*- Hen -*- +;;;; -*- Hen -*- +;;;; SPDX-FileCopyrightText: 2014 John Cowan +;;;; +;;;; SPDX-License-Identifier: MIT (define (dynld-name fn) (make-pathname #f fn ##sys#load-dynamic-extension)) diff --git a/tests/run.scm b/tests/run.scm index 8d70851..c445a2e 100644 --- a/tests/run.scm +++ b/tests/run.scm @@ -1 +1,5 @@ +;;;; SPDX-FileCopyrightText: 2014 John Cowan +;;;; +;;;; SPDX-License-Identifier: MIT + (include "../ilists/ilists-test.scm")