Skip to content

Add a few stubs, and fix whitespace in many more - #1167

Merged
colinleach merged 2 commits into
exercism:mainfrom
colinleach:add-stubs
Oct 25, 2026
Merged

colinleach merged 2 commits into
exercism:mainfrom
colinleach:add-stubs

Conversation

@colinleach

@colinleach colinleach commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Wow, this one escalated. I noticed in #1166 that rational-numbers previously had no function stubs in the solution file. This PR adds stubs for three more exercises that lacked them.

My uncertainty about this: the new stubs include Base.{operator} in the function name. Do we prefer to leave out Base. here and use an import at the top of file, like rational-numbers did in the previous PR? This is part of a wider discussion about how much we want the stubs to give away.

Along the way, Claude spotted extensive non-compliance with your rule about a 4-space indent on the blank line in the function body. Plus a few missing newlines at EOF.


Adds function skeletons to three practice stubs, and indents the empty body line in every stub

There are no test or example changes in this PR. Every changed stub still parses in Julia.

Things to look at:

  • New skeletons for complex-numbers, custom-set and robot-simulator. These stubs had only a comment. Each now has the type and the functions that the canonical tests call. Bonus tests are not stubbed.
    • complex-numbers:
      • struct ComplexNumber <: Number. The supertype means ≈ works in the tests.
      • Stubs extending Base: real, imag, +, -, *, /, abs, conj and exp.
      • The bonus-flag comments are kept at the end.
    • custom-set:
      • An empty struct CustomSet, with a comment that the tests call CustomSet(elements) with a vector.
      • There is no separate constructor stub. It would replace the default constructor that a single-field struct gets for free.
      • Stubs extending Base: isempty, in, issubset, ==, push!, intersect! / intersect and union! / union.
      • New functions: disjoint, complement! and complement.
    • robot-simulator:
      • An empty struct Point and an empty mutable struct Robot.
      • A comment, # define NORTH, EAST, SOUTH and WEST, so students choose how to represent headings. The stub doesn't give them an @enum.
      • Stubs for Robot(position::Tuple, heading), position, heading and move!.
      • turn_right!, turn_left! and advance! are not stubbed. The canonical tests only reach them through move!.
  • Body-line whitespace in every practice stub. README.md says function skeletons "should include a blank new line with a four space indentation for the body", but most stubs left that line empty.
    • 58 stubs: the empty line in each skeleton body is now four spaces. circular-buffer was fixed the same way, using eight spaces inside its inner constructor.
    • food-chain and knapsack: the body line had one space instead of four.
    • triangle, run-length-encoding, sum-of-multiples and largest-series-product: they had function ... followed directly by end, so each now has a four-space body line.
    • Deprecated exercises are untouched.
    • git diff -w shows the only changes other than whitespace: the three new skeletons and the four stubs that gained a body line.
  • Final newlines: resistor-color.jl and space-age.jl had no newline at the end of the file. Now they do.

@colinleach colinleach mentioned this pull request Oct 25, 2026
@colinleach
colinleach marked this pull request as ready for review October 25, 2026 20:46
@colinleach
colinleach requested a review from depial October 25, 2026 20:47

@depial depial left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

See separate comment on Base extensions.

@depial

depial commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

I think I'd be in favor of leaving the stubs blank which extend Base functions. There are more than one way to do this, with import or explicit Base.{op}, so I feel weird about showcasing one over the other (even though my preference is to use Base.{op} in my own code). I figure that with the difficulty as high as it is on these exercises, we can leave a bit for the student to figure out.

Do you have any feelings one way or the other?

@colinleach

Copy link
Copy Markdown
Contributor Author

This affects both rational-numbers (difficulty 8) and complex-numbers (difficulty 10). I'm moving towards leaving out the function stubs, and just adding a comment listing the operations that need to be implemented.

I'll push this to #1166 first, then whatever we agree there can be copied to #1167.

@colinleach

Copy link
Copy Markdown
Contributor Author

The no-stub comments in the solution file follow the #1166 precedent.

@colinleach
colinleach merged commit 6188254 into exercism:main Oct 25, 2026
9 checks passed
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