[plt-scheme] how to creating a new "primitve type"

From: Chongkai Zhu (czhu at cs.utah.edu)
Date: Tue May 8 15:54:46 EDT 2007

You can do it in Scheme: define "ssn" as a structure in PLT Scheme, and then 
use Readtable (chapter 11.2.8 of MzScheme) and the built-in 
prop:custom-write structure type property to do read/write.


----- Original Message ----- 
From: YC
To: mzscheme Mailing List
Sent: Tuesday, May 08, 2007 1:44 PM
Subject: [plt-scheme] how to creating a new "primitve type"

Hi all -

say that I want to create a new primitive type (something like path or 
string) so it has the first class status (for the lack of a better term) as 
the other primitive types.  How is this done, and Is this doable only in 
scheme or does it involve working on C code?

Example - social security number.

> (define s1 #ssn"123-45-6789")
> s1
> (ssn->string s1)
> (ssn? s1)
> (equal? s1 #ssn"123-45-6789")
> (equal? s1 #ssn"987-65-4321")

Any pointer is appreciated ;)  Thanks,

  For list-related administrative tasks:

Posted on the users mailing list.