This is the latest docs version
Quick Links
  • -Overview
  • -Language Features
  • -JS Interop
  • -Build System
Documentation
Language Manual
Reference for all language features
ReScript & React
First class bindings for ReactJS
GenType
Seamless TypeScript integration
Reanalyze
Dead Code & Termination analysis
Exploration
Packages
Explore third party libraries and bindings
Syntax Lookup
Discover all syntax constructs
APIPlaygroundBlogCommunity
  • Playground
  • Blog
  • Twitter
  • GitHub
  • Forum
Mar 1, 2019

First-class bs.variadic Support in the Next Release

Hongbo Zhang
Compiler & Build System

Important: This is an archived blog post, kept for historical reasons. Please note that this information might be outdated.

An improved bs.variadic decorator

In previous releases, when a bs.variadic external (previously called bs.splice prior to version 4.08) is present, its tail arguments needed to be applied statically. In other words, the external marked with bs.variadic, when used, requires a literal array:

RE
[@bs.module "path"][@bs.variadic] external join: array(string) => string = "join" let _ = join([|"a", "b"|]) /* this is ok */ let f = b => join(b) /* compiler error when you try to abstract `join` */

More importantly, such compilation error was leaky in cases such as this one:

RE
let f = join

In the next release, we are going to lift such restriction. You'll be able to call an external marked with bs.variadic with an array reference, not just a literal array.

Caveat: it's unclear how to support such first class bs.variadic call in conjunction with bs.new, so an external declaration that contains both will trigger a compilation error. We'll try to figure out this particular case in the future too.

Want to read more?
Back to Overview

© 2024 The ReScript Project

Software and assets distribution powered by KeyCDN.

About
  • Community
  • ReScript Association
Find us on