Hi Chongkai - <br><br>thanks for the helpful answers.&nbsp; I am reading up on the links right now and try to digest it. <br><br>At first I thought struct doesn&#39;t have custom constructor for validation logic until I saw guard-proc - so that should solve the data validation problem.&nbsp; So now the question is - should the parse/validation logic reside in readtable as well?  Or is it okay to let readable construct the object, but only receive an error from the construction? 
<br><br>Thanks,<br>yinso <br><br><div><span class="gmail_quote">On 5/8/07, <b class="gmail_sendername">Chongkai Zhu</b> &lt;<a href="mailto:czhu@cs.utah.edu">czhu@cs.utah.edu</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
&gt; You can do it in Scheme: define &quot;ssn&quot; as a structure in PLT Scheme, and<br>&gt; then use Readtable (chapter 11.2.8 of MzScheme) and the built-in<br>&gt; prop:custom-write structure type property to do read/write.
<br><br>To make &quot;equal?&quot; work is a little tricky. Normally you will need to<br>re-define &quot;equal?&quot;:<br><br>(define (my-equal? p1 p2)<br>&nbsp;&nbsp;(if (and (ssn? p1)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (ssn? p2))<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;;your code to tell whether two ssn equal?
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(equal? p1 p2)))<br><br>If you use modules, than you can creat your own language as a extension of<br>MzScheme: export &quot;my-equal?&quot; as &quot;equal?&quot;, and everything else from MzScheme.<br><br>&gt; Chongkai
<br>&gt;<br>&gt; ----- Original Message -----<br>&gt; From: YC<br>&gt; To: mzscheme Mailing List<br>&gt; Sent: Tuesday, May 08, 2007 1:44 PM<br>&gt; Subject: [plt-scheme] how to creating a new &quot;primitve type&quot;<br>
&gt;<br>&gt;<br>&gt; Hi all -<br>&gt;<br>&gt; say that I want to create a new primitive type (something like path or<br>&gt; string) so it has the first class status (for the lack of a better term)<br>&gt; as the other primitive types.&nbsp;&nbsp;How is this done, and Is this doable only
<br>&gt; in scheme or does it involve working on C code?<br>&gt;<br>&gt; Example - social security number.<br>&gt;<br>&gt;&gt; (define s1 #ssn&quot;123-45-6789&quot;)<br>&gt;&gt; s1<br>&gt; #ssn&quot;123-45-6789&quot;<br>
&gt;&gt; (ssn-&gt;string s1)<br>&gt; &quot;123-45-6789&quot;<br>&gt;&gt; (ssn? s1)<br>&gt; #t<br>&gt;&gt; (equal? s1 #ssn&quot;123-45-6789&quot;)<br>&gt; #t<br>&gt;&gt; (equal? s1 #ssn&quot;987-65-4321&quot;)<br>&gt; #f<br>
&gt;<br>&gt; Any pointer is appreciated ;)&nbsp;&nbsp;Thanks,<br>&gt; yinso<br>&gt;<br>&gt;<br>&gt;<br>&gt;<br>&gt;<br>&gt; _________________________________________________<br>&gt;&nbsp;&nbsp;For list-related administrative tasks:<br>&gt;&nbsp;&nbsp;
<a href="http://list.cs.brown.edu/mailman/listinfo/plt-scheme">http://list.cs.brown.edu/mailman/listinfo/plt-scheme</a><br>&gt; _________________________________________________<br>&gt;&nbsp;&nbsp;For list-related administrative tasks:
<br>&gt;&nbsp;&nbsp;<a href="http://list.cs.brown.edu/mailman/listinfo/plt-scheme">http://list.cs.brown.edu/mailman/listinfo/plt-scheme</a><br>&gt;<br><br></blockquote></div><br>