看板 PLT 關於我們 聯絡資訊
※ 引述《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
etwas:感謝解惑! 12/31 08:06