Re: [问题] '#'的意思

楼主: joshs (Josh Ko)   2012-12-30 19:49:40
※ 引述《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
作者: etwas (i'm only dust)   0000-00-00 00:00:00
感谢解惑!

Links booklink

Contact Us: admin [ a t ] ucptt.com