nodejs / nodejs/node

Remove FFI type aliases while it's still experimental

Offen
#64,848 7 Kommentare 6 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

feature request ffi
Vorherrschende Sprache
JavaScript
Sterne
122k
Forks
37.3k
Ø Merge
4 T. 2 Std.
Gemergte PRs (30 T.)
283

Beschreibung

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

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne beim Einstiegspunkt node:ffi und erfasse die Typ-Aliase, die Namen von ffi.types, die Zugriffshilfen und die Dokumentationsverweise. Die bevorzugte Schreibweise ist im Issue nicht festgelegt; prüfe daher vor dem Fortfahren die bestehenden API-Konventionen. Als abgeschlossen gilt die Arbeit, wenn jeder unterschiedliche Typ genau eine Schreibweise hat und die zugehörige Dokumentation und das Verhalten die Entfernung konsistent widerspiegeln.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
javascript
Bereich
backend
Issue-Typ
Refactoring
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Aktiv
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
48/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.