Policy for exposing range structs

Adam D. Ruppe via Digitalmars-d digitalmars-d at puremagic.com
Thu Mar 31 07:30:52 PDT 2016


On Thursday, 31 March 2016 at 14:00:38 UTC, Steven Schveighoffer 
wrote:
> Ugh, let's try the huffman coding thing first :)

Do that after and along with!

> Stack traces would be unusable.

That's why I'd keep the function name outside the hash. The inner 
spam wouldn't be readable (not like a megabyte long name is 
readable anyway...), but the function name (which includes 
template arguments*) still is and that's probably the most useful 
part anyway.

* I just thought of another thing though.... string arguments to 
templates are included in the mangle, and with CTFE mixin stuff, 
they can become VERY long.

void foo(string s)() {}

pragma(msg, foo!"hi there, friend".mangleof);

_D1p48__T3fooVAyaa16_68692074686572652c20667269656e64Z3fooFNaNbNiNfZv

That "68692074686572652c20667269656e64" portion of it is the 
string represented as hexadecimal.

If you do a CTFE thing, the code string you pass in may be kept 
in ALL the names generated from it.

We should probably do something about these too. Simply gzipping 
before converting to hex is a possible option if we want it 
reversible. Or, of course, hashing too if we don't care about 
that.

And IMO a huge string in a stack trace is unreadable anyway... 
I'd be tempted to say if the string is longer than like 64 chars, 
just hash it. But this is debatable.

> A possible thing the compiler *could* do is place inside the 
> binary a hash-to-actual-symbol table that the exception printer 
> can utilize to print a nicer stack trace...

Indeed. I actually just emailed Liran with this suggestion as 
well. I don't think it is ideal for D in general, but for an 
internal project, it might solve some problems.


More information about the Digitalmars-d mailing list