Design #610
Variable It: assign before or after printing
Description
I found this is an old email (20101119).
Currently given a freestanding top-level expr C5 evaluates it,
prints the value, and then assigns it to It
. I discovered
this while trying to track a memory problem: every malloc/free
printed a logging message -- I was surprised to see so many
logging messages appear after the result was printed.
In any case I want to be sure that if printing is interrupted
then I can still rely on the assignment to It
having been
completed before the prompt reappears.
A "psychological" disadvantage to assigning to It
before
printing the result is that a simple computation could appear to
take a long time if It
previously contained a large result
which takes some time to delete.
Opinions? Am I simply creating a problem where none existed?
Related issues
History
#1
Updated by John Abbott over 4 years ago
- Description updated (diff)
- Target version changed from CoCoA-5.?.? to CoCoA-5.4.0
#2
Updated by John Abbott over 4 years ago
If we make printing interruptible then it would be better to assign to It
before printing (o/w the assignment may never occur).
#3
Updated by John Abbott over 4 years ago
- Related to Feature #1271: Allow Interruption of printing? added
#4
Updated by John Abbott over 2 years ago
- Target version changed from CoCoA-5.4.0 to CoCoA-5.4.2
Is the value "assigned" to It
or swapped into It
(hopefully without being copied more than strictly necessary)?
#5
Updated by John Abbott about 2 months ago
- Status changed from New to Resolved
- Assignee set to John Abbott
- % Done changed from 0 to 70
I believe that the relevant spurce code is around Interpreter.C:4187
The line I mean is
runtimeEnv->getTopLevelFrame()->varSlots[runtimeEnv->itSlot].value = v;
Inside the function void EvalStatement::implExecute(RuntimeEnvironment *runtimeEnv)
Assuming I have correctly located the line then it seems that assignment occurs before printing.
Also the assignment is of smart pointers, so it should be efficient.
Status set to resolved I hope Anna can confirm what I have deduced above (then we can close this issue).
#6
Updated by John Abbott about 2 months ago
I am testing the behaviour by computing a large cyclotomic polynomial (without assigning it). Then compute 1+2
without assigning it, and observe how long it takes to print out the result 3
.
Indeed it took a couple of seconds to print out 3
-- not ideal, but really not a problem. I did the test in a xterm -- it would not be clever to do it inside emacs!)
#7
Updated by John Abbott about 2 months ago
- Status changed from Resolved to Closed
- % Done changed from 70 to 100
- Estimated time set to 0.88 h
Current behaviour is acceptable (and should still be safe even if we make printing interruptible).
Closing.