converting C++ typedef to nim-lang

2022-12-19 Thread nospher
I have this code in C++ works without problem. but when i transpiled to nim-lang i crashed all times. DWORD* floatingEnumInstance = *reinterpret_cast(base_address + 0x24FB358); typedef int(__thiscall* FloatingTextGetTextType)(DWORD* floatingEnumInstance,int textType);

Splat operator implementation with macros

2022-12-19 Thread Araq
Don't mistreat tuples as arrays, use arrays to begin with and the desire for a "splat" disappears.

Proposed method of writing filters in Nexus v2

2022-12-19 Thread jasonfi
Here's the example filter code include filter_types proc getAdminUsersWithReportsAccess(context: Context): AccountUsers = var filter: AccountUserFilter filter.whereEq.isAdmin = true filter.whereIn.names = @[ "User 1", "User 2" ] filt

Proposed method of defining models with Nim code in Nexus

2022-12-19 Thread jasonfi
Here's simpler way to write the models in Nim: import schema_types proc setupModels*() = var model: Model model.name = "Account User" model.description = "Users by account" model.tableOptions.namingCase = snakeCase var

Looking for resources about more complex generics, comptime type construction, etc.

2022-12-19 Thread ElegantBeef
Indeed: type A[T] = object var a: A[int] echo a.T Run

Looking for resources about more complex generics, comptime type construction, etc.

2022-12-19 Thread giaco
Generic parameters can be accessed as fields?

Nimwave - build TUIs for the terminal, web, and desktop

2022-12-19 Thread ElegantBeef
Spinning cubes are so last year, spinning hypercube or broke.

Looking for resources about more complex generics, comptime type construction, etc.

2022-12-19 Thread ElegantBeef
Well you wanted a collection, and the only collection I like using is `openarray` :P Jokes aside a `static seq`, `static openarray`, and `static array` are all identical in the compiler/vm, so the most flexible solution is `openarray`.

Looking for resources about more complex generics, comptime type construction, etc.

2022-12-19 Thread fsh
I didn't see the later part of your message! Did you add that in or did I just miss it. > And yeah, re: question 3 I couldn't convince the compiler to accept an > expression there, I got: "Error, cannot generate code for: M" and wrote an > omfg proc in frustration. This is, also, part of pushin

Looking for resources about more complex generics, comptime type construction, etc.

2022-12-19 Thread fsh
> You could make a type alias for the first part Yes, you're right, tho again I admit my example was a bit stupid, as I put a concrete `int` there but actually is kind of what remains generic, I just wanted to "focus" on certain parameters. Like a typeclass-alias, rather than a type alias. E.g

Tutorial for nim pixie graphics?

2022-12-19 Thread DougT
I had not seen pixiebook. If you google pixie graphics tutorial Run then I believe there is not a reference to pixiebook. I will study pixiebook and in about a week reply with what additional material I would like to see.

Looking for resources about more complex generics, comptime type construction, etc.

2022-12-19 Thread ElegantBeef
You could make a type alias for the first part type MyComplexGeneric[X;Y;Z;W] = object MyRelaxedGeneric[X;Y;Z;] = MyComplexGeneric[int, float, string, int] Run The latter you could likely use a macro cache and cache a type for your special arrays.

Looking for resources about more complex generics, comptime type construction, etc.

2022-12-19 Thread fsh
Hey, thanks so much for reply. > proc doThing(gen: MyGeneric) = discard # A generic type without parameters is > a typeclass Yep, this I got; I think of `MyGeneric = forall x, y: MyGeneric[x, y]`, but I meant if there's a way of getting `MyGenericIntLike = forall x: MyGeneric[x, int]`? Like a

Splat operator implementation with macros

2022-12-19 Thread ElegantBeef
You cannot use a macro inside the call statement as it does not back propagate as you'd want, there is no way of adding the expanded ast to the parent ast, it either is a `StmtList`, `Bracket` or whatever type of tree you emit, it never gets added to the call as a argument.

Looking for resources about more complex generics, comptime type construction, etc.

2022-12-19 Thread ElegantBeef
To work through this list a bit type MyGeneric[A;B;C;D: static int, E: static float] = object proc doThing(gen: MyGeneric) = discard # A generic type without parameters is a typeclass Run 3 is a compiler bug. I think a more sensible approach to last type is t

Tutorial for nim pixie graphics?

2022-12-19 Thread UxDnz0
Doing fonts/text so well, and comprehensively deserves much respect man. The pixiebook entry could do with a bit more code though :D (The pixie repo examples are already pretty good here though..)

Looking for resources about more complex generics, comptime type construction, etc.

2022-12-19 Thread shirleyquirk
> Often I also get very confusing error messages (or even hit internal > assertions in the compiler) If you're crashing the compiler, you've found a bug! Search for it in the issue tracker on GitHub, see if someone's reported it already, and if so, add your test case to the comments. If not, ad

