Skip to content

How should I handle optional arguments in WebIDL for Golang? #3

Description

@heathj

Currently, if a function takes optional arguments, I just make multiple functions with different names and place the default arguments in these function definitions. I think this is fine, but maybe there is a more readable way to do this. Golang does not support method overloading and optional arguments. I could also try variable length arguments.

Current method

// https://html.spec.whatwg.org/multipage/parsing.html#appropriate-place-for-inserting-a-node
func (c *HTMLTreeConstructor) getAppropriatePlaceForInsertion() insertionHandler {
	return c.getAppropriatePlaceForInsertionWithOverrideTarget(c.currentNode)
}

// https://html.spec.whatwg.org/multipage/parsing.html#appropriate-place-for-inserting-a-node
func (c *HTMLTreeConstructor) getAppropriatePlaceForInsertionWithOverrideTarget(target *dom.Node) insertionHandler {

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions