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
{{ message }}
Repository navigation
Facade grammar: a variadic case that is an out-pointer (curl_easy_getinfo(h, CURLINFO_RESPONSE_CODE, &long)) has no form #3119
case CURLINFO_RESPONSE_CODE: &mut c_long is refused: "a case states an integer C type ('c_long', 'curl_off_t', an enum) or 'str'". So curl_easy_getinfo has no safe form, and every libcurl user reads the HTTP status through a raw call.
The shape is common beyond libcurl: a getter that writes a value through a pointer selected by a key (getsockopt, sqlite3_db_status, ioctl-style APIs, SDL_GetWindowSize-style multi-out). The presented surface should return the value: easy.getinfo(CURLINFO_RESPONSE_CODE)? : c_long (or Result[c_long, E] under the facade's ok contract), the compiler supplying the out-slot. Cases also need &mut CStr / &mut f64 / &mut curl_off_t (CURLINFO_EFFECTIVE_URL, TOTAL_TIME, SIZE_DOWNLOAD_T).
Done when: case K: out c_long (spelling to rule) presents a value-returning getter, with a fixture over libcurl and one non-variadic out-param API.
Brief: a variadic case that writes through an out-pointer
Question. How does a facade spell a case of a discriminated variadic function whose argument is a pointer the library writes a value through, and what does it present?
The C, from the pinned libcurl 8.23.0.Curl_getinfo (lib/getinfo.c 652 to 709) switches on the type bits of the selector and reads one argument: long *, double *, curl_off_t *, const char **, struct curl_slist ** or curl_socket_t *. Each is written only when the helper succeeds; a null pointer returns CURLE_BAD_FUNCTION_ARGUMENT.
What the spec says today. §16.2b.5 already has the word for a fixed parameter: fills param 2 is "presented as the operation's result", asserts the callee writes the record without reading it and keeps no pointer, and With passes T.zeroed(). The variadic grammar (§16.2b.5, "Discriminated variadic contracts") lets a case state "the presented With type and contract of the variadic argument"; today that type is an integer, str, a callback or a retained pointer.
Options.
A. case K: fills T. The case reuses fills: the compiler passes the address of a zeroed T as the variadic argument and the presented call returns it: easy.getinfo(CURLINFO_RESPONSE_CODE) is Result[c_long, CurlError] under the function's ok contract. One word, one meaning, already defined.
B. case K: out T. A new word that means the same thing as fills in one position. Two spellings for one meaning.
C. case K: &mut T (what the issue's first attempt wrote). There is no &mut T in safe code (D172), and it would make the caller declare and pass a slot the compiler can supply.
What others do. Rust's curl crate hand-writes one method per info (response_code() -> Result<u32>); Go's and Python's bindings return the value from one getinfo. Nobody makes the caller pass a slot.
Mission fit. The slot is determined by the case, so the programmer writing it is ceremony (Law 1). The value's meaning needs the status: a failed call leaves the slot unwritten, so the result is only presented under the function's ok contract; without one the case is refused, never a zero presented as an answer.
Three points the words must settle.
T is an integer, a float, or a flat value record (§16.2b.3's zero-valid rule, as for fills).
A case that hands back a pointer (CURLINFO_EFFECTIVE_URL: const char **, owned by the handle) is not fills: it is a borrowed return and needs returns borrow words of its own. I would leave it out of this ruling and keep those cases raw.
A draft never states it from the C alone: the proof is that the callee reads exactly one T * under that selector, writes it without reading, and keeps nothing (the D213 variadic store proof, pointed the other way).
Prediction: A, 80%. Proposed sentence for §16.2b.5, after the callback-case paragraph:
A case may state fills T: the variadic argument is a pointer to one T that the callee writes without reading and does not keep. With passes the address of a zeroed T and presents the value as the operation's result, under the function's ok contract; a function with no ok contract cannot state the case.
This is normative spec text, so it waits for Eric's words.
Labelled human attn needed: the brief above is finished and the only thing missing is Eric's blessing of the §16.2b.5 sentence (case K: fills T). Implementation follows the words.
Yes to case K: fills T, with one added clause. The blessed sentence for §16.2b.5:
A case may state fills T: the variadic argument is a pointer to one T that the callee writes without reading and does not keep. T obeys the rule for fills on a fixed parameter. With passes the address of a zeroed T and presents the value as the operation's result, under the function's ok contract; a function with no ok contract cannot state the case.
Activity
ehartford commentedon Nov 23, 2026
Brief: a variadic case that writes through an out-pointer
Question. How does a facade spell a case of a discriminated variadic function whose argument is a pointer the library writes a value through, and what does it present?
The C, from the pinned libcurl 8.23.0.
Curl_getinfo(lib/getinfo.c 652 to 709) switches on the type bits of the selector and reads one argument:long *,double *,curl_off_t *,const char **,struct curl_slist **orcurl_socket_t *. Each is written only when the helper succeeds; a null pointer returnsCURLE_BAD_FUNCTION_ARGUMENT.What the spec says today. §16.2b.5 already has the word for a fixed parameter:
fills param 2is "presented as the operation's result", asserts the callee writes the record without reading it and keeps no pointer, and With passesT.zeroed(). The variadic grammar (§16.2b.5, "Discriminated variadic contracts") lets a case state "the presented With type and contract of the variadic argument"; today that type is an integer,str, a callback or a retained pointer.Options.
case K: fills T. The case reusesfills: the compiler passes the address of a zeroedTas the variadic argument and the presented call returns it:easy.getinfo(CURLINFO_RESPONSE_CODE)isResult[c_long, CurlError]under the function'sokcontract. One word, one meaning, already defined.case K: out T. A new word that means the same thing asfillsin one position. Two spellings for one meaning.case K: &mut T(what the issue's first attempt wrote). There is no&mut Tin safe code (D172), and it would make the caller declare and pass a slot the compiler can supply.What others do. Rust's
curlcrate hand-writes one method per info (response_code() -> Result<u32>); Go's and Python's bindings return the value from onegetinfo. Nobody makes the caller pass a slot.Mission fit. The slot is determined by the case, so the programmer writing it is ceremony (Law 1). The value's meaning needs the status: a failed call leaves the slot unwritten, so the result is only presented under the function's
okcontract; without one the case is refused, never a zero presented as an answer.Three points the words must settle.
Tis an integer, a float, or a flat value record (§16.2b.3's zero-valid rule, as forfills).CURLINFO_EFFECTIVE_URL:const char **, owned by the handle) is notfills: it is a borrowed return and needsreturns borrowwords of its own. I would leave it out of this ruling and keep those cases raw.T *under that selector, writes it without reading, and keeps nothing (the D213 variadic store proof, pointed the other way).Prediction: A, 80%. Proposed sentence for §16.2b.5, after the callback-case paragraph:
This is normative spec text, so it waits for Eric's words.
ehartford commentedon Nov 23, 2026
Labelled
human attn needed: the brief above is finished and the only thing missing is Eric's blessing of the §16.2b.5 sentence (case K: fills T). Implementation follows the words.ehartford commentedon Nov 25, 2026
Ruled by Eric, 2026-11-25 (answers to briefs.md).
Yes to
case K: fills T, with one added clause. The blessed sentence for §16.2b.5:Label removed; implementation is mine.