Conversation
There was a problem hiding this comment.
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
-Lflag 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); |
There was a problem hiding this comment.
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.
| std::ostream& operator<<(std::ostream& os, const Fraction& f) { | ||
| os << f.to_string(); | ||
| return os; | ||
| } |
There was a problem hiding this comment.
[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.
| Fraction(int numerator, int denominator); | ||
|
|
||
| <<method declarations>> | ||
| <<overloaded operator declarations>> |
There was a problem hiding this comment.
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.
Tries to have
<<overload as notfriend.