Thank you! <br><br>Yes it does help. <br><br>I'm trying to work out the class.ss equivalent of java class methods and fields like this; <br><br><blockquote style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;" class="gmail_quote">
<span style="font-family: courier new,monospace;">public class ActivityManager extends Thread {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">[...]</span><span style="font-family: courier new,monospace;">
</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> private synchronized static ActivityManager getInstance() {</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> if ( s_instance == null || !s_instance.isAlive() ) {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> s_instance = new ActivityManager();
</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> }</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> return s_instance;
</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> }</span><br style="font-family: courier new,monospace;"></blockquote><span style="font-family: courier new,monospace;">
</span><span style="font-family: courier new,monospace;"></span>[code from <a href="http://prefuse.org">prefuse.org</a>; I'm porting bits to scheme]<br><br>Do you mind if I put your example in the scheme cookbook?<br>
(in or near <a href="http://schemecookbook.org/Cookbook/IntroductionToMzlibClasses">http://schemecookbook.org/Cookbook/IntroductionToMzlibClasses</a> )<br><br>The 'Factory Pattern' is next for me. Any suggestions gratefully accepted.
<br><br>Cheers,<br><br><br>Stephen<br><br><br><br><br><br>On Dec 11, 2007 2:58 AM, Matthias Felleisen <<a href="mailto:matthias@ccs.neu.edu">matthias@ccs.neu.edu</a>> wrote:<br>> On Dec 10, 2007, at 8:48 PM, Stephen De Gabrielle wrote:
<br>> <br>> > Hi, I'm trying to replicate the 'singleton' pattern using class.ss,<br>> > but I'm having a little trouble. Can anyone point of to an example?<br>> <br>> <br>> One of the things you can do is instantiate a class once and export
<br>> only that instance:<br>> <br>> (module singleton mzscheme<br>> <br>> (require (lib "class.ss"))<br>> <br>> (define one%<br>> (class object%<br>> (super-new)<br>
> (define/public (hello) one))<br>> <br>> (define one (new one%))<br>> <br>> (provide one))<br>> <br>> Inside the class you never use new; instead you refer to this<br>> instance. Does this help?
<br>> <br>> -- Matthias<br>> <br>> <br>> <br><br><br><br>-- <br>Cheers,<br><br>Stephen<br><br><br><br>--<br>Stephen De Gabrielle<br><a href="mailto:s.degabrielle@ucl.ac.uk">s.degabrielle@ucl.ac.uk</a><br>Telephone +44 (0)20 7679 5242 (x45242)
<br>Mobile 079 851 890 45<br><a href="http://www.uclic.ucl.ac.uk/annb/MaSI.html">http://www.uclic.ucl.ac.uk/annb/MaSI.html</a><br>University College London Interaction Centre<br>Remax House - 31/32 Alfred Place
<br>London - WC1E 7DP<br>