Skip to content

Disable support for splitting rest parameters in chained calculations #2485

@josdejong

Description

@josdejong

From the discussion in #2474:

We want to disable support for splitting rest parameters like math.chain(2).std(3,3,4), this is not something you need or want in practice.

To do so, @gwhitney proposes the following implementation (#2474 (comment)):

A) In typed-function, expose a function typed.isTypedFunction(x) (well, or use the one already in import.js but really it ought to come from typed-function and import should be changed to use that).

B) In typed-function, expose a function typed.resolve(fn: typedFunction, argList: Array.) that returns the object with the specific signature and implementation function that the call fn(argList[0], argList[1], ...) would reach. [Note that neither A or B is a breaking change to typed-function, so that's convenient.]

C) In chainify in Chain.js, if there are any arguments in the latest call, rather than just applying fn to the args, instead call the "resolve" function from part (B). If it returns a signature that consists entirely of a single rest parameter, issue an error message that a rest parameter may not be split across a chain() constructor and a subsequent call; otherwise, apply the returned implementation function to the assembled argument list.

That makes sense to me, though for step (B) it's probably enough to have this resolve function return a string with the matching signature, which you can use next via myTypedFunction.signatures[matchingSignature]. We'll have to see the details when implementing it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions