Square brackets for generics

2020-10-29 Thread timothee
D has the best syntax here, a!T, a.b!T, a![T1,T2] No ambiguity between normal and UFCS, and shorter syntax for the common case.

handmade hero in nim ( warning: noob)

2020-10-29 Thread nucky9
Yeah, I had the same problem - hopefully you had more success than I did!

Is there a way for case objects to have cases share fields?

2020-10-29 Thread sky_khan
> I also tried nkDocument, nkCanvas, but I need nkCanvas to eventually be > different from document? Not possible for now:

Is there a way for case objects to have cases share fields?

2020-10-29 Thread shirleyquirk
`type NodeKind = enum nkDocument nkCanvas nkRectangle Node = ref object case kind: NodeKind of nkDocument,nkCanvas: children: seq[Node] of nkRectangle: box: Rect ` Run

Is there a way for case objects to have cases share fields?

2020-10-29 Thread treeform
I want both nkDocument and nkCanvas to have children, but not nkRectangle? Is there a way to do this? type NodeKind = enum nkDocument nkCanvas nkRectangle Node = ref object case kind: NodeKind of nkDocument: childre

Is there a way for case objects to have cases share fields?

2020-10-29 Thread treeform
I also tried nkDocument, nkCanvas, but I need nkCanvas to eventually be different from document? Node = ref object id: string name: string case kind: NodeKind of nkDocument, nkCanvas: children: seq[Node] of nkCanvas: backg

handmade hero in nim ( warning: noob)

2020-10-29 Thread 19
Okay so i got to the DirectSound, and it looks like it's a gigantic bug pile of ugly Win32 C++ OOP stuff. I think I'm gonna be stuck here for a while as i figure out how to bind it. I'm comfortable binding C stuff but this has weird interfaces and macros. I got input bindings pretty effortlessl

Why does this proc may have side effects?

2020-10-29 Thread fxn
@Araq I mean, where do you put the pragma and where's the hints? I couldn't make it work.

Posix mqueue Thank for Nim

2020-10-29 Thread JPLRouge
Hello : environment : Linux Manjaro 20.1.2 XFCE GCC-LIBGCC-NIM I would like to share, I was helped I spent more than 48 hours in a row To relate the Linux C system development book to Nim. So a lot of reading, to match the programs correctly, as well as going from array to char * to cstring

Why does this proc may have side effects?

2020-10-29 Thread Araq
> Do you know how to use the effects macro here? I didn't try it, but it should say that `+` has a side effect (what else?) and then you need to edit times.nim's `+` operator with the effects macro to get further information.

What is Kernel32?

2020-10-29 Thread Ward
Yes, they are comments. I just keep the list to remind myself and other developer where the definitions come from.

Nim videos and tutorials survey

2020-10-29 Thread juancarlospaco
... But where?, link to channel or something.

Square brackets for generics

2020-10-29 Thread Araq
> None of these are perfect, ... So why change anything... ;-)

What is Kernel32?

2020-10-29 Thread Sixte
Thank you, it worked. Another question: regarding the tremendous list of #includes in winim: What happens with them? They are simply comments, aren't they? A bit ironic: looks perfectly like C but isn't. But if so, are the includes to be declared elsewhere for the compiler?

What is Kernel32?

2020-10-29 Thread Sixte
I just tried to compile a project relying on the windows API, in particular "VirtualProtect", therefore the function gets declared with a "windows.h" header. Nim went trough, but gcc stopped because of a missing "Kernel32". Indeed, the C intermediate contains an #include "Kernel32" ( I'd expect

What is Kernel32?

2020-10-29 Thread treeform
I recommend using winim, it appears to have the function you are looking for:

Why does this proc may have side effects?

2020-10-29 Thread fxn
@Araq in this case the problem is that the time zone could change between calls and therefore this is not a pure function? Do you know how to use the `effects` macro here?

Why does this proc may have side effects?

2020-10-29 Thread Araq
The `+` operator has a side-effect as it calls `inZone` which access the Timezone.

Mysterious crashed with SIGSEGV

2020-10-29 Thread Stefan_Salewski
I strongly assume that with --gc:arc the problem is only hidden but still exists. Generally it is gc:arc which shows issues early, while gc:refc can hide memory issues until GC starts. So in old days when ARC was not available I often added GC_fullcollect() calls to the gintro code to enforce e

Why does this proc may have side effects?

2020-10-29 Thread cblake
I do not know for sure, but suspect it is from time zone construction. This works just added to the end of the posted example: func diff*(a, b: DateTime): Duration = a - b Run

Mysterious crashed with SIGSEGV

2020-10-29 Thread KnorrFG
Interestingly, under Windows, the problem was the same. However, once I added --gc:arc the problem was gone. On both OSes.

Why does this proc may have side effects?

2020-10-29 Thread juancarlospaco
The time has a side effect.

Comment tree?

2020-10-29 Thread Araq
Well that's why I'm never on HN or Reddit, I think it's a terrible UI experience.

Why does this proc may have side effects?

