flan/web/examples/ffi.flan
Joseph Ferano 98dce374d1 The FFI example declared a name the prelude now has
web/examples/ffi.flan opened with (declare cos-f64 [x f64] f64 "cos"), which
was a fine one-liner until the prelude grew cos-f64 an hour ago. @page caught
it: "cos-f64 is defined twice", with the prelude line named as the other site.

It is cosh now. Same shape, same answer, and the collision is worth keeping in
the page rather than editing around silently -- a reader reaching for a libm
function needs to know the common ones are already there and that a second
declaration of a name is refused, not shadowed. The example says so in one
sentence.

This is the cost of filling out the prelude, and it is the whole of it: a
program that declared one of the new names for itself stops compiling, with
both sites named. Nothing in the corpus or in examples/ hit it; this page did.
2026-09-17 22:06:59 +07:00

12 lines
525 B
Plaintext

;; A plain `declare` names a C symbol in a signature Flan can already spell:
;; no aggregate crosses, so no wrapper is generated.
;;
;; cosh and not cos, because the prelude already declares cos-f64 and a second
;; declaration of a name is refused with both sites named. That refusal is the
;; useful half of this example: the prelude is where the common libm calls
;; live, and a `declare` is how you reach one it does not name.
(declare cosh-f64 [x f64] f64 "cosh")
(defn main [] ()
(print (cosh-f64 0.0)) (println ""))