Skip to content

Options objects with overrides #1011

Open
@jpolitz

Description

@jpolitz

[I searched for related issues but couldn't find one.]

The plot library uses a simultaneously horrific and wonderful hack to support overridable options objects in a terse way. You write:

plot(... data ..., _.{ color: "blue" })

That is, the interface expects a function of one argument that is expected to be a defaults object, and then extends/overrides it with the provided values.

Naturally, this is insane syntax to show beginners.

In the compiler, we define defaults objects for the compiler's options, and then use a style like:

default-compiler-options.{ allow-shadow: true, ignore-unbound: false }

This is pretty verbose, and requires getting the right access to the defaults object (and remembering its name, etc)

The language doesn't support the ability to just pass in an object and merge it with an existing object, since no such operator on two objects exists. A merge operator could make this work well, though it complicates typing (especially with width subtyping).

Some design is needed to identify the use cases, syntax, and semantics that options objects ought to have.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions