Skip to content

Block indices #4017

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Block indices #4017

wants to merge 1 commit into from

Conversation

rtjoa
Copy link
Contributor

@rtjoa rtjoa commented May 16, 2025

Add explicit indices into a block, gated by layouts_beta. A quick example follows below. For full documentation, see jane/doc/extensions/_02-unboxed-types/block-indices.md.

open Stdlib_beta

type pt = { x : int; y : int }
type line = { p : pt#; q : pt# }

let mk_idx () : (line, int) idx_imm = (.q.#y)

let get_coord (line : line) (i : (line, int) idx_imm) : int =
  Idx_imm.unsafe_get line i

let first_x (): (pt# array, int) idx_mut = (.(0).#x)

let inc_coord (pts : 'a) (i : ('a, int) idx_mut) =
  Idx_mut.unsafe_set pts i (Idx_mut.unsafe_get pts i + 1)

Testing

Reviewing

  • @ccasin to "whole-feature" review
  • @mshinwell to do targeted review of the middle-end, runtime, and runtime tests (backend/, bytecomp/, middle_end/, testsuite/tests/typing-layouts-block-indices/block_indices.ml, testsuite/tests/records-and-block-indices/test_generation.ml)
  • Note that much of the diff is due to generated tests (beginning with generated_), which generates tests of the same shape for many types. The best way to review these is to review the file that does the generation, then look at the tests for just a few types.

Copy link

github-actions bot commented May 16, 2025

Parser Change Checklist

This PR modifies the parser. Please check that the following tests are updated:

  • parsetree/source_jane_street.ml

This test should have examples of every new bit of syntax you are adding. Feel free to just check the box if your PR does not actually change the syntax (because it is refactoring the parser, say).

Siteproxy

Siteproxy

搜索引擎


常用网站


新闻网站


海外论坛


@rtjoa rtjoa force-pushed the rtjoa.block-indices branch 2 times, most recently from c399bd0 to 0e82efc Compare May 21, 2025 09:30
@xclerc xclerc force-pushed the record-nesting-wip branch 2 times, most recently from e5653ca to 54578cb Compare May 23, 2025 10:47
Base automatically changed from record-nesting-wip to main May 23, 2025 11:25
@rtjoa rtjoa force-pushed the rtjoa.block-indices branch 3 times, most recently from 7f76b49 to 603c214 Compare May 23, 2025 15:48
@rtjoa rtjoa marked this pull request as ready for review May 23, 2025 15:51
@rtjoa rtjoa requested a review from ccasin May 23, 2025 15:51
@rtjoa rtjoa force-pushed the rtjoa.block-indices branch 6 times, most recently from daaa8b4 to cc494f4 Compare May 23, 2025 23:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant