Hi, I was under the impression that this, ` _ = s[10] `, happens at compile
time. But that probably doesnt make sense. We dont know the length of all
slices at compile time.
Then, what is this actually improving? Does the compiler see there will be
a bound check, so it doesnt produce instructi
Good point. But shouldn’t that trigger another error like “platform dependent
comparison”. Seems that should be disallowed as well.
> On Oct 12, 2024, at 10:05 PM, Ian Lance Taylor wrote:
>
> On Sat, Oct 12, 2024 at 8:08 AM Robert Engels wrote:
>>
>> Understood - but the compiler already de
On Sat, Oct 12, 2024 at 8:08 AM Robert Engels wrote:
>
> Understood - but the compiler already determines constants - determining the
> condition is a constant to avoid the current compiler error wouldn’t require
> an optimization. It seems that a constant false might also be reported as an
> e
On Fri, Oct 11, 2024 at 3:25 AM 'Timo Beckers' via golang-nuts <
golang-nuts@googlegroups.com> wrote:
> On Fri, 11 Oct 2024 at 03:15, Robert Engels wrote:
> >
> > That’s what I was thinking. Thanks for providing the details. Rule of
> thumb - if you’re trying to do something and you’re the only o
Agree completely - that’s what kind of annoys me about the unused variable
being an error. I would like a little more consistency but it is what it is.
> On Oct 12, 2024, at 10:24 AM, Peter Weinberger wrote:
>
> I think we want to limit the compiler's enthusiasms. I frequently put
> if false
I think we want to limit the compiler's enthusiasms. I frequently put
if false {...} around a piece of code i want to ignore temporarily, or
if true {...} around an alternate implementation, and it would be
annoying to get compiler errors, even if they were justifiable.
There's a tradeoff with usab
Understood - but the compiler already determines constants - determining the condition is a constant to avoid the current compiler error wouldn’t require an optimization. It seems that a constant false might also be reported as an error as an unreachable code block. On Oct 12, 2024, at 10:04 AM, Ia
On Fri, Oct 11, 2024, 9:30 PM Robert Engels wrote:
> FWIW, I’m not sure that I think it is the best outcome. If the expression
> is a constant the loop can be omitted entirely - which I would hope the
> compiler would do. And consequently the errors from the compiler should
> reflect that - inclu