Skip to content

Fix misleading Seq.init XML doc#19293

Open
bbatsov wants to merge 2 commits intodotnet:mainfrom
bbatsov:fix/seq-init-docs
Open

Fix misleading Seq.init XML doc#19293
bbatsov wants to merge 2 commits intodotnet:mainfrom
bbatsov:fix/seq-init-docs

Conversation

@bbatsov
Copy link
Contributor

@bbatsov bbatsov commented Feb 15, 2026

Fixes #14233

The Seq.init XML doc claimed "Each element is saved after its initialization" but this is incorrect — Seq.init does not cache elements. The initializer function is reapplied on each iteration, exactly like Seq.initInfinite.

Changes:

  • Updated the description to match actual behavior, using the same wording as Seq.initInfinite
  • Added a <see> reference to Seq.cache for users who need cached results
  • Removed the misleading "This is an O(n) operation" from the remarks (creating the sequence is O(1), same as initInfinite)

The doc claimed "Each element is saved after its initialization" but
Seq.init does not cache elements — the initializer function is
reapplied on each iteration, same as Seq.initInfinite.

Update the description to match actual behavior and add a reference
to Seq.cache for users who need cached results.

Fixes dotnet#14233
@github-actions
Copy link
Contributor

github-actions bot commented Feb 15, 2026

⚠️ Release notes required, but author opted out

Warning

Author opted out of release notes, check is disabled for this pull request.
cc @dotnet/fsharp-team-msft

///
/// <remarks>The returned sequence may be passed between threads safely. However,
/// individual IEnumerator values generated from the returned sequence should not be accessed concurrently. This is an O(n) operation, where n is the count.</remarks>
/// individual IEnumerator values generated from the returned sequence should not be accessed concurrently.</remarks>
Copy link
Member

Choose a reason for hiding this comment

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

Please keep the complexity docs. In case of seq, those can be also split into construction complexity and enumeration complexity (expressed in terms of function invocations in this case)

@T-Gro T-Gro added the NO_RELEASE_NOTES Label for pull requests which signals, that user opted-out of providing release notes label Feb 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

NO_RELEASE_NOTES Label for pull requests which signals, that user opted-out of providing release notes

Projects

Status: New

Development

Successfully merging this pull request may close these issues.

Seq.init does not save values as suggested in description

2 participants