[Haskell-cafe] RFC: Space-leak-free, efficient symbol table implementation.

Felipe Lessa felipe.lessa at gmail.com
Sat Jan 16 17:11:59 EST 2010


Interesting code, it was nice to read, thanks!  Just a few minor
comments.

On Thu, Jan 14, 2010 at 11:33:54PM +0000, Thomas Schilling wrote:
> intern s = unsafePerformIO $ do
>   lnk <- newIORef Nothing
>   r <- newIORef $ SymInfo (hash s) lnk s
>   return (Symbol r)
>
> mkSymbolInfo :: String -> SymbolInfo
> mkSymbolInfo s = unsafePerformIO $ do
>   lnk <- newIORef Nothing
>   return $ SymInfo (hash s) lnk s

intern = fmap Symbol . newIORef . mkSymbolInfo



>         -- END OF COMMON CASE
>         --
>         -- If the symbols have been built using the same symbol table
>         -- we will only reach this case if we have a hash collision or
>         -- the symbols were built from different symbol tables.

         -- END OF COMMON CASE
         --
         -- We will only reach this case if we have a hash collision or
         -- the symbols were built from different symbol tables.

Thanks for sharing,

--
Felipe.


More information about the Haskell-Cafe mailing list