Skip to content

Conversation

@dbosk
Copy link
Owner

@dbosk dbosk commented Sep 29, 2024

Tries to have << overload as not friend.

@dbosk dbosk requested a review from Copilot September 15, 2025 12:30
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a new section about C++ and Java to a literate programming tutorial, demonstrating compilation errors and the use of the -L flag in noweb for better error reporting. The main focus is showing how literate programming tools can maintain source file references in compiler error messages.

Key changes:

  • Adds comprehensive C++ fraction class example with constructor, operators, and string conversion
  • Demonstrates noweb's -L flag functionality for preserving line number references in compilation errors
  • Includes Java comparison section (placeholder)

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
whatis/whatis.nw Adds new section reference for C++/Java content
whatis/introsort.nw Minor documentation improvements and cross-references
whatis/cppjava.nw New comprehensive C++ example with fraction class implementation
whatis/abstract.tex Removes comment markers and fixes citation format
whatis/Makefile Adds build rules for C++ examples and dependencies
whatis/.gitignore Adds generated files to ignore list

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

<<headers to include>>=
#include <iostream>
<<function declarations>>=
std::ostream& operator<<(std::ostream& os, const Fraction& f);
Copy link

Copilot AI Sep 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The operator<< declaration should be placed in the header file (fraction.h) under a <<function declarations>> section, not just in the implementation file. This ensures the function is properly declared for external use.

Copilot uses AI. Check for mistakes.
Comment on lines +322 to +325
std::ostream& operator<<(std::ostream& os, const Fraction& f) {
os << f.to_string();
return os;
}
Copy link

Copilot AI Sep 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The operator<< implementation calls a public method to_string() but could directly access private members if declared as a friend function, which would be more conventional for stream operators. However, the current approach maintains encapsulation and works correctly.

Copilot uses AI. Check for mistakes.
Fraction(int numerator, int denominator);

<<method declarations>>
<<overloaded operator declarations>>
Copy link

Copilot AI Sep 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The <<function declarations>> section is referenced but never defined in the header file structure. The operator<< declaration should be included in the header file for proper compilation.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants