[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: Advice on ST-Object data-structure setup
From: |
Maxime Devos |
Subject: |
RE: Advice on ST-Object data-structure setup |
Date: |
Wed, 17 Apr 2024 18:34:19 +0200 |
>is to get the mechanics working. For this I
> need to have an St-Object which is basically a Vector but which
> answers #false to vector? and #true to st-object?
>
> [Note https://github.com/KenDickey/Crosstalk/blob/master/st-kernel.scm ]
>
> I note that one might change the T7 type-tag from 0x0d (vector) to
> 0x6d (currently unused) with a quick bitwise-or, but would like some
> advice on the best way to do this or some alternate. I would prefer
> to work in Scheme, not C, BTW.
It would be simplest to define a record type with a single field, let’s say
‘<st-vectorlike>’ with a field ‘actual-vector’(*)
(*) plus whatever fields are required to make it satisfy ‘st-object?’
The objects of type <st-vectorlike> are by construction not vectors (so, they
don’t satisfy vector?). However, you can easily define
;; st-vector-ref: rename this to the equivalent of vector-ref in Smalltalk,
;; and replace ‘define’ by what would be the equivalent in Smalltalk
(define (st-vector-ref v n)
;; st-vector-like-actual-vector: field getter
;; vector-ref: standard Scheme procedure
(vector-ref (st-vector-like-actual-vector v) n))
and the like.
Best regards,
Maxime Devos.