Talk:ASCII art diagram converter: Difference between revisions
Content added Content deleted
m (→D solution won't compile: add sig) |
|||
Line 10: | Line 10: | ||
Are you sure that the code is correct?<br> |
Are you sure that the code is correct?<br> |
||
--[[User:Smls|Smls]] ([[User talk:Smls|talk]]) 23:09, 30 January 2014 (UTC) |
--[[User:Smls|Smls]] ([[User talk:Smls|talk]]) 23:09, 30 January 2014 (UTC) |
||
: Looking at the current implementation, it has the test data: |
|||
:<lang D> Header h; |
|||
h.ID = 10; |
|||
h.RA = true; |
|||
h.ARCOUNT = 255; |
|||
h.Opcode = 7;</lang> |
|||
:which gives the test output: |
|||
:<lang D>[0, 10, 56, 128, 0, 0, 0, 0, 0, 0, 0, 255]</lang> |
|||
:But note that the first number in the output is a zero and the second number is a 10. Meanwhile, the specification indicates that ID should be the first value. So that might be one issue. |
|||
:Note also that 56 corresponds to this bit sequence: 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 if we place the high order bits on the left (and RFC 1035 specifies "Whenever an octet represents a numeric quantity, the left most bit in |
|||
the diagram is the high order or most significant bit"). Since opcode was 7, I would have instead expected a value of 7168. |
|||
:Anyways, it should not be hard for a good D programmer to fix that implementation. --[[User:Rdm|Rdm]] ([[User talk:Rdm|talk]]) 15:52, 31 January 2014 (UTC) |
Revision as of 15:52, 31 January 2014
D solution won't compile
I installed the Digital Mars D compiler version 2.064.2 on my Linux box (x86_64 architecture), copied the snippet into a file, and passed it to dmd - but it failed with this error:
$ dmd ascii_struct.d ascii_struct.d(121): Error: cannot implicitly convert expression ((line.length - 1LU) / 3LU) of type ulong to uint ascii_struct.d(139): Error: cannot implicitly convert expression ((field.length + 1LU) / 3LU) of type ulong to uint ascii_struct.d(188): Error: CTFE failed because of previous errors in makeStructFromDiagram
Are you sure that the code is correct?
--Smls (talk) 23:09, 30 January 2014 (UTC)
- Looking at the current implementation, it has the test data:
- <lang D> Header h;
h.ID = 10; h.RA = true; h.ARCOUNT = 255; h.Opcode = 7;</lang>
- which gives the test output:
- <lang D>[0, 10, 56, 128, 0, 0, 0, 0, 0, 0, 0, 255]</lang>
- But note that the first number in the output is a zero and the second number is a 10. Meanwhile, the specification indicates that ID should be the first value. So that might be one issue.
- Note also that 56 corresponds to this bit sequence: 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 if we place the high order bits on the left (and RFC 1035 specifies "Whenever an octet represents a numeric quantity, the left most bit in
the diagram is the high order or most significant bit"). Since opcode was 7, I would have instead expected a value of 7168.