Skip to content
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

Rethink about JS object method name encoding #999

Closed
bobzhang opened this issue Dec 14, 2016 · 3 comments
Closed

Rethink about JS object method name encoding #999

bobzhang opened this issue Dec 14, 2016 · 3 comments

Comments

@bobzhang
Copy link
Member

relevant reasonml/reason#849
cc @chenglou @hhugo (Jordan name does not auto-complete..)

This is a design issue, lets not rush to make the decision. So currently the name mangling serves two purpose: (we currently reuse the same mangling scheme for the two different purposes which might not be good)

  1. expression some properties not expressible due to lexical restrictions for example keyword keys like open
  2. allow more expressivity to method overloading

With regard to purpose 2, we should de-mangling after type checking, otherwise it defeats the purpose of name mangling.

With regard to purpose 1, we also need consider when we do the de-mangling,

  • Ideally we should de-mangling as soon as we can, for example if Reason allows x."Foo" and it is inferred as type { "Foo" } this binding
    can not be consumed on OCaml side, we have to write x##_Foo, but the type checker will refuse to type check those programs. (we can allow x##"Foo" too).

  • But if we de-mangle at the syntax level, it will enforce us to provide a solution for type level de-mangling, currently user only need write < _Foo : .. > Js.t without ppx, in this case, we should ppx object types and class types (more complexity introduced), maybe we should completely hide Js.t by saying [%bs: < _Foo : > ]

Another issue is that current name mangling _ is too short that it is confusing to people since create_name is a normal name, maybe we should make it __ for purpose 2.

@bobzhang
Copy link
Member Author

bobzhang commented Dec 14, 2016

I think it is okay to consume reason bindings from OCaml even we de-mangling after type checking. Since reason bindings already provide types, so we only need expression to be capable of expressing keyword properties. In that case, I only need allow x##"open" which is not that bad (but types have to be declared on reason side)

@bobzhang
Copy link
Member Author

current name mangling rules are documented here: http://bloomberg.github.io/bucklescript/Manual.html#_object_label_translation_convention

@bobzhang
Copy link
Member Author

bobzhang commented Feb 13, 2017

Based on what we described above:

We introduce two cases where name mangling will be introduced

  1. single underscore followed by an OCaml keyword (does reason introduce new keywords?) or CAPITAL letter
_open -> open
_in -> in 
_mod -> mod 
_MAX_LENGTH -> MAX_LENGTH
  1. double underscore for ad-hoc polymorphism
self##hey__     -->  self.hey
self##hey__two --> self.hey

note if it is a keyword, it is perfectly fine to have this

self##open__ --> self.open
self##open__two -> self.open

how about such cases, the simple rule is always apply rule 2 first, then rule 1

self##_Capital__  -> self.Capital
self##_open__ -> self.open

bobzhang added a commit that referenced this issue Feb 14, 2017
bobzhang pushed a commit that referenced this issue Aug 2, 2017
PR #999 changed the status line to be printed when edges finish on dumb
teerminals, but the default status message includes the number of
started edges, resulting in sequential status lines with identical
edge counts.

Change the default status to show the number of finished edges, which
will keep the count incrementing on every line.  This will slightly
change the output on smart terminals.  Previously a build that was just
starting would show a count equal to the number of concurrent jobs, and
a build waiting for the final jobs to finish would show a count equal to
the total number of edges.  Now a starting build will show 0, and build
waiting for the final jobs will show a count less than the total number
of edges by the number of remaining jobs.

Fixes: #1142
bobzhang pushed a commit that referenced this issue Aug 2, 2017
PR #999 made dumb terminals only output when edges
finish. BuildStatus::overall_rate_ stopwatch is only initialized to the
current time when PrintStatus is called with finished_edges_ == 0, but
on a dumb terminal it will be called for the first time when
finished_edge_ = 1, which results in very long elapsed times:
NINJA_STATUS="[%r processes, %f/%t @ %o/s : %es ] "
[0 processes, 2/2 @ 0.0/s : 1461869902.367s ]

Reset the stopwatches in BuildEdgeFinished before finshed_edges_ is
incremented instead.
bobzhang pushed a commit that referenced this issue Aug 2, 2017
PR #999 made dumb terminals only output when edges finish.  PrintStatus
is called after finished_edges_ is incremented, which means the
calculation for running edges will always return 1 less than the real
number of running processes.  This happens on smart terminals too, but
ninja will immediately print the status for the next edge with
starting_edges_ incremented, so the incorrect value is never visible.

Pass a boolean specifying whether the status is being printed on an edge
finishing, and if so count the edge that just finished as being running.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant