ocsigen / ts2ocaml

Generate OCaml bindings from TypeScript definitions via the TypeScript compiler API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Snake-casing of identifiers

Lupus opened this issue · comments

Probably an option to do proper snake-casing of identifiers will be popular. cast_to_EventEmitter is arguably inconsistent and might be better perceived as cast_to_event_emitter along with module itself being named as Event_emitter. I got the impression that snake case is the prevaling style in OCaml community, but I might be wrong.

I think it is better to keep the original casing because it introduces name clashes in some cases:

interface Foo {
  get someProperty(): number
  getSomeProperty(): number
}

With the current naming strategy:

module Foo: sig
  type t
  val get_someProperty: t-> unit -> number
  val getSomeProperty: t -> unit -> number
end

If we made everything snake_case:

module Foo: sig
  type t
  val get_some_property: t-> unit -> number
  val get_some_property': t -> unit -> number
end

The prefixes like get_, set_, or cast_to_ are actually "meta" prefix, so I think we should make it easy for users to distinguish them from ordinary methods.