On Fri, Dec 20, 2019 at 5:07 PM Michel Levieux <m.levi...@capitaldata.fr> wrote:
>
> I was working on a project and for simplicity reasons I just happened to 
> write a lot of useless, effectless conditions.
> What I mean by "useless, effectless condition" is a condition that makes no 
> function call, that has no body, and that makes no assignment of any variable 
> outside the scope of the condition. For example, an example of my code would 
> be:
>
> if tracer.detailLevel & macros.TraceDetailLevelMostPossible != 0 {}
>
> Such function could be removed without affecting the execution of the 
> program, algorithmically speaking. Moreover, it seems to me it might be 
> possible to define a relatively small set of rules that identifies such 
> constructs and only those. However when I googled it, I didn't find anything 
> that would answer my question.
>
> So here it is: Is such a condition eliminated at compile-time?

Well, there are multiple Go compilers and it depends on the compiler,
but for the standard Go compiler you can download at golang.org, yes,
those conditions are eliminated at compile time.

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 golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAOyqgcW6N2bgw2juJHY2WbjpEg7nMez57AWb8U-svJ0vPsZyKw%40mail.gmail.com.

Reply via email to