Nicer function anmes and other identifiers in the JS output

2021-03-19 Thread alexeypetrushin
> When developing a web app in Nim, you shouldn't look at the generated > JavaScript, just like you don't look at the generated C when developing a > native program in Nim. Disagree. If you are using JS, there are high chance that you going to need some JS libraries. And the simple the integrat

Nicer function anmes and other identifiers in the JS output

2021-03-19 Thread halloleo
Very good point. Didn't think of it. So, I guess - for good reasons - it is what it is.

Nicer function anmes and other identifiers in the JS output

2021-03-18 Thread xigoi
And then you could also have `proc test(n: int)`, since Nim supports name-based overloading…

Nicer function anmes and other identifiers in the JS output

2021-03-18 Thread ElegantBeef
Well the issue with always outputting the proper name is in Nim we have types, JS doesnt so the following code is valid in Nim. proc test(a, b: int) = discard proc test(a, b: float) = discard Run both output: function test(a,b){} Run

Nicer function anmes and other identifiers in the JS output

2021-03-18 Thread halloleo
> This could be default way for generating var names, at least those which are > not derived I think, at least it would be great to have an _option_ that all names are generated as is without the trailing number. Because it's pretty painful to add `{.exportc.}` to many declarations if you want

Nicer function anmes and other identifiers in the JS output

2021-03-18 Thread Yardanico
It doesn't matter for debugging as you have Nim stack traces and that compiler can generate source maps for the JS backend.

Nicer function anmes and other identifiers in the JS output

2021-03-18 Thread r3c
> When developing a web app in Nim, you shouldn't look at the generated > JavaScript, just like you don't > look at the generated C when developing a > native program in Nim. For simple todo app, sure.

Nicer function anmes and other identifiers in the JS output

2021-03-18 Thread sekao
> and other people in the organisation are no Nim fans - yet. ;-) I can assure you they will be even less fans of the generated JS output from Nim...

Nicer function anmes and other identifiers in the JS output

2021-03-18 Thread xigoi
When developing a web app in Nim, you shouldn't look at the generated JavaScript, just like you don't look at the generated C when developing a native program in Nim.

Nicer function anmes and other identifiers in the JS output

2021-03-18 Thread r3c
This could be default way for generating var names, at least those which are not derived. There's no need for names like `var answer_4576375436745 = 42` at all

Nicer function anmes and other identifiers in the JS output

2021-03-18 Thread enthus1ast
Then i would write it in JavaScript. (Or get the others to also write nim :) ). I think changeing the generated js code will get your team in a lot of troubles later on, and you cannot compile from nim any more, since you would lose the changes.

Nicer function anmes and other identifiers in the JS output

2021-03-18 Thread xigoi
You can export variables the same way as functions. JavaScript doesn't have custom types, so exporting a type doesn't really make sense.

Nicer function anmes and other identifiers in the JS output

2021-03-18 Thread halloleo
So, the self-defined function names look good now - Is any way to get my variables and types without the trailing numbers in the JS output?

Nicer function anmes and other identifiers in the JS output

2021-03-18 Thread halloleo
I expected a comment like this... :-) The whole situation is not ideal, of course, but other people (very occasionally) will need to maintain the code after I hand over the project - and other people in the organisation are no Nim fans - yet. ;-)

Nicer function anmes and other identifiers in the JS output

2021-03-18 Thread halloleo
The idea with `push` and `pop` is great; this way I can make all self-defined function names easily very readable.

Nicer function anmes and other identifiers in the JS output

2021-03-17 Thread xigoi
If you want an even worse idea: make Nim compile to TypeScript, so that type information is not lost :P

Nicer function anmes and other identifiers in the JS output

2021-03-17 Thread Araq
> I checked how the generated JavaScript looks, because at some stage we might > need to maintain the JavaScript output without the Nim source. Why would you ever do that... It's one of the worst ideas I've ever come across. For a start, the Nim source has valuable type information, the generat

Nicer function anmes and other identifiers in the JS output

2021-03-17 Thread Hlaaftana
Or just `{.exportc.}` to use the proc name. `{.push exportc.}` might help if you want to do it for multiple procs in a row

Nicer function anmes and other identifiers in the JS output

2021-03-17 Thread ElegantBeef
It's mainly just for JS interop but you can do `exportC: "Name"` on the procedure to give it a nice JS name.

Nicer function anmes and other identifiers in the JS output

2021-03-17 Thread halloleo
For my current project I use the JS backend. I checked how the generated JavaScript looks, because at some stage we might need to maintain the JaavScript output without the Nim source. So it is good that the JavaScript code is fairly readable, however all function names (plus other identifiers