You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm reading the paper about the FIP feature of koka https://www.microsoft.com/en-us/research/uploads/prod/2023/07/fip.pdf
My understanding is that the fip keyword requires a function to do no allocations or deallocations, but owned memory can (must?) be reused. All arguments to a function are owned if the ref count is 1, unless they are marked with ^, which means they are borrowed.
inline fip extern int-add : (int,int) -> int
c "kk_integer_add"
cs inline "(#1 + #2)"
js "$std_core_types._int_add"
// Add two integers.
pub fip fun (+)(x : int, y : int ) : int
int-add(x,y)
However, to my understanding ints are arbitrary precision and therefore can be stored in heap-allocated memory. So then worst case I think adding two integers would require one allocation and two deallocations. Why is this function still marked fip?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I'm reading the paper about the FIP feature of koka https://www.microsoft.com/en-us/research/uploads/prod/2023/07/fip.pdf
My understanding is that the
fip
keyword requires a function to do no allocations or deallocations, but owned memory can (must?) be reused. All arguments to a function are owned if the ref count is 1, unless they are marked with^
, which means they are borrowed.I'm looking at the
int
implementation at https://github.com/koka-lang/koka/blob/dev/lib/std/core/int.kk and notice that addition is marked asfip
.However, to my understanding
int
s are arbitrary precision and therefore can be stored in heap-allocated memory. So then worst case I think adding two integers would require one allocation and two deallocations. Why is this function still markedfip
?Beta Was this translation helpful? Give feedback.
All reactions