作者joshs (Josh Ko)
看板PLT
标题Re: [问题] '#'的意思
时间Sun Dec 30 19:49:40 2012
※ 引述《etwas (i'm only dust)》之铭言:
: 各位版友好
: 想请问在source code中 '(#', '#)'是什麽意思? 例如:
: instance Monad (ST s) where
: return x = ST (\ s -> (# s, x #))
: 这在哪里的文件有提到呢?
: 谢谢
这是 GHC 的 unboxed tuples:
Unboxed tuples are used for functions that need to return
multiple values, but they avoid the heap allocation normally
associated with using fully-fledged tuples. When an unboxed
tuple is returned, the components are put directly into
registers or on the stack; the unboxed tuple itself does not
have a composite representation. Many of the primitive
operations listed in primops.txt.pp return unboxed tuples.
In particular, the IO and ST monads use unboxed tuples to
avoid unnecessary allocation during sequences of operations.
以上摘自
http://www.haskell.org/ghc/docs/latest/html/users_guide/primitives.html
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 86.2.123.53
1F:→ etwas:感谢解惑! 12/31 08:06