Conversion-to-string-function is hard to find

2024-05-15 Thread dsrw
This is really just repeating what @SolitudeSF said, but you can't find the `string` function because it doesn't exist. A `Path` is a distinct string, so essentially it's already a string. `Path("/some/path")` is a type conversion from `string` to `Path`, and `string(myPath)` is a type conversio

Single parameter version of varargs

2024-05-09 Thread dsrw
This works: proc toRange(a: HSlice[int, int]): HSlice[int,int] = a proc toRange(a: int): HSlice[int,int] = a..a proc toIntSeq(a: HSlice[int, int] | int): seq[int] = let r = a.toRange for v in r: result.add(v) echo toIntSeq(20) echo to

how to use parseExpr in runtime ?

2024-01-23 Thread dsrw
Evaluating a script at runtime with the VM is pretty straightforward, but bridging the VM and your host program so they can pass data and call into each other is a bit more complicated. The [tcompilerapi.nim](https://github.com/nim-lang/Nim/blob/devel/tests/compilerapi/tcompilerapi.nim) test in

Enu 0.2

2023-12-08 Thread dsrw
Your code, and any bots/blocks that you place or edit should be saved automatically. If they don't that's a serious bug and I'd really like to hear more about it. If it truly isn't saving, please ping me on [Discord](https://discord.gg/BWHUs4Wc) or report it on [Github](htt

How to create local packages

2023-12-06 Thread dsrw
. `requires "https://github.com/dsrw/model_citizen 0.18.17"`), then run `nimble setup`. This will fetch your dependencies into your `~/.nimble` directory and create a `nimble.paths` file pointing to them. Normally I develop like this, but if I need to work on a dependency I update t

Enu 0.2

2023-12-05 Thread dsrw
I just added [discussions](https://github.com/dsrw/enu/discussions) to the github repo. If anyone has support requests, or general comments that don't fit here, please ping me there or on [Discord](https://discord.gg/BWHUs4Wc).

Enu 0.2

2023-12-05 Thread dsrw
Thanks for the feedback. I really appreciate it. I'll have to do more "non happy path" testing for prototypes. It sounds like you were instancing a prototype that was instancing a prototype, which should work of course, but none of my demos actually do that so it must have broken at some point.

Enu 0.2

2023-12-04 Thread dsrw
This is GREAT! Thank you! I'm really curious to hear where the pain points are, and what you need to keep going. I'm really proud of this release, but the fact of the matter is that there are a LOT of missing features required for real game development, and I'd like to prioritize development bas

Enu 0.2

2023-12-04 Thread dsrw
I guess I didn't really answer the question. Using Nim and Godot together has mostly been great. I wish it had better support for hot code reloading, but the fact that many errors get caught at compile time means I have to iterate less to get something working. GDScript code samples translate to

Enu 0.2

2023-12-03 Thread dsrw
[nim-godot](https://github.com/pragmagic/godot-nim) is excellent. Rock solid in my experience. However, it's mostly unmaintained and it's Godot 3 only, which is at this point is a fairly major issue. It's still working very well for me, but it's hard to look at the shiny new Godot 4 features and

Enu 0.2

2023-11-30 Thread dsrw
If you or anyone tries that I'd love to see a screenshot or a video. I'm usually awful at that sort of thing, but I'll give it a go if I find a day that seems easy enough :)

Enu 0.2

2023-11-29 Thread dsrw
Thank you! If you do try it I'd love to hear how she makes out. Eventually I want Enu to ship with a full programming tutorial/course, but for now teaching a newcomer will definitely require some handholding.

Enu 0.2

2023-11-29 Thread dsrw
Enu 0.2 is finally here! This has been "a month or two away" for about 2.5 years now, but in the end I decided to hold off on releasing it until it's actually good. Well, it's good now. This is the biggest update to Enu by far, and adds a host of new features like multithreading, multiplayer (us

Questions about Nim and its extensibility

2022-10-28 Thread dsrw
> As @dsrw said, it's possible to write a sub-language in Nim, this is very > interesting. You could have a macro that took a filename as a parameter, read the file, ran it through a parser of some sort, then used the parse tree to generate Nim code which would be compiled into y

Questions about Nim and its extensibility

2022-10-27 Thread dsrw
Nim is really extensible. Features like async/await, `->` style anonymous functions, and string interpolation are defined in the stdlib, with little to no language level support. I have a lot of Ruby experience, a language know for its metaprogramming capabilities, and Nim is significantly more

Nim 1.6.8 release candidate

2022-09-09 Thread dsrw
I'm excited to try this out. Thanks! I'm probably too late, but would it be possible to get included?

Enu - 3d live programming and game dev in Nim

2022-06-02 Thread dsrw
[Enu 0.1.99](https://github.com/dsrw/enu/releases/tag/v0.1.99) has been released! This is the final release before 0.2! Maybe! I've also released a new demo video that uses Enu to create `Inky: Isolation`, a simple survival game that stars Inky, the blue ghost from Pac-Man. <https://

Enu - 3d live programming and game dev in Nim

2022-03-02 Thread dsrw
After almost 13 months and 263 commits, a new version of Enu has finally been released. [Enu 0.1.97](https://github.com/dsrw/enu/releases/tag/v0.1.97) is the first preview of Enu 0.2, which should be out in the next 3 - 6 weeks. Significant new features since 0.1.2: * A [prototype based

Nim devroom at FOSDEM this weekend

2022-02-05 Thread dsrw
The dev room was great! Thanks to the organizers. If anyone posts their videos elsewhere, could you link them here? I had to miss 4 of the videos today, and I'd really like to see them all. I put my video (Potato Zombies) up at .

Nim 1.6.4 release candidate

2022-01-30 Thread dsrw
That fixed my issue. Thank you!

Nim 1.6.4 release candidate

2022-01-25 Thread dsrw
I'm getting `SIGBUS: Illegal storage access. (Attempt to read from nil?)` crashes using [godot-nim](https://github.com/pragmagic/godot-nim) with this version. I also saw this in 1.6.2 (but not 1.6.0 or earlier) and assumed it would be fixed by , but ei

NIM IDE

2021-10-26 Thread dsrw
According to VSCode is used by > 70% of developers, so a good VSCode plugin seems like the best way to attract new users. Fortunately we already have that. There's also

Nim 2.0 -- thoughts

2021-10-10 Thread dsrw
I haven't spent a lot of time in the guts of the compiler, but from what I've seen it's in good shape. Nim is evolving quickly (I can't think of a mature language that's moving faster), is fairly easy to work on, and critical bugs are fixed quickly when found. I'm sure there are things the team

How to get Name and Value from Variable for macro/template

2021-06-29 Thread dsrw
Personally, I'd say that only exported symbols are usable in future cells, and then I'd load each cell in its own module and have each module automatically import all previous modules/cells. Advantages: * Very easy. * Works without any parsing or macros. * You get cell/module local variab

Type-safe DSL / Data Schema

2021-06-29 Thread dsrw
You probably want [macros.expectKind](https://nim-lang.org/docs/macros.html#expectKind%2CNimNode%2CNimNodeKind) or [macros.error](https://nim-lang.org/docs/macros.html#error%2Cstring%2CNimNode). When you have the `NimNode` that you're interested, either pass it to `expectKind` or do whatever c

Is there a way to build better Nim DSL for plotting?

2021-06-29 Thread dsrw
This is a bit of an aside, but you could implement this whole TS feature with Nim macros. Rather than writing a DSL for plotting, you could write a macro that takes a schema and produces types and a DSL using a pretty similar format to TS. It might be a decent amount of work, and I'm not sure if

Sandboxing untrusted Nimscript code

2021-06-28 Thread dsrw
> I claim the VM's sandboxing is then very good. That's really great to hear. Thank you very much.

Sandboxing untrusted Nimscript code

2021-06-28 Thread dsrw
I'll also be running untrusted nimscript code in the not too distant future. I was planning to rely on os provided process sandboxing, but being able to lock down nimscript as suggested here would make my life easier. What's the general confidence level that this would actually work? Can I lock

I am confused. Javascript, WASM coroutine support ?

2021-03-23 Thread dsrw
1\. Coroutines are definitely my #1 feature request for Nim, but for now they aren't well supported. The [coro module](https://nim-lang.org/docs/coro.html) is an unstable API that hasn't seen much attention recently. It works well under the arc/orc garbage collector, but has problems with the de

createInterpreter in a DLL

2021-02-13 Thread dsrw
Great, I'm glad you got things working. Unfortunately I don't know the Nim GC well enough to say if this is a valid fix, or if it's just a band-aid that will cause problems down the road, but it seems like a step in the right direction at least. ARC/ORC manages to sidestep most of these problem

Enu - 3d live programming and game dev in Nim

2021-02-13 Thread dsrw
Thank you! That's really nice to hear. 1.0 is still far off, but getting to the point were other people can use enu has been really rewarding. > How can I contribute? I'm planning to do a v0.1.2 release soonish (in the next week or two) that focuses on bug fixes and quality of life improvements

createInterpreter in a DLL

2021-02-11 Thread dsrw
Your example works for me if I build and run it like this: nim c --app:lib --define:useNimRtl interpdll.nim nim r --define:useNimRtl interptest.nim Run You'll need to build `nimrtl.dll` from the instructions at a

Using nim libraries

2021-02-08 Thread dsrw
is a nim app with a runtime plugin system, so it might be worth checking out. briefly talks about GC with dlls. You can only have one copy of the GC per process, so you build your app and dlls without a ru

createInterpreter in a DLL

2021-02-08 Thread dsrw
64 bit. Both the nim dll and the app that loads it are built with mingw. This sounds more like a GC issue than something specific to the VM. `--gc:regions` or `--gc:orc` may help, although I'm sure someone more knowledgeable than myself could get it working with the default gc.

createInterpreter in a DLL

2021-02-08 Thread dsrw
I'm using NimScript in a DLL, but I don't think I did anything special to make it work. I'm compiling with `--noMain --app:lib`, the default gc, and I'm not using nimrtl. I don't think you need nimrtl if your DLL is the only nim code in the process. I have no idea what could be wrong, but I can

Enu - 3d live programming and game dev in Nim

2021-02-03 Thread dsrw
Enu 0.1 has finally been released. Only 3 months late! <https://github.com/dsrw/enu/releases/tag/v0.1.0> has x64 binaries for Mac, Windows and Linux. The Linux build has only been tested on a single Ubuntu 20.4 system, and I expect there will be issues. Report them here or on github and

Listening for variable changes in Nim?

2020-10-28 Thread dsrw
This isn't nearly as sophisticated, but you can do something like this with a regular getter/setter too. It won't work for a plain variable, but if it makes sense to tie it to an object, you can do this: # robots.nim type Robot* = object name: string proc

Enu - 3d live programming and game dev in Nim

2020-10-27 Thread dsrw
I just released a [new demo video](https://youtu.be/upg77dMBGDE) for Enu and [posted it to Hacker News](https://news.ycombinator.com/item?id=24908514). I'd very much appreciate some love. Enu 0.1 will release on Nov 6th with Mac/Windows binaries, and will be validated to build and run on the la

What Nim projects are you working on?

2020-10-27 Thread dsrw
I'm working on [Enu](https://github.com/dsrw/enu), a 3D live-programming/block-building type environment that hopes to make programming (particularly 3D game programming) more accessible. It's my first Nim project, and I'm really happy with how it's turning out. I just crea

Enu - 3d live programming and game dev in Nim

2020-09-25 Thread dsrw
The initial release will mostly be for education. People (mainly kids) could use it to learn the basics of coding, and maybe put together a few interesting worlds. I run a coding club with a group of 10 year olds, so we'll be using it there. Sort of a 3D Scratch alternative. Eventually, I'd lik

Enu - 3d live programming and game dev in Nim

2020-09-25 Thread dsrw
Thanks for the feedback. I've added Godot to the description, and will explicitly mention it in the next video.

Enu - 3d live programming and game dev in Nim

2020-09-25 Thread dsrw
At Nim conf 2020 I did a quick talk about Enu, a 3d live programming environment that I've been working on. It's still a few weeks from an initial release, but I recorded another video and I thought I'd share it: <https://youtu.be/AW0PT9j976s> The code is at <htt

Nim embedded inside Python

2020-09-01 Thread dsrw
If you call a specific proc, you get back a (PNode)[, which you can get a value out of. Something like: import compiler / [nimeval] writeFile "script.nim", "proc main*: string = \"hello world\"" let

Pause/resume the Nim VM

2020-08-29 Thread dsrw
How should I be getting ahold of the top of the stack? Do I need to return it from `rawExecute`, or can I get it from PCtx somehow?

Pause/resume the Nim VM

2020-08-24 Thread dsrw
Great. I’ll get a PR together. Thanks!

Pause/resume the Nim VM

2020-08-24 Thread dsrw
air bit of time trying to come up with something with iterators, but I couldn't make it work. What I ended up doing is patching the Nim VM to explicitly support pausing/resuming. [https://github.com/dsrw/enu/commit/5662f28dbb5e105116cd6d1236eb6913ce79c74b](https://github.com/dsrw/enu/commit

Using the compiler API for hot code reloading

2020-08-20 Thread dsrw
This is a hack, but it works for me on 1.2.6. If you `include` rather than `import` `nimeval`, you can access the `ModuleGraph` for the interpreter and register an error hook. This will be called for all sorts of things, but if you validate that `errorCount >= errorMax` you should be able to fil