Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add support for ArrayBuffer and typed arrays to @unboxed#7788

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
mediremi merged 2 commits intorescript-lang:masterfrommediremi:unboxed-array-buffer
Aug 23, 2025

Conversation

@mediremi
Copy link
Member

@mediremimediremi commentedAug 22, 2025
edited
Loading

Closes#6757

While adding support forArrayBuffer.t was simple
, supporting typed arrays (e.g.Int8Array) required changingAst_untagged_variants.get_block_type_from_typ so it first looks at the unexpanded types (e.g.Int8Array) rather than just the fully expanded version (e.g.Stdlib_TypedArray.t).

@pkg-pr-new
Copy link

pkg-pr-newbot commentedAug 22, 2025
edited
Loading

Open in StackBlitz

rescript

npm i https://pkg.pr.new/rescript-lang/rescript@7788

@rescript/darwin-arm64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/darwin-arm64@7788

@rescript/darwin-x64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/darwin-x64@7788

@rescript/linux-arm64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/linux-arm64@7788

@rescript/linux-x64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/linux-x64@7788

@rescript/win32-x64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/win32-x64@7788

commit:3a3f1d6

@mediremimediremi changed the titleAdd support for ArrayBuffer to @unboxedAdd support for ArrayBuffer and typed arrays to @unboxedAug 22, 2025
|Someinstance_type ->Some (InstanceType instance_type))
|{desc =Ttuple_} ->Some (InstanceTypeArray)
|_ ->None
(* First check the original (unexpanded) type for typed arrays and other instance types*)
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

The stdlib usest = Stdlib_TypedArray.t<int> andt = Stdlib_TypedArray.t<float> for typed arrays, so we can't differentiate them by their expanded types.

@mediremimediremi marked this pull request as ready for reviewAugust 22, 2025 12:24
@mediremimediremi requested a review fromzthAugust 22, 2025 12:25
@@ -1,5 +1,3 @@
moduleArray=Ocaml_Array
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

I removed this line and replacedarr[0] witharr->Array.getUnsafe(0) in the test to make compiling with./cli/bsc.js tests/tests/src/UntaggedVariants.res easier (bsc would complain about unknown dependencyOcaml_Array otherwise)

@zthzth requested a review fromcristianocAugust 22, 2025 12:28
Copy link
Collaborator

@cristianoccristianoc left a comment

Choose a reason for hiding this comment

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

Can we have a summary of how these new types compare to other types in terms of runtime representation?
Are they all objects and are all instance of cases mutually exclusive (with each other and with existing types).
Just double checking where this extension sits wrt what's already there.

@mediremi
Copy link
MemberAuthor

mediremi commentedAug 23, 2025
edited
Loading

typeof is"object" forArrayBuffer and typed arrays:

constbuffer=newArrayBuffer(8)constview=newInt32Array(buffer)console.log(typeofbuffer)// 'object'console.log(typeofview)// 'object'

They can be differentiated withinstanceof checks:

constbuffer=newArrayBuffer(8)constview=newInt32Array(buffer)console.log(bufferinstanceofArrayBuffer)// trueconsole.log(bufferinstanceofArray)// falseconsole.log(Array.isArray(buffer))// falseconsole.log(bufferinstanceofDataView)// falseconsole.log(viewinstanceofInt32Array)// trueconsole.log(viewinstanceofArray)// falseconsole.log(Array.isArray(view))// falseconsole.log(viewinstanceofArrayBuffer)// falseconsole.log(viewinstanceofDataView)// false
cristianoc reacted with thumbs up emoji

@mediremimediremi merged commitfe531a2 intorescript-lang:masterAug 23, 2025
27 checks passed
@cknitt
Copy link
Member

@mediremi Could you add a CHANGELOG entry for this PR?

@mediremi
Copy link
MemberAuthor

@cknitt oops, sorry forgot to add one. Added an entry in#7800

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@cristianoccristianoccristianoc approved these changes

@zthzthAwaiting requested review from zth

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

@unboxed should support Js.TypedArray2.ArrayBuffer.t

3 participants

@mediremi@cknitt@cristianoc

[8]ページ先頭

©2009-2025 Movatter.jp