mirror of
https://github.com/carp-lang/Carp.git
synced 2024-09-19 01:18:40 +03:00
18 lines
897 B
Plaintext
18 lines
897 B
Plaintext
(doc Function "provides operations on functions.")
|
|
(defmodule Function
|
|
(doc unsafe-ptr "returns a void pointer to the function passed in.
|
|
|
|
This is unsafe as unsafe-ptr can't check the value passed in is a function.
|
|
|
|
It is the responsibility of the caller to ensure that the lifetime of the pointer
|
|
does not exceed the lifetime of the function it's used on.")
|
|
(deftemplate unsafe-ptr (Fn [(Ref a)] (Ptr ())) "void* $NAME($a *fn)" "$DECL { return fn->callback; }")
|
|
|
|
(doc unsafe-env-ptr "returns void pointer to the environment captured by a lambda.
|
|
|
|
This is unsafe as unsafe-env-ptr can't check the value passed in is a function.
|
|
|
|
It is the responsibility of the caller to ensure that the lifetime of the pointer
|
|
does not exceed the lifetime of the function it's used on.")
|
|
(deftemplate unsafe-env-ptr (Fn [(Ref a)] (Ptr ())) "void* $NAME($a *fn)" "$DECL { return fn->env; }"))
|