News for hackers. Stuff that matters.
Re:“Mostly functional” programming does not work by swift on Sunday April 27, 2014 @03:55PM (#7656553)
Ptr is exactly the same thing as a C pointer. Critically, if you have a Ptr to some value, that Ptr could become invalid if the value gets moved by the garbage collector, just like a C pointer would. That's why you'd never use Ptr except in FFI code, to access memory that isn't managed by Haskell's GC. (If you need to pass a pointer to a Haskell value to code written in another language, you'd use a StablePtr, which pins the value in the Haskell heap.)

In idiomatic Haskell, if you need something like a pointer you have several choices. If you're writing parallel code your best bet is STM. If you're writing code in IO, you can use an IORef. If you don't want that restriction, you can use an STRef.

(I'm aware that you probably know all this, but other people reading the thread might not.)

Re:“Mostly functional” programming does not work by dllthomas on Sunday April 27, 2014 @04:07PM (#7656609)
Right, it's "exactly the same thing" under the hood. It's different in the roles it serves. Your elaboration is appreciated!