Skip to content

Commit

Permalink
FFI result specification allows * since pointer types were added
Browse files Browse the repository at this point in the history
  • Loading branch information
mlochbaum committed Jun 1, 2024
1 parent 5738912 commit 4f91617
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/spec/system.html
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ <h3 id="foreign-function-interface-ffi"><a class="header" href="#foreign-functio
</pre>
<p>By default, the returned function takes a list of arguments <code><span class='Value'>𝕩</span></code>, requires <code><span class='Value'>𝕨</span></code> to be an empty list if present, and returns a value corresponding to the C result. Some argument-specific rules can change this:</p>
<ul>
<li>The result type may also be the empty string <code><span class='String'>&quot;&quot;</span></code>, indicating a void or ignored result, or <code><span class='String'>&quot;&amp;&quot;</span></code>, indicating an ignored result, using a mutable argument for the BQN result, as discussed below. It can't contain any instance of the pointer rule <code><span class='Paren'>(</span> <span class='String'>&quot;*&quot;</span> <span class='Function'>|</span> <span class='String'>&quot;&amp;&quot;</span> <span class='Paren'>)</span> <span class='Value'>type</span></code>.</li>
<li>The result type may also be the empty string <code><span class='String'>&quot;&quot;</span></code>, indicating a void or ignored result, or <code><span class='String'>&quot;&amp;&quot;</span></code>, indicating an ignored result, using a mutable argument for the BQN result, as discussed below. It can't contain the character <code><span class='String'>&quot;&amp;&quot;</span></code> otherwise.</li>
<li>An argument type may be preceded by up to one <code><span class='Function'>&gt;</span></code>, and up to one <code><span class='Value'>𝕨</span></code> or <code><span class='Value'>𝕩</span></code>, in any order. Arguments with <code><span class='Value'>𝕨</span></code> are taken from <code><span class='Value'>𝕨</span></code> in order, and the others from <code><span class='Value'>𝕩</span></code>. If no arguments come from <code><span class='Value'>𝕨</span></code>, the BQN function may be called monadically. If an argument type contains <code><span class='Function'>&gt;</span></code>, it must be the only value in its BQN argument (<code><span class='Value'>𝕨</span></code> or <code><span class='Value'>𝕩</span></code>), and that argument will be treated not as a list but as an entire value.</li>
</ul>
<p>Beginning with the type declarations themselves, a <strong>number</strong> such as <code><span class='Value'>f32</span></code> corresponds to a C type with the given quality (<code><span class='Value'>i</span></code> for signed integer, <code><span class='Value'>u</span></code> for unsigned, <code><span class='Value'>f</span></code> for floating-point) and width in bits. The corresponding BQN value is a number, and should be converted exactly for integers and with rounding for decreasing-type conversions. For conversions to or from an integer type, attempting to convert a value to a type that can't contain it, or one outside of the exactly representable integer range (<code><span class='Function'>-</span><span class='Number'>2</span><span class='Function'>⋆</span><span class='Number'>53</span></code> to <code><span class='Number'>2</span><span class='Function'>⋆</span><span class='Number'>53</span></code> for IEEE doubles), results in an error.</p>
Expand Down
2 changes: 1 addition & 1 deletion spec/system.md
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ Types are to be interpreted according to the C ABI appropriate for the platform
digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"

By default, the returned function takes a list of arguments `𝕩`, requires `𝕨` to be an empty list if present, and returns a value corresponding to the C result. Some argument-specific rules can change this:
- The result type may also be the empty string `""`, indicating a void or ignored result, or `"&"`, indicating an ignored result, using a mutable argument for the BQN result, as discussed below. It can't contain any instance of the pointer rule `( "*" | "&" ) type`.
- The result type may also be the empty string `""`, indicating a void or ignored result, or `"&"`, indicating an ignored result, using a mutable argument for the BQN result, as discussed below. It can't contain the character `"&"` otherwise.
- An argument type may be preceded by up to one `>`, and up to one `𝕨` or `𝕩`, in any order. Arguments with `𝕨` are taken from `𝕨` in order, and the others from `𝕩`. If no arguments come from `𝕨`, the BQN function may be called monadically. If an argument type contains `>`, it must be the only value in its BQN argument (`𝕨` or `𝕩`), and that argument will be treated not as a list but as an entire value.

Beginning with the type declarations themselves, a **number** such as `f32` corresponds to a C type with the given quality (`i` for signed integer, `u` for unsigned, `f` for floating-point) and width in bits. The corresponding BQN value is a number, and should be converted exactly for integers and with rounding for decreasing-type conversions. For conversions to or from an integer type, attempting to convert a value to a type that can't contain it, or one outside of the exactly representable integer range (`-2⋆53` to `2⋆53` for IEEE doubles), results in an error.
Expand Down

0 comments on commit 4f91617

Please sign in to comment.