A reference type Marc Nieper-Wißkirchen (18 Aug 2022 21:45 UTC)
Re: A reference type John Cowan (19 Aug 2022 01:36 UTC)
Re: A reference type Lassi Kortela (19 Aug 2022 10:03 UTC)
Re: A reference type Marc Nieper-Wißkirchen (19 Aug 2022 10:11 UTC)
Re: A reference type Lassi Kortela (19 Aug 2022 10:25 UTC)
Places in Scheme Marc Nieper-Wißkirchen (19 Aug 2022 10:42 UTC)
Re: Places in Scheme Marc Nieper-Wißkirchen (19 Aug 2022 11:36 UTC)
Re: Places in Scheme Per Bothner (19 Aug 2022 16:33 UTC)
Re: Places in Scheme Marc Nieper-Wißkirchen (19 Aug 2022 17:58 UTC)
Re: Places in Scheme Panicz Maciej Godek (25 Aug 2022 15:20 UTC)
Re: Places in Scheme Ray Dillinger (26 Aug 2022 02:29 UTC)
Re: A reference type Marc Nieper-Wißkirchen (19 Aug 2022 10:54 UTC)
Re: A reference type Marc Nieper-Wißkirchen (19 Aug 2022 11:44 UTC)
Re: A reference type Peter Bex (19 Aug 2022 12:02 UTC)
Re: A reference type Marc Nieper-Wißkirchen (19 Aug 2022 12:26 UTC)
Big words Lassi Kortela (19 Aug 2022 16:29 UTC)
Re: Big words Marc Nieper-Wißkirchen (19 Aug 2022 18:07 UTC)
Re: Big words Lassi Kortela (19 Aug 2022 20:06 UTC)
Re: Big words Marc Nieper-Wißkirchen (19 Aug 2022 20:31 UTC)
Re: Big words blake@xxxxxx (19 Aug 2022 22:06 UTC)
Re: Big words blake@xxxxxx (19 Aug 2022 22:08 UTC)
Re: Big words Arthur A. Gleckler (19 Aug 2022 18:09 UTC)
Re: Big words John Cowan (19 Aug 2022 18:39 UTC)

Re: A reference type Marc Nieper-Wißkirchen 19 Aug 2022 11:44 UTC
Fixed source code attached.

The original version had `define-variable' in place of `define-place'.
After Lassi's hint at CL's concepts, I think the latter is much
better.

Marc

Am Fr., 19. Aug. 2022 um 12:53 Uhr schrieb Marc Nieper-Wißkirchen
<xxxxxx@gmail.com>:
>
> Your extensive knowledge is always very helpful, John!
>
> So, let us call the objects "locatives" instead.  This also has the advantage that the getter can be reasonably named "locative-ref" as would be custom in Scheme.
>
> On top of what I proposed (possibly minus the non-mutable locatives), specialized constructors should also be provided (and which may be implemented more efficiently by an implementation than by hand):
>
> * (make-list-locative LIST INDEX)
> * (make-vector-locative VECTOR INDEX)
> * (make-string-locative STRING INDEX)
> * (make-hash-table-locative HASH-TABLE KEY DEFAULT)
> * (make-hashtable-locative HASHTABLE KEY DEFAULT)
> * (make-car-locative PAIR)
> * (make-cdr-locative PAIR)
> * (make-record-locative RECORD FIELD-INDEX)
>
> On top of that, I would propose syntax like
>
> * (define-place <IDENTIFIER> <LOCATIVE-EXPRESSION>)
>
> which binds <IDENTIFIER> to an identifier macro so that <IDENTIFIER> behaves like a variable but is backed up by the location modeled by the locative.
>
> And syntax
>
> * (locative <IDENTIFIER>)
>
> which takes an identifier bound to variable-like syntax (e.g. a variable) and returns a corresponding locative.
>
> (Note that Michael Sperber's example from [1] does not work with `define-place' because a "place" (what is bound by `define-place') is not a first-class entity, but syntax.)
>
> I have attached to this post a sample implementation and a test suite for this yet-to-be-written SRFI.  The implementation is in R6RS Scheme (because it has record inspection and identifier syntax and R7RS large is not yet there), but the core parts are easily portable to R7RS-small.
>
> --
>
> [1] https://srfi-email.schemers.org/srfi-17/msg/2778611/
>
> Am Fr., 19. Aug. 2022 um 03:36 Uhr schrieb John Cowan <xxxxxx@ccil.org>:
>>
>>
>>
>> On Thu, Aug 18, 2022 at 5:45 PM Marc Nieper-Wißkirchen <xxxxxx@gmail.com> wrote:
>>
>>> I wonder whether someone would like to write a SRFI describing a
>>> reference type. With SRFI 111/SRFI 195 we have box types, but we don't
>>> have a box-like type that reuses an existing location.
>>
>>
>> Lisp has a standard term for these things of which you speak: locatives.  Zetalisp, the pre-CL of the Lisp Machine, had low-level locatives documented at <https://hanshuebner.github.io/lmman/fd-loc.xml>.  Locatives were removed from CL because they were considered not portable enough, but there is a portable package cl-locatives at <https://quickref.common-lisp.net/cl-locatives.html>.