In trying to get Phobos to compile with dip1000, I was faced with the following innocuous looking line:

  assert(equal(achr, arr), text(a.byCodepoint));

  https://github.com/dlang/phobos/blob/master/std/uni.d#L3763

and the compiler complained that `text(a.byCodepoint)` was a system call. I decided to accept the Mission Impossible of figuring out why it was inferred as @system.

I found myself getting lost in a maze of twisty template expansions, all looking slightly different:

  text
  begat textImpl
  begat to
  begat toImpl
  begat toStr
  begat formatValue
  begat formatValueImpl
  begat put
  begat doPut
  begat Appender.put
  begat Appender.put

These templates are all just wrappers around wrappers. They're laden with overloads, constraints and static ifs, so finding just what code is being compiled with what parameters is absurdly difficult. I can't begin to defend this.

Converting a range of empty/front/popFront to a string should be a simple, direct piece of code.

For example, simple conversion to a string should not need to detour through a complex formatting function.

(For those wondering about the genesis of https://github.com/dlang/dmd/pull/8384, trying to figure this out motivated it. Saved me lots of time, especially in finding which overload was being called.)

If someone wants to figure out how to build an uncomplicated, straightforward, efficient implementation of text() that we can be proud of, that would be a nice contribution.

Reply via email to