-
Notifications
You must be signed in to change notification settings - Fork 23
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
better importjs: func fn(a: var int, b: int) {.importjs: "$2 = $3 + $2".}
#315
Comments
Automatic implicit dereferencing is disabled by default for C target tho. |
I'm assuming you're referring to P2. func fn(x: var T; b: T2) {.importjs: "$2 += $3".}
please elaborate |
@juancarlospaco since you'd also be one benefitting from this with your js PR's, would you consider working on this? |
While working on nim-lang/Nim#17422, I got a lot of (EDIT(timotheecour): i had to change the link you wrote since it's in another repo: #17422 => nim-lang/Nim#17422) |
maybe instead of proc `+`*(a, b: int128): int128 {.importcpp: "(# + #)".} # works, but requires C++
proc `+`*(a, b: int128): int128 {.importc: "(# + #)".} # doesn't work obviously
proc `+`*(a, b: int128): int128 {.pattern: "# + #".} # what i want (this RFC) the same syntax would work in c,cpp,js see also: nim-lang/Nim#15653 (comment) and #399 (comment) |
problem 1: var params
when var params are involved, the wrappers in std/jsbigints are more complicated than they should, and maybe even create overhead:
problem 2: referring to arguments out of order or multiple times
importjs
doesn't allow referring to arguments by position, creating more complex and potentially less efficient wrappers:proposal
$1
notation (which maps to the proc name) to allow referring to params (eg:$2
is 1st param)example:
$2
maps to($2)[0]
in jsexample:
example with a var param and a param referred to more than once:
()
around each param so these don't need to appear in declaration (to preventexample:
note: see nim-lang/Nim#16409 (comment) as to why parens are needed in the first place
()
wrapping the whole importjs expression, as soon as at least one un-escaped $ is detected; this is not the same as P3.TODO
figure out what to do with:
refs nim-lang/Nim#17296 (comment)
can this work non-ambiguously?
importjs
Nim#17422 (comment)links
importjs pragma is underdocumented and buggy · Issue #488 · timotheecour/Nim
The text was updated successfully, but these errors were encountered: