Project

General

Profile

Bug #697

Interpreter: Avoid outputting an empty line after each line of input

Added by John Abbott almost 9 years ago. Updated over 6 years ago.

Status:
Closed
Priority:
Normal
Category:
Parser/Interpreter
Target version:
Start date:
11 May 2015
Due date:
% Done:

100%

Estimated time:
1.01 h
Spent time:

Description

CoCoA-5 prints an empty line after each input line which outputs nothing.

Might be related to the fact that standalone expressions are equivalent to println <expr>?


Related issues

Related to CoCoA-5 - Feature #500: Interpreter: is it possible to avoid useless prompts?Closed2014-03-28

History

#1 Updated by John Abbott over 8 years ago

  • Priority changed from Normal to Low
  • Target version changed from CoCoA-5.1.2 summer 2015 to CoCoA-5.1.3/4 Jan 2016

This is just a cosmetic issue; so I have lowered the priorty, and postponed to next version of C5. I think it will involve some time-consuming understanding of the interpreter code; probably the actual fix will be fairly simple (once the code for the interpreter has been comprehended).

#2 Updated by John Abbott about 8 years ago

  • Target version changed from CoCoA-5.1.3/4 Jan 2016 to CoCoA-5.?.?

#3 Updated by Anna Maria Bigatti about 7 years ago

  • Assignee set to Anna Maria Bigatti
  • Priority changed from Low to Normal
  • Target version changed from CoCoA-5.?.? to CoCoA-5.2.2
  • % Done changed from 0 to 10

The line printing the newline is this, in LineProviders.H:

std::string promptHeader() const { return openBlocks.empty() ? "\n" : "\n"+openBlocks.back(); }

#4 Updated by John Abbott about 7 years ago

Perhaps the interpreter needs to have a flag saying whether a newline should be printed before printing the prompt.
The flag starts off as false, and it reset to false by the command println (which already prints a newline).
The command print sets the flag to true (unless the string it prints is empty?)

This heuristic does mean that there is a slight difference between println; and print "\n";
But I do not think that this is very important.

#5 Updated by Anna Maria Bigatti about 7 years ago

I'm very tempted just to remove this empty line in all cases.... after all I also remove them in the manual and in my demos!

#6 Updated by Anna Maria Bigatti about 7 years ago

  • Target version changed from CoCoA-5.2.2 to CoCoA-5.2.0 spring 2017
  • % Done changed from 10 to 60

#7 Updated by John Abbott about 7 years ago

  • Status changed from New to In Progress
  • Target version changed from CoCoA-5.2.0 spring 2017 to CoCoA-5.2.2
  • % Done changed from 60 to 10

There is a class called OSTREAM in Interpreter.H:274.

Perhaps that class could contain a flag which says whether the last output line ended with a newline?

#8 Updated by Anna Maria Bigatti about 7 years ago

removed the empty lines, and checked in.
I like it! A lot more compact :-)
Have a look, what do you think?

#9 Updated by John Abbott over 6 years ago

Seems OK to me.

Let's worry later (if at all) about outputting a newline if the last print line didn't have one...

Close?

#10 Updated by Anna Maria Bigatti over 6 years ago

  • Status changed from In Progress to Feedback
  • % Done changed from 10 to 90
  • Estimated time set to 1.01 h

#11 Updated by Anna Maria Bigatti over 6 years ago

  • Status changed from Feedback to Closed
  • % Done changed from 90 to 100

Also available in: Atom PDF