[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
A new? Scheme type...
From: |
Clive Tovero |
Subject: |
A new? Scheme type... |
Date: |
Wed, 9 Mar 2022 01:14:20 +0000 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 |
HI Memo 1
"A new? Scheme type;
or Dis-joint, dat-joint, what's the point?;
or Am I completely full of BS?"
.IGNORE
I briefly had an Internet addiction "contract" with my wife--if I needed
anything she would look it up for me and print it out. For a while it
helped prevent some of my waking up screaming in the middle of the night
episodes. However, she couldn't keep up with all my requests like "What
is the dialectric breakdown voltage for the phenolic resin used in a
vacuum tube base? Can you find and price an OEM 1 MV voltage source?
Would a single carbon resistor be cheaper and have a stable, steady state?"
AN IDEA, POSSIBLY MALFORMED
One side-effect of any "moonshot" program like Grassland is the
important offshoot technology (like Tang and other space-food snacks):
When implementing a signed distance function expression compiler using
generic arithmetic, I think I discovered an important new Scheme
datatype, kind of a subtype of pair called 'tagged-data'. It really
*is* just a cons pair (type tag and contents, ala SICP), but in my
Scheme, Machinate, I have implemented it as a low-level type, disjoint
from the other object types (predicate 'tagged-data?'). This diverges a
little from R5RS, which I am trying to adhere to mostly, but the new
type has been very useful and I don't think R5RS disallows it. The main
idea of making it a disjoint primitive is that a new type can be
distinguished from just any old cons pair with a symbol as the car.
A 'tagged-data' constructor creates new objects, given a type symbol and
(possibly complicated) contents object. I have specialized and generic
versions of 'tag' and 'contents'. The generic versions of these will
return the type symbol and value, respectively, even of primitive types
like number and symbol:
mash> (define a (tagged-data 'my-new-type 3))
(tagged-data my-new-type 3)
mash> (tagged-data? a)
#t
mash> (pair? a)
#f
mash> (tag a)
my-new-type
mash> (contents a)
3
mash> (tagged-data? 15)
#f
mash> (tag 15)
number
mash> (contents 15)
15
mash> (tagged-data? (cons 'line-count 3))
#f
mash> (pair? (cons 'line-count 3))
#t
The specialized versions only work with the 'tagged-data' type. I'm also
trying to keep compatibility with MIT Scheme and was thinking today
about how I would provide the same functionality with it. I couldn't
find a way to either add a new disjoint type or a CL-style 'typeof' for
getting the primitive type of an object. Please do not say "Just use
SOS!", OOP is another addiction I'm trying to quit, CLOS-like or not.
BYE
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- A new? Scheme type...,
Clive Tovero <=