Pointers and references: Difference between revisions
J
No edit summary |
(J) |
||
Line 414:
These are all the operations allowed on references. The type system guarantees that a reference can never leave the monad. The IO monad has similar operations ''newIORef'', ''readIORef'', ''writeIORef''. One can also embed the ST monad in the IO monad with 'stToIO'.
=={{header|J}}==
J's "boxes" are, in essence, pointers (except with pass-by-value semantics instead of pass-by-reference semantics).
< used monadically boxes its argument (much like C's & creates a pointer to a value).
> used monadically unboxes its argument (much like C's * dereferences a pointer).
=={{header|Java}}==
|