More Nim on more Microcontrollers!? (Arm CMSIS / Zephyr RTOS)

2021-09-11 Thread elcritch
> My evenings for the past couple weeks were spent (re)writing this: > Fantastic! I'm looking forward to digging into it next week. Luckily my day job now includes writing Nim on embedded devices. :-) > It seems to be working, I have a test that checks all reg

More Nim on more Microcontrollers!? (Arm CMSIS / Zephyr RTOS)

2021-09-11 Thread elcritch
To join in on the sharing party, I've been working on Zephyr support in the Nim stdlib. It's working now, but not ready for an upstream PR (yet). But if you're curious: CMSIS support would be awesome. @auxym any thoughts on hardware you'd like

More Nim on more Microcontrollers!? (Arm CMSIS / Zephyr RTOS)

2021-09-11 Thread auxym
Hi everyone :) My evenings for the past couple weeks were spent (re)writing this: It seems to be working, I have a test that checks all register addresses against those in a reference C header (generated by ARM's tool, SVDConv). The API is detailed in the rea

I'm having a Nim+Lua+Libtcod callback wrapping problem

2021-09-11 Thread Skaruts
I tried something that I thought might work, but it doesn't. I'm not being able to capture the lua state in the `PathProc`. _path.nim(81, 17) Error: illegal capture 'L' because ':anonymous' has the calling convention: Run I annotated line 81 below: #==

What does ref object key return

2021-09-11 Thread EnteryName
Hi, today I've seen a code that was returning a reference to an object, and for trying I coded a simple script but it gives me errors such as type mismatch. This is an example of what I've tried to do: `` type A = ref object proc x(): ref A = var x = A() return ref A() var obj = x() `

Weave+ARC WIP or my bug?

2021-09-11 Thread ggibson
Thanks @Araq, I was just beginning to realize this while playing with the destructors, but I'm very glad to get set straight! I agree about linked lists. Unfortunately, linked list is an elegant solution for what I'm doing (tree of life phylogeny simulation stuff). I'll see about using an edge l

Weave+ARC WIP or my bug?

2021-09-11 Thread Araq
The auto-generated destructors are recursive and you produce a stack overflow with long linked lists. Give your type a custom destructor and ideally stop using linked lists, they have been a bad idea for the hardware for about 20 years now.

Is it possible to tell `import` to not create const with same name as imported module?

2021-09-11 Thread Araq
> And instead of doing import unit as unit when you need it, in 1% of cases, > you do import unit as unit_module almost for every second module you use in > 99% of cases. > > Extremely inconvenient. So name your module `units.nim`. It's a convention too.

Why is backward index operator [^1] not zero based [^0]?

2021-09-11 Thread Araq
> When you work with low-level protocols and buffers 0-based makes more sense. I don't see how that follows. > Also: Oh god not this again, I've debunked it multiple times already. Exlusive upper bounds only work when you

Weave+ARC WIP or my bug?

2021-09-11 Thread ggibson
This has nothing to do with Weave. Even remaking the example to use built-in threading mechanisms causes the same symptoms of slowness and crashing when compiled with ARC.

Why is backward index operator [^1] not zero based [^0]?

2021-09-11 Thread xigoi
0-indexing makes more sense. Why are the years 19xx in the 20th century, _except_ 1900, which is in the 19th century? Because of 1-indexing. If anything, 1-indexing is a “legacy” of the fact that humans used to be afraid of 0.

Nim 1.6.0 RC1

2021-09-11 Thread xigoi
Is it possible to use `--experimental` without crashing if I'm on a Nim version that doesn't support it?

Weave+ARC WIP or my bug?

2021-09-11 Thread ggibson
I didn't find any statements that ARC and Weave don't work together, but they seem to not work together with even a trivial example. Found some older forum discussion by mratsim on the topic Putting `loadBalance(Weave)` in and out makes me think this has

Why is backward index operator [^1] not zero based [^0]?

2021-09-11 Thread alexeypetrushin
I didn't meant math and science, I meant general programming. But ok, as a system lang, and needs to be well integrated with widely adopted zero based, ok then.

Why is backward index operator [^1] not zero based [^0]?

2021-09-11 Thread mratsim
I doubt that math and science are the main Nim use-case either. A system language better be excellent at the base layer.

Is it possible to tell `import` to not create const with same name as imported module?

2021-09-11 Thread haxscramper
Maybe just name modules differently from variables, like stdlib does - options, macros, strutils, times ... Also i can't reproduce the issue anywhere but top-level: import std/strutils let strutils = "" # fails Run import std/strutils

Why is backward index operator [^1] not zero based [^0]?

2021-09-11 Thread alexeypetrushin
I believe they mentioned somewhere that it was a conscious choice, as it makes more sense, not just random inheritance. > When you work with low-level protocols and buffers 0-based makes more sense. Maybe. But we are talking about majority of use cases. I doubt that low-level protocols and buff

Is it possible to tell `import` to not create const with same name as imported module?

2021-09-11 Thread alexeypetrushin
When you `import unit` it's impossible to use `let unit = Terran.init(name: "Jim")` Because import would create a const with `unit` name. Is there a way to avoid it? It's needed in 1% of cases, and not needed and creates problem in 99% of cases. And instead of doing `import unit as unit` when

Why is backward index operator [^1] not zero based [^0]?

2021-09-11 Thread mratsim
When you work with low-level protocols and buffers 0-based makes more sense. Julia inherited 1-based for Fortran and Matlab.

Nim 1.6.0 RC1

2021-09-11 Thread alexeypetrushin
> \--experimental:overloadableEnums # Allow enum field names to be overloaded. > I hope some libraries make good use of this feature. Huge thanks!

Why is backward index operator [^1] not zero based [^0]?

2021-09-11 Thread Araq
Personally I think what makes little sense is to have the first element at zero, it causes the constant friction between `a.len` and `a.high` and `..` vs `..<` and off-by-one errors. It's a legacy.

Why is backward index operator [^1] not zero based [^0]?

2021-09-11 Thread alexeypetrushin
> Personally I think what makes little sense is to have the first element at > zero +1, I worked a little bit with Julia, it has zero based arrays, it feels better.

Keep a http connection alive and hand it off to another proc

2021-09-11 Thread ingo
a simplified version. Two things went wrong. Somehowe it got into my head a callback for the asyncstream is required. It is not and that makes life simpler. No more need to deal with the connections directly, just link the socket_fd to a specific stream. The other one was a waitFor instead of an

Why is backward index operator [^1] not zero based [^0]?

2021-09-11 Thread enthus1ast
Python and Nim might look the same at first, but are very different languages.

Why is backward index operator [^1] not zero based [^0]?

2021-09-11 Thread filip
Thanks guys. With Nim aiming to be a Python alternative I guess it makes sense to copy their logic.