(define-macro (bind-ext-val symname type . docstring)
`(let* ((type-str ,(if (impc:ti:typealias-exists? (symbol->string type))
(impc:ti:get-typealias-ground-type-pretty (symbol->string type))
(symbol->string type)))
(type-list (impc:ir:get-type-from-pretty-str type-str))
(ds ,(if (null? docstring) "" (car docstring))))
(llvm:compile-ir
(string-append "@" ,(symbol->string symname) " = external global " (impc:ir:get-type-str type-list)))
(impc:ti:register-new-globalvar ,(symbol->string symname) type-list ds)
(impc:aot:insert-ext-globalvar-binding-details ,(symbol->string symname) ,(symbol->string type) ds)
(impc:compiler:print-binding-details-to-log "bind-ext-val:" ,(symbol->string symname) ,(symbol->string type))))