From 3652a454d8f60f8b31e9b9ea871e6b2ed930bda8 Mon Sep 17 00:00:00 2001
From: Doug Coleman <doug.coleman@gmail.com>
Date: Fri, 7 Mar 2008 20:02:58 -0600
Subject: [PATCH] rewrite singletons to be predicate classes instead of tuples

---
 extra/singleton/singleton-docs.factor | 10 +++++-----
 extra/singleton/singleton.factor      |  8 ++++----
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/extra/singleton/singleton-docs.factor b/extra/singleton/singleton-docs.factor
index b87c557366..4ebbc9b71d 100644
--- a/extra/singleton/singleton-docs.factor
+++ b/extra/singleton/singleton-docs.factor
@@ -1,14 +1,14 @@
-USING: help.markup help.syntax ;
+USING: help.markup help.syntax kernel words ;
 IN: singleton
 
 HELP: SINGLETON:
 { $syntax "SINGLETON: class"
 } { $values
-    { "class" "a new tuple class to define" }
+    { "class" "a new singleton to define" }
 } { $description
-    "Defines a new tuple class with membership predicate name? and a default empty constructor that is the class name itself."
+    "Defines a new predicate class whose superclass is " { $link word } ".  Only one instance of a singleton may exist because classes are " { $link eq? } " to themselves.  Methods may be defined on a singleton."
 } { $examples
-    { $example "SINGLETON: foo\nfoo ." "T{ foo f }" }
+    { $example "SINGLETON: foo\nGENERIC: bar ( obj -- )\nM: foo bar drop \"a foo!\" print ;\nfoo bar" "a foo!" }
 } { $see-also
-    POSTPONE: TUPLE:
+    POSTPONE: PREDICATE:
 } ;
diff --git a/extra/singleton/singleton.factor b/extra/singleton/singleton.factor
index b745e8f902..f859cec5c0 100644
--- a/extra/singleton/singleton.factor
+++ b/extra/singleton/singleton.factor
@@ -1,10 +1,10 @@
 ! Copyright (C) 2007 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: kernel parser quotations prettyprint tuples words ;
+USING: classes.predicate kernel parser quotations words ;
 IN: singleton
 
+
 : SINGLETON:
+    \ word
     CREATE-CLASS
-    dup { } define-tuple-class
-    dup unparse create-in reset-generic
-    dup construct-empty 1quotation define ; parsing
+    dup [ eq? ] curry define-predicate-class ; parsing