On Thu, 2023-08-17 at 11:34 +0200, Peter Herth wrote:
> I think the omission of keyword parameters in Go is a weakness. In
> many cases, keyword parameters are a simple way of creating APIs,
> which depend on a lot of possible parameters, of which most are not
> necessarily specified. Their omission is especially ironic, as there
> is a strong push to initialize structs only via using the keyword
> parameter syntax. And the reasons for that are very good. So when we
> have a nice system - which essentially is just syntactic sugar at the
> call site - for structs, why can't we have the same system for
> functions? Like with structs, it should be mostly a syntax for
> calling functions. They should probably be able to specify which
> parameters are positional and which can be specified by keyword
> parameters. 
> Of course you can do the common "trick" via generating a struct which
> allows the keyword syntax for creation, but I think it would be a
> good addition to not need that indirection.

A significant problem with additions like this is that people would use
it. kwargs-rich functions enable overly complex APIs. I'm very glad Go
doesn't have them.

-- 
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/3a3163c2d6827bb2c40a850c2d24b39dced1285c.camel%40kortschak.io.

Reply via email to