Tutorial for nim pixie graphics?

2022-12-19 Thread treeform
Have you seen ? What kind of tutorials would you like to see?

Tutorial for nim pixie graphics?

2022-12-19 Thread DougT
I have not found a tutorial. I think we need something more in depth than the simple examples on Github treeform/pixie. References to more detailed examples would also be helpful.

Splat operator implementation with macros

2022-12-19 Thread resolritter
I'd like to implement an operator `...` such that: type Point = tuple[x, y: int] let p1: Point = (2,2) let p2: Point = (3,3) echo sum(1, ...p1, ...p2) # expands to sum(1, 2, 2, 3, 3) Run Based on , which refers to

Trouble with Nim debugging in VS Code

2022-12-19 Thread Clonk
Debugging with the compile time switch : `--debugger:native --stacktraces:on -d:useMalloc --mm:orc`; I haven't had any issues using GDB and Valgirnd (at least no more than I would have had for a similar C++ program).

Trouble with Nim debugging in VS Code

2022-12-19 Thread doofenstein
it's a bit of an unfortunate thing to say, but it's not going to get much better than this. If you haven't been using --debugger:native already, that does makes some things like breakpoints work atleast in theory. Though if you have ever debugged C++ code, you know that when turning on the slig

Advent of Nim 2022

2022-12-19 Thread fxn
I saw that [Noulith](https://github.com/betaveros/noulith) has x max= y Run as a (conceptual) shortcut for x = max(x, y) Run which is often handy for AoC in particular. And just realized you can write that in Nim, for example:

Looking for resources about more complex generics, comptime type construction, etc.

2022-12-19 Thread fsh
I am often in need of types which can carry a lot (or more complex) static compile-time information, à la: type SomeType[A: static[...], B: static[...], C: static[...], ...] = object ... Run I'm in general looking for some resources / documentation that goes more in

Nimwave - build TUIs for the terminal, web, and desktop

2022-12-19 Thread moigagoo
I see putting things on spinning cubes is your thing 😅

Nimwave - build TUIs for the terminal, web, and desktop

2022-12-19 Thread moigagoo
OMG that would be so awesome. Especially if the UI would be responsive as the Turbo Pascal IDE was.

Nimwave - build TUIs for the terminal, web, and desktop

2022-12-19 Thread sekao
Sure, and with Nimwave's OpenGL renderer you can put your Turbo Pascal like editor on a spinning cube :D Damn, that's a project idea...

Mr. Rumpf, why didn't you went along with the Python standard library?

2022-12-19 Thread linwaytin
How about this?

Mr. Rumpf, why didn't you went along with the Python standard library?

2022-12-19 Thread Araq
Nim is not similar enough to Python for this to provide any benefits. Instead Nim's standard library evolved with the Nim compiler and offers many little improvements like `multiReplace` or `containsOrIncl` and Python really should look into stealing.

Nimwave - build TUIs for the terminal, web, and desktop

2022-12-19 Thread Araq
Can this be used to implement a Turbo Pascal-like editor?

Mr. Rumpf, why didn't you went along with the Python standard library?

2022-12-19 Thread jasonfi
Give ChatGPT a try. It's not perfect, but it can give you some ideas quickly. The question you asked about not going the way of the Python library is implying that Nim is a sped-up clone of Python, which it isn't.

Mr. Rumpf, why didn't you went along with the Python standard library?

2022-12-19 Thread matkuki
`Nim` has got (in my opinion) the best `Python` interop out there: [nimpy](https://github.com/yglukhov/nimpy)

Mr. Rumpf, why didn't you went along with the Python standard library?

2022-12-19 Thread aEverr
because nim is not specifically aimed to be similar to python in every sense

Mr. Rumpf, why didn't you went along with the Python standard library?

2022-12-19 Thread ElegantBeef
Nim is not a Python subset. It is its own distinct language with its own design principles. Aside from passing similarities they have very little in common.

Mr. Rumpf, why didn't you went along with the Python standard library?

2022-12-19 Thread NameUndefined
Because Nim is not meant to be a compilable python, but if you still need some of python modules or functions there may be rewrites somewhere on the internet. For instance Narimiran ported the [itertools](https://github.com/narimiran/itertools) python module to nim.

Mr. Rumpf, why didn't you went along with the Python standard library?

2022-12-19 Thread grd
Right now I am struggling quite a lot with a new program that I am trying to rewrite. Everything is slightly different from the standard library of Python. So why did you got rid of this? Some of the things are pretty well thought of, I am well aware that they aren't designed to be as performant

Trouble with Nim debugging in VS Code

2022-12-19 Thread Clonk
Do you compile with --debugger:native ?

Why is the cursor pragma called cursor?

2022-12-19 Thread Araq
The literature it was based on called it a "cursor" too. I cannot cite the paper right now though, I've read too many.