On Thursday, 28 February 2013 at 16:36:44 UTC, Walter Bright wrote:
On 2/28/2013 6:48 AM, Ary Borenszweig wrote:
On 2/28/13 1:57 AM, Walter Bright wrote:
On 2/27/2013 8:01 PM, John Colvin wrote:
Why must sentinel be known at compile time? I don't see what's in the
way of it
being a runtime argument.

Performance!

It should be usable as a case in a switch statement.

Isn't it possible for the optimizer to inline the function call and then combine
the next ifs?

if (isSentinel(value)) {
} else {
  switch(value) {
  case ...
  }
}

1. I don't know of any C compiler that would do that.


As mentioned, LLVM is able to do this kind of things. I have to admit I was quite amazed when I discovered it.

2. There are other cases, as I pointed out to deadalnix.

3. You still can't do lookahead without extra checks


You need the actual check to do proper generic D code. But the compiler is able to optimize it away via inlining and mecanism described in 1.

Once again, guys, have a look at lexer.c at the lines I pointed out.

I see nothing that can't be done by an optimizing compiler. Maybe something is, but I can't find it. And the example you pointed me aren't.

Reply via email to