Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

This doc comment should be hidden from end users. #373

Open
your-diary opened this issue Jun 19, 2024 · 0 comments
Open

This doc comment should be hidden from end users. #373

your-diary opened this issue Jun 19, 2024 · 0 comments

Comments

@your-diary
Copy link

The doc comment below should be hidden from end users because the terms value and exp are not defined anywhere end users can see.

2024-06-19_16_17_01

// Decimal represents a fixed-point decimal. It is immutable.
// number = value * 10 ^ exp ← (THIS)
type Decimal struct {
	value *big.Int

	// NOTE(vadim): this must be an int32, because we cast it to float64 during
	// calculations. If exp is 64 bit, we might lose precision.
	// If we cared about being able to represent every possible decimal, we
	// could make exp a *big.Int but it would hurt performance and numbers
	// like that are unrealistic.
	exp int32
}

Some suggestions:

  • Prevent the line from being rendered. (I don't know it's technically possible in Go though.)

  • Just move the line inside struct{ ... }. Maybe just after the opening brace {.

  • Keep the comment but define the terms value and exp. I think this approach is very interesting as I was personally impressed when I first read the source code to know how Decimal was implemented.

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

No branches or pull requests

1 participant