top | item 11884173

(no title)

mc_hammer | 9 years ago

its much easier if you can skip int8 and int16 and just use a single precision, if not consider a shorthand syntax for them like "u1234" or "d1234" or "foo = uint(1234)".

for libraries you can get the types from the library headers, "func a(foo int)" you know that x is int if they write "a(x)"

for new code just check the values assigned to variables (through all time); 1-10 as int, 1.xx-10.xx as float, etc. then use some switching to fill in the rest. but it never catches all the edge cases so you maybe you can use a foo<type> custom-syntax...

i did something similar for coffeescript to golang and i could get about 99% but i know it would break under real world conditions, ended with a custom syntax foo#type or foo<type>, and then they can use int8 and int16 and double and what not.

discuss

order

No comments yet.