[change atom to use the LSB to denote validity, it also should never be negative.
John Meacham <john@repetae.net>**20080210122835] hunk ./E/Annotate.hs 142
-    | isEtherialId i || i == 0 || i `mmember` ss = nv (fromList [ (x,undefined) | x <- xs ] `mappend` ss)
+    | isInvalidId i || i `mmember` ss = nv (fromList [ (x,undefined) | x <- xs ] `mappend` ss)
hunk ./E/Subst.hs 153
-    | isEtherialId i || i == 0 || i `mmember` ss = nv (fromList [ (x,undefined) | x <- xs ] `mappend` ss)
+    | isInvalidId i || i `mmember` ss = nv (fromList [ (x,undefined) | x <- xs ] `mappend` ss)
hunk ./Name/Id.hs 14
+    isInvalidId,
hunk ./Name/Id.hs 160
+-- Id types
+-- odd - an atom
+-- 0 - special, indicating lack of binding
+-- negative - etherial id, used as placeholder within algorithms
+-- positive and even - arbitrary numbers.
+
hunk ./Name/Id.hs 167
-etherialIds = [-1, -2 .. -100 ]
-isEtherialId id = id < 0 && id >= -100
+etherialIds = [-2, -4 ..  ]
+isEtherialId id = id < 0
+isInvalidId id = id <= 0
hunk ./Name/Name.hs 170
-fromId i | not $ isValidAtom i = fail $ "Name.fromId: not a name " ++ show i
-fromId i = return $ case intToAtom i of
-    Just a -> Name a
-    Nothing -> error $ "Name.fromId: not a name " ++ show i
+--fromId i | not $ isValidAtom i = fail $ "Name.fromId: not a name " ++ show i
+fromId i = case intToAtom i of
+    Just a -> return $ Name a
+    Nothing -> fail $ "Name.fromId: not a name " ++ show i
hunk ./StringTable/Atom.hsc 97
-    fromAtom a@(Atom v) = (stPtr a,fromIntegral $ v .&. (#const ATOM_LEN_MASK))
+    fromAtom a@(Atom v) = (stPtr a,fromIntegral $ (v `shiftR` (#const ATOM_LEN_SHIFT)) .&. (#const ATOM_LEN_MASK))
hunk ./StringTable/Atom.hsc 124
-isValidAtom i = i < -100
+isValidAtom i = odd i
hunk ./StringTable/StringTable_cbits.c 8
-#define NDEBUG 1
+//  #define NDEBUG 1
hunk ./StringTable/StringTable_cbits.c 16
-#define pthread_mutex_lock(x) ;
-#define pthread_mutex_unlock(x) ;
+// #define pthread_mutex_lock(x) ;
+// #define pthread_mutex_unlock(x) ;
hunk ./StringTable/StringTable_cbits.c 29
-#define CHUNK_SIZE 32768
+#define CHUNK_SIZE 16384
hunk ./StringTable/StringTable_cbits.c 33
-#define ATOM_LEN(c)     (((atom_t)(c)) & ATOM_LEN_MASK)
-#define CHUNK_INDEX(c)  (((atom_t)(c) >> 8)&0xFF)
-#define CHUNK_OFFSET(c) (((atom_t)(c) & ~VALID_BITMASK) >> 16 )
+#define ATOM_LEN(c)     (((atom_t)(c) >> ATOM_LEN_SHIFT) & ATOM_LEN_MASK)
+#define CHUNK_INDEX(c)  (((atom_t)(c) >> 9)&0xFF)
+#define CHUNK_OFFSET(c) (((atom_t)(c) >> 17) & 0x3FFF)
hunk ./StringTable/StringTable_cbits.c 37
-#define MAKE_ATOM(ci,co,len) ((((len) & 0xFF) | ((((unsigned)ci) & 0xff) << 8) | (((unsigned)co) << 16))|VALID_BITMASK)
+#define MAKE_ATOM(ci,co,len) ((((((atom_t)len) & ATOM_LEN_MASK) << ATOM_LEN_SHIFT) | ((((atom_t)ci) & 0xff) << 9) | (((atom_t)co & 0x3FFF) << 17)) | VALID_BITMASK)
hunk ./StringTable/StringTable_cbits.c 41
-#define ATOM_VALID(a) ((a) & VALID_BITMASK)
+#define ATOM_VALID(a) (a)
+
+// ((a) & VALID_BITMASK)
hunk ./StringTable/StringTable_cbits.c 314
-char *
+unsigned char *
hunk ./StringTable/StringTable_cbits.h 7
-#define VALID_BITMASK 0x80000000
+#define VALID_BITMASK 0x1
+
+// always shift, then mask
hunk ./StringTable/StringTable_cbits.h 11
+#define ATOM_LEN_SHIFT 1
hunk ./StringTable/StringTable_cbits.h 19
-char *stringtable_ptr(atom_t cl);
+unsigned char *stringtable_ptr(atom_t cl);
hunk ./selftest/SelfTest.hs 3
-import List(sort)
+import List(sort,nub)
hunk ./selftest/SelfTest.hs 40
+    quickCheck $ label "atomint" prop_atomint
+    quickCheck $ label "atomii" prop_atomii
hunk ./selftest/SelfTest.hs 64
+prop_atomint xs = an > 0 && odd an where
+    an = fromAtom $ toAtom (xs :: String) :: Int
+
+prop_atomii xs = Just xs == fromAtom `fmap` (intToAtom an) where
+    an = fromAtom $ toAtom (xs :: String) :: Int
hunk ./selftest/SelfTest.hs 117
-    let prop_list x xs = List.delete x xs == toList p where
+    let prop_list x xs = sort (List.delete x $ nub xs) == toList p where
hunk ./selftest/SelfTest.hs 121
-    quickCheck prop_list
-    quickCheck prop_enum
+    quickCheck $ label "prop_list"  prop_list
+    quickCheck $ label "prop_enum"  prop_enum