Hi Luke Thank you ! I got it :) Best Regards Chunye Wang <chunye.w...@nsn.com>
________________________________ From: ext Luke Palmer [mailto:lrpal...@gmail.com] Sent: Tuesday, January 06, 2009 3:44 PM To: Wang, Chunye (NSN - CN/Beijing) Cc: Haskell-Cafe@haskell.org Subject: Re: [Haskell-cafe] Can I destructive rebind a local variable in haskell? 2009/1/6 Wang, Chunye (NSN - CN/Beijing) <chunye.w...@nsn.com> Dear haskeller, Can I destructive rebind a local variable like this import System.Directory test filename = do is_dir <- doesDirectoryExist filename let filename = if not is_dir then filename else filename Nope. The "filename" on the right side of the = is the same as the "filename" on the left, so you're making an infinite loop, the same way: let x = x in x is an infinite loop. However you can make a new name as you are trying, you just can't reference the old one. e.g.: let filename = 42 Here would be just fine. However, for cases like this, it is useful that single quote is a valid identifier, so you can say: let filename' = if not is_dir then filename else filename (read "filename prime") Luke
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe