Reason
  • Docs
  • Try
  • API
  • Community
  • Blog
  • Languages icon中文
    • 日本語
    • English
    • Deutsch
    • Español
    • Français
    • 한국어
    • Português (Brasil)
    • Русский
    • Українська
    • 繁體中文
    • 帮助翻译
  • GitHub

›Advanced Features

Intro

  • What & Why

Setup

  • Installation
  • Editor Plugins

Language Basics

  • Overview
  • Let Bindings
  • Primitives
  • Basic Structures
  • Types
  • Records
  • Variants
  • Options and nullability
  • Functions
  • Recursion
  • Destructuring
  • Pattern Matching
  • Mutable Bindings
  • Loops
  • Modules

Advanced Features

  • JSX
  • External
  • Exception
  • Object

JavaScript

  • Interop
  • Syntax Cheatsheet
  • Pipe First
  • Promise
  • Libraries
  • Converting from JS

Extra

  • Frequently Asked Questions
  • Extra Goodies
Translate

External

external,或叫 “FFI”(foreign function interface),或者更简单叫做 “interop” (interoperability 的缩写),帮助 Reason 与其他语言交流,像 C 和 JavaScript。

想象一个 let 绑定,省略实体,但是标注了类型(强制)声明。

external myCFunction: int => string = "theCFunction";

Note: externals can only be at the top level, or inside a module definition. You can't declare them in e.g. a function body.

用法

You'd use an external value/function as if it was a normal let binding.

For more infos on how to link up your C functions within your Reason application, have a look at the Dealing with foreign libraries section in the dune build system docs.

← JSXException →
  • 用法