Skip to content

Cannot call interface methods named 'close' #33

@mologie

Description

@mologie

The following will not work due to close() being replaced by the node-capnp implementation:

interface DirectionControllableShutter {
	open @0 ();
	close @1 ();
	stop @2 ();
}
this.controller.getDirectionControllableShutter(id)
    .then((result) => result.object.close())
    .then((result) => { /* ... */ })

I'm aware that this is by design, but would raise an issue nevertheless because the capnp compiler allows methods to be named 'close'. As such, I'd expect them to be callable, even if it requires a language-specific workaround (which might also be required when naming a method after a language's reserved word.)

If you have a suggestion for a clean and generic workaround I'd be happy to implement it and submit a pull request. Ideally, this should be done without introducing an edge-case.

A quick and simple solution would be to detect clashes and resolve them by appending an underscore to the method name, so that the above would say .then((result) => result.object.close_()). I think that this is bad, because an edge-case is introduced which must be documented and communicated to the user.

Cheers and a happy new year, Oliver

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions