User talk:Ledrug: Difference between revisions

+ note about LZW compressor in D
No edit summary
(+ note about LZW compressor in D)
Line 93:
where these rectangles obviously have only 1 symetric cut.
As I have no intention to change a language example I <s>cannot</s>do not intend to run, I just thought to give notice to the author instead. - [[User:PKai|pKai]] ([[User talk:PKai|talk]]) 20:44, 10 May 2013 (UTC)
 
== LZW compressor ==
 
I have translated your nice C LZW program to D language. I have tried to make it idiomatic D, but some of the C style is probably still present. The D code currently still requires five casts, and I have guarded them with asserts, like:
 
assert(tmp >> oBits <= ubyte.max);
result[outLen] = cast(ubyte)(tmp >> oBits);
 
Perhaps with some more semantic knowledge of the program it's possible to avoid one or two of those casts.
If you want you can tell me if you see something that could be improved in the D version of the code. In some cases it's nice to receive a little of code review on Rosettacode.