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

Add #mangle example for fixing C identifiers (to conform nep1-style) #218

Merged
merged 1 commit into from Aug 10, 2021
Merged

Add #mangle example for fixing C identifiers (to conform nep1-style) #218

merged 1 commit into from Aug 10, 2021

Conversation

haxscramper
Copy link
Contributor

Given

void foo() {}
void foo_() {}
void foo__() {}
void __foo() {}
void __foo__() {}
void foo_bar_() {}
void foo_bar() {}
void _foo_bar_() {}
void foo() {}
void foo_() {}
void foo__() {}
void __foo() {}
void __foo__() {}
void foo_bar_() {}
void foo_bar() {}
void _foo_bar_() {}
void _____foo___var_asdfasdf_asdf_asdfa_() {}
void ______________asss____() {}
void ____s_____() {}

outputs

proc foo*() =
  discard

proc foo*() =
  discard

proc foo*() =
  discard

proc foo*() =
  discard

proc foo*() =
  discard

proc foo_bar*() =
  discard

proc foo_bar*() =
  discard

proc foo_bar*() =
  discard

proc foo*() =
  discard

proc foo*() =
  discard

proc foo*() =
  discard

proc foo*() =
  discard

proc foo*() =
  discard

proc foo_bar*() =
  discard

proc foo_bar*() =
  discard

proc foo_bar*() =
  discard

proc foo___var_asdfasdf_asdf_asdfa*() =
  discard

proc asss*() =
  discard

proc s*() =
  discard

which seems to be what most users would want

Given

```c
void foo() {}
void foo_() {}
void foo__() {}
void __foo() {}
void __foo__() {}
void foo_bar_() {}
void foo_bar() {}
void _foo_bar_() {}
void foo() {}
void foo_() {}
void foo__() {}
void __foo() {}
void __foo__() {}
void foo_bar_() {}
void foo_bar() {}
void _foo_bar_() {}
void _____foo___var_asdfasdf_asdf_asdfa_() {}
void ______________asss____() {}
void ____s_____() {}
```

outputs 

```nim
proc foo*() =
  discard

proc foo*() =
  discard

proc foo*() =
  discard

proc foo*() =
  discard

proc foo*() =
  discard

proc foo_bar*() =
  discard

proc foo_bar*() =
  discard

proc foo_bar*() =
  discard

proc foo*() =
  discard

proc foo*() =
  discard

proc foo*() =
  discard

proc foo*() =
  discard

proc foo*() =
  discard

proc foo_bar*() =
  discard

proc foo_bar*() =
  discard

proc foo_bar*() =
  discard

proc foo___var_asdfasdf_asdf_asdfa*() =
  discard

proc asss*() =
  discard

proc s*() =
  discard
```
which seems to be what most users would want
@haxscramper haxscramper changed the title Add note for invalid nim identifier fixes Add #mangle example for fixing C identifiers (to conform nep1-style) Aug 6, 2021
@Araq Araq merged commit 1d559c1 into nim-lang:master Aug 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants