My apologies, So as to not waste your time or anybody else's, I'll follow the proposal headings in the (proposal/.../TEMPLATE.md), and post here.
On Sunday, 21 May 2023 at 07:23:22 UTC+10 Ian Lance Taylor wrote: > On Sat, May 20, 2023 at 1:17 PM Dexter Plameras <[email protected]> wrote: > > > > 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 didn't explain why the new syntax is better. It doesn't seem any > clearer to me, so I don't see what we gain. Thanks. > > Ian > -- 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/dcd6d3fe-548f-4ba0-846b-1aff7c9f1e53n%40googlegroups.com.
