-
Notifications
You must be signed in to change notification settings - Fork 18.3k
Open
Labels
FeatureRequestIssues asking for a new feature that does not need a proposal.Issues asking for a new feature that does not need a proposal.NeedsDecisionFeedback is required from experts, contributors, and/or the community before a change can be made.Feedback is required from experts, contributors, and/or the community before a change can be made.OS-JS
Milestone
Metadata
Metadata
Assignees
Labels
FeatureRequestIssues asking for a new feature that does not need a proposal.Issues asking for a new feature that does not need a proposal.NeedsDecisionFeedback is required from experts, contributors, and/or the community before a change can be made.Feedback is required from experts, contributors, and/or the community before a change can be made.OS-JS
Type
Projects
Relationships
Development
Select code repository
Activity
agnivade commentedon Feb 22, 2021
Any new API addition needs to be supported by requirements which will benefit a wide number of users using the package.
Can you please outline your reasoning behind these new methods? When should the user call Invoke vs Invoke2?
Go usually believes in one way of doing things, so diverging the API at this point does not seem to overshadow the benefit gained by introducing this new API.
I believe the panic was deliberately written for a reason, but I cannot recall it at the moment.
pjebs commentedon Feb 22, 2021
Let me explain:
A primer for non-JS developers:
In JS, the constructor (
New
insyscall/js
), and instance methods (Invoke/Call
) of JS objects can throw Exceptions. This package converts the thrown Exceptions to panics of typeError
. There is usually nothing "exceptional" about these thrown exceptions. They are better suited to be treated as a returned error value, as per @robpike's reasoning for returning error values instead of throwing Exceptions since the early days of Go.Reasoning:
--2
) does not mean "alternative to ...". (Even though they can be thought of as such). It means they return 2 return values, and are 'almost' analogous to the naming convention found in the standard library: eg https://golang.org/pkg/reflect/#Value.Slice3New
,Invoke
andCall
panic for other reasons (these are documented in godoc). They are not effected by this proposal and the behaviour will remain the same.pjebs commentedon Feb 22, 2021
pjebs commentedon Oct 13, 2021
Any progress on this issue?