[plt-scheme] how to creating a new "primitve type"
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.
Chongkai
----- 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"123-45-6789"
> (ssn->string s1)
"123-45-6789"
> (ssn? s1)
#t
> (equal? s1 #ssn"123-45-6789")
#t
> (equal? s1 #ssn"987-65-4321")
#f
Any pointer is appreciated ;) Thanks,
yinso
_________________________________________________
For list-related administrative tasks:
http://list.cs.brown.edu/mailman/listinfo/plt-scheme