-
Notifications
You must be signed in to change notification settings - Fork 453
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
Drop Caml runtimes and primitives #6984
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Like it |
cometkim
force-pushed
the
drop-caml
branch
2 times, most recently
from
August 27, 2024 20:31
035a175
to
6737fe8
Compare
cometkim
force-pushed
the
drop-caml
branch
5 times, most recently
from
September 8, 2024 21:20
904f3ff
to
3fe91d0
Compare
cometkim
force-pushed
the
drop-caml
branch
6 times, most recently
from
September 10, 2024 21:56
1ffebf9
to
83d9bce
Compare
cometkim
force-pushed
the
drop-caml
branch
5 times, most recently
from
September 22, 2024 17:50
fe725f5
to
e263f97
Compare
cometkim
changed the title
WIP: Drop Caml runtimes and primitives
Drop Caml runtimes and primitives
Sep 22, 2024
Now the only `runtime` dir is the built-in primitive literally Removed dependency hacks from `ninja.js` and make the dependency graph clearly `others` -> `runtime` Removed `Belt_internals` module, use compiler primitive instead Removed `runtime/js`, so made `others/js` only source of JS bindings Primitives shouldn't rely on JS any binding
Added |
Merge! Merge! Merge! 😁 |
cknitt
approved these changes
Sep 27, 2024
Merged! 🎉 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves #5779
Rationale
This removes runtime modules and primitives that exist for OCaml compatibility.
The original BuckleScript tried distinguishing between OCaml-inherited primitives and custom primitives (
?prim
) and js primitives (#prim
), but it didn't stick well.Since we gave up OCaml compatibility, it added unnecessary complexity with indirection, making it hard to predict where specialization would be performed.
So here I unify all primitives into a single prefix grammar of
%
. There is still#
primitive, but it exists temporarily for compatibility or is meant to be internal to the compiler and not exposed to the frontend.Changes
This PR contains many breaking changes
Primitive_object.updateDummy
(formallyCaml_obj.update_dummy
) behavior is now the same as theObject.assign
and doesn't specially handleArray
instances. See discussion from Improve obj dup using spread syntax #7043. But this is safer because it is only used inmodule rec
bindings.String.get: (string, int) => char
behavior is now the same as theString.prototype.codePointAt
. It was potentially buggy with existing char primitives, but this fixes it. See RFC: Revisechar
primitive #7028int32
(useint
instead)int64
uint32
nativeint
floatarray
(useFloat32Array
orFloat64Array
instead)bytes
(useArrayBuffer
orUinr8Array
instead)caml_{type}_compare
->%{type}order
(e.g.%intorder
)caml_{type}_min
->%{type}min
(e.g.%intmin
)caml_{type}_max
->%{type}max
(e.g.%intmax
)%bs_min
->%min
%bs_max
->%max
%bs_equal_null
->%equal_null
%bs_equal_undefined
->%equal_undefined
%bs_equal_nullable
->%equal_nullable
#unsafe_lt
->%unsafe_lt
#unsafe_gt
->%unsafe_gt
#unsafe_le
->%unsafe_le
#unsafe_ge
->%unsafe_ge
#unsafe_eq
->%unsafe_eq
#unsafe_neq
->%unsafe_neq
%bs_equal_null
->%equal_null
%bs_equal_undefined
->%equal_undefined
%bs_equal_nullable
->%equal_nullable
#debugger
->%debugger
#typeof
->%typeof
#null
->%null
#undefined
->%undefined
%makemutable
->%makeref
%bs_field0
->%refget
%bs_set_field0
->%refset
?create_dict
->%makedict
#makemutablelist
->%makemutablelist
?await
->%await
#import
->%import
#apply{N}
->%curry_apply{N}
#is_nullable
->%is_nullable
#nullable_to_opt
->%nullable_to_opt
#null_to_opt
->%null_to_opt
#undefined_to_opt
->%undefined_to_opt
#wrap_exn
->%wrap_exn
#hash
->%hash
#hash_mix_int
->%hash_mix_int
#hash_mix_string
->%hash_mix_string
#hash_final_mix
->%hash_final_mix
#unsafe_to_method
->%unsafe_to_method
#function_length
->%function_arity
?obj_dup
(from Improve obj dup using spread syntax #7043)?hexstring_of_float
?float_of_string
?int_of_string
?int64_of_string
?int64_format
?format_int
?format_float
?lex_engine
?new_lex_engine
?parse_engine
?set_parser_trace
?md5_string
?string_repeat
?create_bytes
?bytes_length
?bytes_safe_get
?bytes_safe_set
?bytes_unsafe_get
?bytes_unsafe_set
caml_bytes_*
%int64_*
caml_int64_*
?bigint_div
?bigint_mod
%bigint_of_int32
%bigint_to_int32
?int_of_float
(%intoffloat
is still available)?float_of_int
(%floatofint
is still available)?int_float_of_bits
?int_bits_of_float
?fmod_float
?modf_float
?ldexp_float
?frexp_float
?copysign_float
?expm1_float
?hypot_float
?exn_slot_name
?is_extension
?as_js_exn
%reraise
%raise_notrace
%lazy_force
(UseLazy.force
instead)%backend_type
%word_size
%int_size
%max_wosize
0u
(uint32) literal0l
(int32) literal0L
(int64) literalJs.isCamlExceptionOrOpenVariant
format_float
string_of_bool
bool_of_string
bool_of_string_opt
string_of_int
int_of_string
int_of_string_opt
string_of_float
float_of_string
float_of_string_opt
print_string
print_int
print_float
print_endline
print_newline
prerr_endline
prerr_newline
valid_float_lexem
Arg
Callback
Genlex
Lexing
Parsing
Parsing
Digest
Random
Bytes
Uchar
Buffer
Stream
Filename
Int32
Int64
String
partiallyChar
partiallyArray
Sort
List
Set
Map
Hashtbl
(exceptHashtbl.hash
)Map
Stack
Queue
Complex
Caml_module
->Primitive_module
Caml_obj
->Primitive_object
Caml_array
->Primitive_array
Caml_char
->Primitive_char
Caml_string
->Primitive_string
Caml_exceptions
,Caml_js_exceptions
->Primitive_exceptions
Caml_hash
,Caml_hash_primitive
->Primitive_hash
Caml_lazy
->Primitive_lazy
Caml_module
->Primitive_module
Caml_option
->Primitive_option
Curry
->Primitive_curry
Runtime_promise
->Primitive_promise
Runtime_dict
->Primitive_dict
Runtime_deriving
->Primitive_util
Primitive_bool
Primitive_int
Primitive_float
Primitive_bigint
Caml_format
-> xCaml_sys
-> xCaml_lexer
-> xCaml_parser
-> xCaml_md5
-> xCaml_int32
-> xCaml_int64
-> xCaml_splice_call
-> x (from improve variadic call using spread syntax #7030)Note for future refactoring
All primitives except # prefixed should eventually be treated as "features" and documented. We can rename all by a new convention for primitive names, but the old names should be kept for a while for compatibility.
Primitives are declared in two different places because they are processed separately before and after
Lam_convert
. It is difficult to change and to determine the types used or not used, resulting in many dangerous assertions.Ultimately, I want to consolidate the primitive declarations into one place and make them easier to manage.