nodejs / nodejs/node

Remove FFI type aliases while it's still experimental

Đang mở
#64,848 7 bình luận 6 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

feature request ffi
Ngôn ngữ chính
JavaScript
Star
122k
Fork
37.4k
Merge trung bình
4 ngày 3 giờ
Pull request đã merge (30 ngày)
272

Mô tả

What is the problem this feature will solve?

node:ffi was introduced with synonyms for the same types

i8, int8
u8, uint8, bool, char
i16, int16
u16, uint16
i32, int32
u32, uint32
i64, int64
u64, uint64
f32, float
f64, double
pointer, ptr
string, str
buffer
arraybuffer

While this may be convenient for folks that are familiar with the different names, it also adds mental overhead - developers need to confirm if 'char' and 'u8' mean the same thing or are subtly different.

There were a few bugs that are kindof related to this

  • when ffi.types.FLOAT_32 was added it's value was float32 which wasn't a supported alias, so now there's three ways to spell float 32.
  • buffer and arraybuffer are also synonyms but are different lines in the docs
  • char is listed on the same lines as u8 and bool but it is not a synonym (it varies by platform)

cc @nodejs/ffi

What is the feature you are proposing to solve the problem?

We should remove each synonym and keep one spelling for each distinct type.
I'm not opinionated on which spelling we prefer, I think the uint8 style agrees with ffi.types and the access helpers (getUint8).

We should do this now while the module is experimental. WE can always add more names in the future, but removing them after the module is stable is harder.

What alternatives have you considered?
  • we could do nothing and live with the synonyms
  • we could deprecate and print a warning when the non-preferred aliases are used

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu tại entry point node:ffi và lập danh mục các bí danh kiểu, tên của ffi.types, các helper truy cập và các tham chiếu trong tài liệu. Cách viết được ưu tiên chưa được quyết định trong issue, vì vậy hãy xem lại các quy ước API hiện có trước khi tiếp tục. Công việc được xem là hoàn tất khi mỗi kiểu riêng biệt chỉ có một cách viết và tài liệu cũng như hành vi liên quan nhất quán phản ánh việc loại bỏ.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
javascript
Lĩnh vực
backend
Loại issue
Tái cấu trúc
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Sôi nổi
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
48/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.