News for hackers. Stuff that matters.
Re:Writing a compiler in Python using Lex, Yacc and LLVM by ilkhd2 on Saturday September 19, 2009 @07:40PM (#832456)
> low level details don't really come into play in compiler construction until the code generation

-- Not true. modern compilers do a lot of optimization long before code generation, and you really want to have for example floating point to be behaving exactly like in target language - if you collapse operations on constants such as 1.0D + 4.0. And aside from optimization, lexer - it has to distinguish single-precision and double precision floats.

Re:Writing a compiler in Python using Lex, Yacc and LLVM by pmorici on Saturday September 19, 2009 @10:34PM (#832630)
If what you are saying is true and the language you write the compiler in needs to mirror the type properties of the target then there would be no cross compilers or new architectures or new languages because you would be stuck with the type semantics of your original platform. It doesn't make common sense let alone technical correctness.
Re:Writing a compiler in Python using Lex, Yacc and LLVM by ilkhd2 on Saturday September 19, 2009 @10:56PM (#832643)
Of course it is true. And of course it does not make common sense - common sense usually made by brain/mind. If you cannot mirror properties of target machine - you cannot optimize code for that target - period. Any computatiuon made in compiler will be potentially different from the same, nonoptimized computation made in target. The more computations have been optimized in the compiler the bigger probabilty you'll get wildly different code.

However, if you do not have the target datatype you dealing with during compilation, you are destined to simulate them.

Example: ((unsigned char) 2) + ((unsigned char)255) = 1

That is in C. In ruby you'll have to manually check for overflow, and do it for each operation. You can invent classes all kind of things, but why? Use a language with types, and the check will be done for you by you Core Duo.

Re:Writing a compiler in Python using Lex, Yacc and LLVM by anamax on Sunday September 20, 2009 @04:17PM (#833488)
> you really want to have for example floating point to be behaving exactly like in target language

You keep writing that like it's a hard thing to do. It isn't. More to the point, it's a small part of the whole problem.