On Thu, May 17, 2012 at 4:32 PM, chris dollin <
ehog....@googlemail.com> wrote:
> On 17 May 2012 16:22, Jim Whitehead II <
jnwh...@gmail.com> wrote:
>> On Thu, May 17, 2012 at 2:29 PM, Joubin Houshyar <
jhou...@gmail.com> wrote:
>>>
>>>
>>> On May 17, 8:15 am, kortschak <
dan.kortsc...@adelaide.edu.au> wrote:
>>>> If you want to use levels, why not just use an int with a set of const
>>>> definitions like None, Log, Debug, ... It seems more complex than it needs
>>>> to be with no real difference.
>>>
>>> The hope is that mr. compiler (in some future variant if not today)
>>> will not bother with nop methods. (Based on comment in cited thread
>>> by r re "compiler".) You would assign your logger to debug or no
>>> debug version and be done with it.
>>
>> That would be surprising behaviour in a language with side effects. It
>> would prevent us from being able to read the following code and have
>> any idea what is going on:
>>
>> foo(bar())
>>
>> Regardless of how foo is defined I would expect that bar() is
>> evaluated when viewing this code from a birds-eye view. I'd resist any
>> sort of change like this simply because it's voodoo.
>
> If bar has no side-effects (which is what I think the OP meant
> by "nop method") then if foo discards bar's value the compiler
> could discard the evaluation of foo without damaging anyone's
> notion of what's going on.
>
> It's not a matter of the .language. having no side-effects, but
> of the .specific instance. not having them.
I'm bringing the list back into this, since I suspect you just forgot
to include it in your reply.
I don't actually think we mean different things, but let's look at a
more concrete example. Let's say you define a function called
'debugf', and call it like
debugf("just did something: %d", bar())
What I read being proposed was that if debugf is assigned a noop
(func(){} being the only acceptable definition of a noop in this
case), then bar would never be evaluated and everything would be
happy.
That's precisely what I disagree with, because I don't understand how
that would make sense in the context of the full language.
Certainly you can determine statically at compile-time if debugf is
set to a noop function and that it is never assigned any other value.
Even if that were the case, you don't currently have the information
needed in the compiler to determine whether or not bar has side
effects and can be safely dropped. Also, what happens if the value of
debugf can change during the running of a program?
I'm just confused how this could ever make sense in the language specification.
- Jim