Solumin / Systems630-Project1

Repository for Project 1 of the CS630 Systems course
Other
1 stars 9 forks source link

PRINT_ITEM does not put spaces between items #3

Open Solumin opened 10 years ago

Solumin commented 10 years ago

https://docs.python.org/2/reference/simple_stmts.html#print "A space is written before each object is (converted and) written, unless the output system believes it is positioned at the beginning of a line. This is the case (1) when no characters have yet been written to standard output, (2) when the last character written to standard output is a whitespace character except ' ', or (3) when the last write operation on standard output was not a print statement. (In some cases it may be functional to write an empty string to standard output for this reason.)"

Solumin commented 10 years ago

A couple thoughts on this.

One option is to "cheat" and look at the next instruction. If it's a PRINT_ITEM(_TO), add a space. If it's anything else, don't.

Another way is to track what we've printed and if it matches the "at new line" criteria above. If:

I think the actual Python interpreter keeps state on each file object, marking if it has been written to, keeping track if a space is needed, etc. We could do this, too, except we don't support files yet.

cibelemf commented 10 years ago

Maybe we should wait to see if we will be able to support files and try the solution where we keep the states.