mirth-lang / mirth

Compiler for the Mirth programming language.
BSD Zero Clause License
447 stars 14 forks source link

Flexible external declaration. #292

Closed typeswitch-dev closed 5 months ago

typeswitch-dev commented 5 months ago

This PR expands and replaces def-external with external. The new external declaration can be used the same way as def-external, but it also allows you to make C declarations directly. E.g.,

external(
   "#include <stdio.h>"
   "void printint(int x) { printf(\"%d\", x); }"
   printint [ +World CInt -- +World ]
)

This example has both raw C declarations (the string literals), and an external function declaration printint [ +World CInt -- +World ].

Note the new syntax for declaring an external function, where the type signature is passed in the brackets:

name [ type-sig ]
name -> symbol [ type-sig ]

The old syntax (passing the type signature as a separate argument) is still supported, but not recommended.