Greetings, As per the requirement before putting together a proposal, a discussion on LHS inference for type assertions
Currently, type assertions take the form of: // // Pre assertion // var original string = "Hello Type Assertions" var data interface{} = original // or "var data any" // // Assertions // // fails compiler checks destInt := data.(int) // passes compiler checks destString := data.(string) Proposal: Instead of a RHS type assertion, I'd like to propose a language change that would take the type assertion as an inference from the LHS, potentially using a new assignment operator. // // Pre assertion // original := "Hello Type Assertions" var data interface{} = original // or var data any // LHS inference of the int type. Compiler checks fail. (notice the ".=" assignment operator, it could be variation of the assignment operator that makes it clearer) var destInt int .= data // LHS inference of the string type. var destString string .= data // or var destString string destString .= data This could potentially work with multiple RHS returns too. var data string var err error data, err .= function() I'm certainly no programming language expert but does this hold any value? -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/21ad2a0c-b261-4fd0-9a79-888d9ce59aadn%40googlegroups.com.