Hi, Greg Ewing wrote: > Dag Sverre Seljebotn wrote: > >> Can anyone think of a reason why C string literals are allocated as >> variables in C source? > > I can't remember all the reasons I did it that way in Pyrex, > but one of them may have been so that I could leave calculating > the length of the string to the C compiler. It's not entirely > trivial to do that when escape sequences are involved.
That is very true. I put a whole lot of work into proper string escaping to make sure byte strings end up in the binary the way they were written in the source. That usually makes non-ASCII strings a bit longer than their pure byte sequence. > Another reason is so that I can refer to the C version of the > string in the generated code concisely, instead of having to > insert the whole string literal at that point, making it > easier to audit the generated code. It's also more readable, as some important information such as identifier state or unicode type are currently stored in the string tab behind the string literal. Although one could argue that it's trivial to move it before the literal... All of this makes me think that it's not a bad idea to keep them separate in the code. Stefan _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
