Reason: ocaml `let switch = 3` prints as `let match = 3;`

Created on 24 Feb 2017  路  9Comments  路  Source: reasonml/reason

Most helpful comment

Swapping strings seems limited in this case.
Do we have infra to substitute this way?

1) ml -> re
match -> switch
switch -> switch_
match_ -> match
switch_ -> switch__
match__ -> match_
switch__ -> switch___
match___ -> match__
...

2) re -> ml
switch -> match
match -> match_
switch_ -> switch
match_ -> match__
switch__ -> switch_
match__ -> match___
switch___ -> switch__

So e.g.
match switch with
ml -> re
switch switch_ {
re -> ml
match switch with

All 9 comments

Converting OCaml to Reason? This is intended.

lmao, cc @bobzhang. I guess I kinda get it? Leaving this open til it's documented

To clarify a bit more: within Reason let switch is a syntax error while in OCaml let match is a syntax error.

Swapping strings seems limited in this case.
Do we have infra to substitute this way?

1) ml -> re
match -> switch
switch -> switch_
match_ -> match
switch_ -> switch__
match__ -> match_
switch__ -> switch___
match___ -> match__
...

2) re -> ml
switch -> match
match -> match_
switch_ -> switch
match_ -> match__
switch__ -> switch_
match__ -> match___
switch___ -> switch__

So e.g.
match switch with
ml -> re
switch switch_ {
re -> ml
match switch with

name mangling is something I would like to avoid if we can.

switch x {
  case None => 0;
  case Some x => x 
}

match x {
  case None => 0;
  case Some x => x
}

They are mostly the same?

@cristianoc I really like your suggestion - it's simple, we should definitely do it.

@cristianoc We don't have the infra to substitute this way but I think we should do this.

Fixed through #1539

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bluddy picture bluddy  路  3Comments

braibant picture braibant  路  4Comments

modlfo picture modlfo  路  4Comments

TrakBit picture TrakBit  路  3Comments

cristianoc picture cristianoc  路  4Comments