Skip to content

Improve documentation for memory and table grow methods - #122

Merged
andreaTP merged 1 commit into
bytecodealliance:mainfrom
Marcono1234:grow-docs
Jul 27, 2026
Merged

andreaTP merged 1 commit into
bytecodealliance:mainfrom
Marcono1234:grow-docs

Conversation

@Marcono1234

Copy link
Copy Markdown
Contributor

I think especially the "return -1 on error" is an important aspect to document.

Side note: The JavaScript API seems to throw an exception for errors. Though I understand that the Endive implementation here is used both as API and as implementation for the Wasm opcode (which requires -1 on error). Not sure how often these grow methods are used from the API by users, but maybe it would make sense then in the future to consider refactoring it to throw an error by default instead of using -1 as return value (respectively having a tryGrow which returns -1)?

@Marcono1234
Marcono1234 requested a review from andreaTP as a code owner July 25, 2026 12:44
Comment on lines +30 to +31
// Implementation note: try-catch is faster than explicit checks and can be optimized by the
// JVM. Catching generic RuntimeException to keep the method bodies short and easily inlinable.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Moved this here, because it is probably not relevant in user-facing Javadoc.

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.

👍

@andreaTP andreaTP 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.

LGTM, thanks a lot!

For the records: I, personally, don't like JavaDocs(several reasons...), but I know that is a ship that should eventually sail.
You are introducing those with focused changes and this makes it for smoother reviews (and personal acceptance of the fact), thanks so much.

Comment on lines +30 to +31
// Implementation note: try-catch is faster than explicit checks and can be optimized by the
// JVM. Catching generic RuntimeException to keep the method bodies short and easily inlinable.

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.

👍

@andreaTP
andreaTP merged commit 72e73fb into bytecodealliance:main Jul 27, 2026
46 of 47 checks passed
@Marcono1234
Marcono1234 deleted the grow-docs branch July 28, 2026 17:36
@Marcono1234

Copy link
Copy Markdown
Contributor Author

I also don't think documenting everything is necessary; often things are obvious (getters, setters) or redundant or duplicated (with @param and @return).

But on the other hand Javadoc can also be quite useful I think, especially when describing the purpose of a class or method and how it interacts with other classes, and when describing things to look out for such as special or error behavior or argument restrictions.

@andreaTP

Copy link
Copy Markdown
Contributor

Javadoc can also be quite useful I think

I agree, and I acknowledge we should do better in this regard in this project.

At the same time I go mad when I see drift happening(i.e. comments misaligned with implementation) 😅

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