2020-10-29 Thread fxn
Hi! This is an exercise from exercism.io: import times const gigasecond = initDuration(seconds = 1_000_000_000) proc addGigasecond*(moment: DateTime): DateTime = moment + gigasecond Run If I replace `proc` with `func`, the compiler complains th

What Nim projects are you working on?

2020-10-29 Thread rockcavera
I was working on some improvements to my [iputils](https://github.com/rockcavera/nim-iputils) package. I still intend to implement some more things in the library. I have a DNS protocol package and a simple DNS client finalized, but I'm still documenting and making some changes before launching

Comment tree?

2020-10-29 Thread Invalid_Username
Test

help use mq posix

2020-10-29 Thread shirleyquirk
il ne faut pas definir une nouvelle proc: `mq_open` in posix.nim c'est `varargs`, alors elle va accepter `(cstring,cint...)` You don't need a new proc: `{.importc varargs.}` procs accept multiple arguments. The documentation for posix could be revised to reflect that. import posix,

Comment tree?

2020-10-29 Thread digitalcraftsman
I guess @Invalid_Username means a comment section like on Hackernews, where comments can have their own comments, thus creating a tree. In contrast, threads on this forum are linear. A tree-style comment section allows a better seperation of discussions within a forum thread, because you only ha

Termios missing when building on Windows?

2020-10-29 Thread drkameleon
Totally, unimportant. I was using just one function: `clearScreen`. I removed it and it all seems to be working fine right now. I'll find another way to do the same thing P.S. I've been struggling with setting up workflows for GitHub Actions all morning... and since I wanted some CI for Windows

Comment tree?

2020-10-29 Thread Araq
No idea what you mean.

Termios missing when building on Windows?

2020-10-29 Thread Araq
You don't need linenoise.nim on Windows as the Windows terminal always supports the arrow keys. There is a `rdstdin.nim` stdlib module that you can use. Depends on how many terminal features you need though.

Comment tree?

2020-10-29 Thread Invalid_Username
Is it possible to get a comment tree function?

Subrange check during initialisation

2020-10-29 Thread Araq
The compiler currently doesn't try the init property for global variables. This produces the warning: type DiceVal = range[1..6] proc m = var d: DiceVal echo d m() Run

Termios missing when building on Windows?

2020-10-29 Thread drkameleon
The projects builds fine under Ubuntu and macOS. However, when trying to build for Windows, I keep getting the following error: ...\nim-1.4.0\lib\wrappers\linenoise\linenoise.c:106:21: fatal error: termios.h: No such file or directory #include ^

Nim videos and tutorials survey

2020-10-29 Thread hrm
Practical tiny tips for templates/macros may be helpful for a novice like me. On top of that, I vote for @sky_khan.

Subrange check during initialisation

2020-10-29 Thread lscrd
The check is done for the implicit variable “result” and we get the usual warning: `Warning: Cannot prove that 'result' is initialized. This will become a compile time error in the future. [ProveInit]` Why not for a normal variable? type DiceVal = range[1..6] proc throwDic

Mysterious crashed with SIGSEGV

2020-10-29 Thread KnorrFG
Thanks for the tipps, Ill look into valgrind and try to run it under windows

Mysterious crashed with SIGSEGV

2020-10-29 Thread Stefan_Salewski
> So I'm wondering When your parser code does not contain dangerous stuff like use of cast, addr, ptr then changes are good that it should not do random crashes. But I assume niGui will contain all that, so chances for bugs are much larger unfortunately. A tiny bug can allow invalid memory modi

Subrange check during initialisation

2020-10-29 Thread xigoi
I swear I did something like this not so long ago and Nim did complain.

Mysterious crashed with SIGSEGV

2020-10-29 Thread KnorrFG
I tried to find out whether the problems are in the parser, or in nigui. I wrote a small program (nigui_test, also in the repo), that renders the same graph (just much larger) based on random, and I added some tests for the parser (in the bottom of parser.nim). The Gui works without problems, an

Subrange check during initialisation

2020-10-29 Thread haxscramper_
No, currently this is just how default initialization is implemented. See [RFC #252](https://github.com/nim-lang/RFCs/issues/252) and [RFC #126](https://github.com/nim-lang/RFCs/issues/126), specifically this [comment](https://github.com/nim-lang/RFCs/issues/126#issuecomment-615014367)

Subrange check during initialisation

2020-10-29 Thread haxscramper_
Not this is not a bug. All objects are zero-initialized upon construction.

Subrange check during initialisation

2020-10-29 Thread michy
This compiles and prints 0 : type DiceVal = range[1..6] var d : DiceVal echo d # -> 0 Run Obviously the 0-initialisation is not checked. Compiler bug?

Subrange check during initialisation

2020-10-29 Thread Stefan_Salewski
It is a bug. I have seen a similar discussion some years ago for enums I think. Maybe we have a needsInitialization pragma which can catch this, but I can not find it yet.

Square brackets for generics

2020-10-29 Thread gemath
> Well you can call printSqured(b) and have its T inferred and that makes all > the difference. True. Two different ways around this: * calling it like this `printSquared()(b)` to indicate the inferred first parameter list (sucky IMHO) or * defining it in upper-case proc Pri