Skip to content

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

Open
@your-diary

Description

@your-diary

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions