diff options
| author | Kimplul <kimi.h.kuparinen@gmail.com> | 2024-12-11 18:02:54 +0200 | 
|---|---|---|
| committer | Kimplul <kimi.h.kuparinen@gmail.com> | 2024-12-11 18:02:54 +0200 | 
| commit | 8ecf1531d93acda9f904f11efb2a34dfec169153 (patch) | |
| tree | 4ef636d9ef9175c188567503a7af9de12dda5789 | |
| parent | e743e30a0523d9990876cbbd56bbe1ba3e65b70e (diff) | |
| download | fwd-8ecf1531d93acda9f904f11efb2a34dfec169153.tar.gz fwd-8ecf1531d93acda9f904f11efb2a34dfec169153.zip | |
add note about closure calls
| -rw-r--r-- | README.md | 20 | 
1 files changed, 20 insertions, 0 deletions
| @@ -296,3 +296,23 @@ create_some_object((*whatever_t) next)  but I'm not entirely certain if this can be automatically detected. In theory I  guess we could implement the `safe` and `unsafe` attributes and provide wrappers  for creating `box` pointers that immediately fix the issue, but hmm. + +### Calling closure multiple times + +This is a relatively small detail, same as in Rust. Depending on how a closure +is used, it can have different properties. If the closure is called just once +(probably the most common situation), it is allowed to move captured variables. +If called multiple times, it is not, since a previous invocation might've +already moved some variables. + +Then there are also function pointers that don't have any closure attached to +them. Currently I'm thinking of using the syntax +``` + (int) - closure that can be called once +&(int) - closure that can be called multiple times +*(int) - raw function pointer, can be called multiple times +``` + +The semantics for passing these different types around seem to match variables +fairly close, where a 'call' is a kind of destructive move. The exact semantics +are still unimplemented, though. | 
