Plans for improving tagged enum (ADT) syntax?

2022-12-12 Thread Araq
> Particularly for anyone who wants to write things like interpreters, > expression/query languages, etc. Having an ergonomic representation for ADT's > makes a world of difference there. Well I'm one who has written things like interpreters, expression/query languages and not one "who wants to

Plans for improving tagged enum (ADT) syntax?

2022-12-12 Thread arnetheduck
> In theory you can flatten it. Not only flatten, but also reorder the fields (by size roughly) - ie these are two "common" optimizations outside of C/C++ that I think we could adopt in Nim, but that would require said ABI feature. > In practice there will be code that uses the Branches type C

Update on strict funcs

2022-12-12 Thread haxscramper
So effectively this change will cause the following changes to the experimental strict funcs: func a(x: var int) = discard func b() = var x = 1 var p = addr x a(x) # OK a(p[]) # FAIL, was OK before Run

strictNotNil and bogus “cannot prove” errors

2022-12-12 Thread Araq
That was mostly a design decision and proving anything that contains unstructured control flow is much harder than you think. Compare it to ML's (Rust's, Swift's ...) pattern matching to understand why it's done this way. "Use early return to save levels of indentation" is just completely and o

A new way for Nim to shine ? Faster than NodeJS interpreted Nim, taking advantage of declared types

2022-12-12 Thread sls1005
Python also has this syntax: T = int | float a: list[T] = [1, 2, 3] Run The Nim-like type-annotation was interduced in Python 3.5, long after Nimrod was released, but before it renamed to Nim.

How do I ‘subclass’ StringStream?

2022-12-12 Thread snej
For posterity, here’s how to initialize a StringStream subclass. It’s a hack, but it works, and I don’t believe it’s possible to do any better without API changes in the `streams` package. type MyStreamClass* = object of StringStreamObj myData: int MyStre

strictNotNil and bogus “cannot prove” errors

2022-12-12 Thread snej
I tried the old not-nil pragma back in 2000 or so, and it definitely wasn’t ready for prime time. Today I thought I’d try `strictNotNil` with the current Nim 1.6.10, so I added it in one source file and sprinkled in a few `not nil` annotations. As expected there were some legit warnings, but als

Plans for improving tagged enum (ADT) syntax?

2022-12-12 Thread GavinRay
Sorry to dredge up a two-week old post, just wanted to say I think this is a very important topic Particularly for anyone who wants to write things like interpreters, expression/query languages, etc. Having an ergonomic representation for ADT's makes a world of difference there.

Transpile Nim to Dart/Flutter?

2022-12-12 Thread ShalokShalom
Oh, if we are recommending other GUI toolkits, I am quite fond of Godot. Its by far the most comfortable, complete and coherent option out there. For me

Transpile Nim to Dart/Flutter?

2022-12-12 Thread juancarlospaco
Blender is preparing to become a GUI Framework, and it can already easily do complex GUI with ready-made themable widgets, 2D/3D, PBR, CPU/GPU, Raytracing, VR/AR, shaders, openGL, 3D sound, network, camera, sockets, IO, video, mobile planned, visually outperforms QtGL, we already have wrapper.

Best practices for initializing objects?

2022-12-12 Thread jcosborn
These might be workarounds and/or opportunities for compiler enhancement. A pure alias doesn't respect `requiresInit` itself, though maybe that could be changed. A distinct wrapper does work if you don't mind that. Unfortunately converting `FooBarImpl` to `FooBarO` doesn't seem to work, though t

Best practices for initializing objects?

2022-12-12 Thread arnetheduck
> Anyway, I’m wondering if the Nim community has evolved some explicit best > practices for object initialization. We have some here:

Transpile Nim to Dart/Flutter?

2022-12-12 Thread ShalokShalom
For those, that look for a "compile to Dart" language Much fun

Best practices for initializing objects?

2022-12-12 Thread Araq
> But if there were a simple change that would make the constructor pattern > work better, would you consider it? I don’t have one in mind but I’ll think > about it. Definitely. I thought `out` parameters might offer something in this regard but right now they don't.

How should system library support be structured?

2022-12-12 Thread elcritch
I was able to get highlighting by manually setting the project file. Nice, yah I looked at the VSCode Nim based extension. Its confusing with all the vscode/nodejs file apis, but fundamentally it just calls some form of execProc to start nimsuggest. Impressive that @saem got it running with Nim

Best practices for initializing objects?

2022-12-12 Thread snej
I found a partial workaround, by redefining `newFoo` as: proc newFoo* [F: Foo = Foo](f: int) : F = F(foo: f) Run Then I can initialize a FooBar like so: proc newFooBar(f: int, b: int) : FooBar = result = newFoo[FooBar](f) result.bar = b

Best practices for initializing objects?

2022-12-12 Thread snej
> You can also structure your code so that "initial all zeros" objects are > valid objects. Yup, I’m used to that from Go, and it’s often good enough. But in this case my actual code has something like an `OwnedObject` type that must have an owner, so `nil` is not a valid value for its `owner`

Best practices for initializing objects?

2022-12-12 Thread Araq
Yeah, that's the downside of Nim's ultra minimal support for OO. You can use this idiom: # foos.nim type Foo* = object of RootObj foo: int proc newFoo*(f: int) : Foo = Foo(foo: f) proc init*(f: var Foo, x: int) = f.foo = x Run

Best practices for initializing objects?

2022-12-12 Thread treeform
You can also structure your code so that "initial all zeros" objects are valid objects. Make first Enums start out Undefined or Empty, if you do actions on the object it can check for nils and initialize them. This is what Nim's `seq` does.

Best practices for initializing objects?

2022-12-12 Thread snej
Thanks! But how do I handle a situation where I subclass a type marked `requiresInit` that has private fields? Here’s an example (Nim 1.6.10) foo.nim type Foo* {. requiresInit .} = object of RootObj foo: int proc newFoo*(f: int) : Foo = Foo(foo: f)

Show Nim: TheArtButton.ai, a new web Stable Diffusion runner

2022-12-12 Thread treeform
I made a new video tutorial here: One thing that can be difficult when generating assets for a game is keeping the style consistent. In this video I show how I generate multiple variations of an asset while keeping a consistent style between them.

Nimble is unable to download and install

2022-12-12 Thread Araq
Interesting, maybe Nimble should use `poParentStreams` then.

Nimble is unable to download and install

2022-12-12 Thread krakengore
The osproc methods also works for me if i use the `poParentStreams` but not without.