To the ops point, wouldn’t it be better to cause an error for unused parameters 
unless they use the blank identifier?

> On Jan 30, 2022, at 2:09 PM, 'Dan Kortschak' via golang-nuts 
> <golang-nuts@googlegroups.com> wrote:
> 
> On Sun, 2022-01-30 at 12:01 -0800, Kamil Ziemian wrote:
>> Hello,
>> 
>> This is a question from ignorant in the meters of compilers and
>> mediocre Go users at best, so it may be stupid.
>> 
>> I really like that in Go unused variable or import is compiler time
>> error. As such I wonder why function like
>>> func funTest(x int) int {
>>>        return 3
>>> }
>> is allowed? I would guess that it is possible to check if function
>> argument is used in function body or not, so it seem plausible to
>> forbid it.
>> 
>> Again, it maybe a stupid question from ignorant person. I have a lot
>> things to learn about Go, but I'm stuck in learning about Unicode and
>> UFT-8, so I guess it will be a long time before I can go back to
>> learning proper Go. I read FAQ and I didn't remember answer to this
>> question from it. This is my excuse for asking this question.
>> 
>> Best regards,
>> Kamil Ziemian
> 
> It is necessary for methods to sometimes have parameters that are not
> used in order for the type to satisfy an interface. Similarly, if
> function values are being passed around the signatures will need to
> match even if the parameters are not being used.
> 
> It is possible to use the blank identifier in these cases to signal
> that a parameter is not being used and that can be linted for.
> 
> See https://github.com/golang/go/issues/39118 for discussion on a
> proposal relating to this.
> 
> 
> -- 
> 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/78c6d5db02f0f35230b60b8324189eb367cee209.camel%40kortschak.io.

-- 
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/BE2F9AE9-AA7B-4A6C-996C-DB88D5E8C956%40ix.netcom.com.

Reply via email to