Strange and misleading error message when converting to JSON

2020-09-11 Thread alexeypetrushin
And if slightly modified, it produces another strange bug, if instead of 2 separate files everything united in 1 file it works.

Strange and misleading error message when converting to JSON

2020-09-11 Thread Araq
Looks like you hit :-)

how does `nimble develop` work?

2020-09-11 Thread jiyinyiyong
I was writing `cirruEdn#head`.

Strange and misleading error message when converting to JSON

2020-09-11 Thread alexeypetrushin
I isolated strange case where error message why it can't convert to JSON is very misleading. Please try code online to see it, click the "Run" button Nim complained that `State` can't be converted to JSON when in reality the problem was tha

default values for objects

2020-09-11 Thread alexeypetrushin
`new_xxx` is more flexible, yet having default parameters for object and shortcut notation for object initialisation, shortening `Obj(some_name: some_name)` as `Obj(some_name)` would still be useful. Example: type CrawlerRef*[J] = ref object id:string

Can I use generic type without interface?

2020-09-11 Thread alexeypetrushin
It works, but I'm not sure if Nim supposed to be used that way? I declared a generic proc `run` that can handle any type that has `id` field and `process` proc defined. So `J` generic type acts like an interface, is it ok to use it that way without explicitly specifying those requirements for th

Can't instantiate generic object with type restriction

2020-09-11 Thread alexeypetrushin
Thanks, but I'm not sure I can do that, the `Container` is declared before and in separate module than the `GetPriceJob`, so this `Container[T:Job | GetPriceJob]` declaration is impossible. The real example - I'm building a `Crawler` that should handle different types of `Jobs`. There's the `li

Set global response header for Jester when serving static files

2020-09-11 Thread Salient
Thanks @dom96 I got it working!

Exceptions in Threads

2020-09-11 Thread snej
> When an exception is thrown, and another thread try to access the error > message for example that thread will segfault. But ... how did the surviving thread get ahold of that error message? There would have to be something built into the exception runtime that sent it from the dead thread to

Pros vs. Cons Of Nim In The Large?

2020-09-11 Thread erikenglund
The compile times are getting bad. There was talk about a new strategy for this about a year ago or something, but I think the solution is simpler than that, like Jonathan Blow said when asked how he could compile so fast, "I don't do anything special or clever, I just don't do anything that is

Pros vs. Cons Of Nim In The Large?

2020-09-11 Thread snej
> the costs of software development are in the bug hunting phase and visibility > violations almost never produce bugs. Visibility problems can cause support problems, though. If you create & support a library, you don't want clients misusing it by calling functions that are supposed to be inte

About sink and copy: is this expected behavior?

2020-09-11 Thread snej
My non-expert opinion: Your first program is a no-op. Copying a B and then letting the copy go out of scope does nothing. It's possible the compiler completely optimized this away. Have you tried a program that does something with the copied value?

Compilation for different macOS version

2020-09-11 Thread snej
No, Apple's toolchain has pretty comprehensive support for specifying the degree of backward compatibility you want — the "Deployment version" in its terminology. The program will then only use system symbols available in that OS version. There are some environment variables you need to set whe

Is there any PWA (Progressive Web Apps) framework or package written in nim?

2020-09-11 Thread shirleyquirk
@francisL has done some recent work porting the latest version of webview

Exceptions in Threads

2020-09-11 Thread sschwarzer
> But it's not the case in Java, C#, Go because of thread-safe GC and it's not > the case of Javascript, Python and scripting languages in general because > they don't support threads. Why do you think Python doesn't support threads? :-)

Can't instantiate generic object with type restriction

2020-09-11 Thread shirleyquirk
because you specifically restricted Container to only accept Job. terrible error message, yikes. you'd need to type Job = object of RootObj id:string GetPriceJob = object of Job message:string Container[T:Job | GetPriceJob] = object job: T

Pros vs. Cons Of Nim In The Large?

2020-09-11 Thread deech
Have you had any issues with generics not being typechecked until they are instantiated? I've been bitten by it a couple of times and in a large codebase I can see it being a big problem.

Is there any PWA (Progressive Web Apps) framework or package written in nim?

2020-09-11 Thread mrhdias
Today, Google Play store and the Microsoft Store accept Progressive Web Apps. "If you are looking for quickly building an Android app that just starts and opens your PWA, checkout out the [Quick Start Guide.](https://developers.go

Is there any PWA (Progressive Web Apps) framework or package written in nim?

2020-09-11 Thread JohnAD
So, in keeping with the passive-aggressive thing: it would be great if we wrote a PWA framework and then made _extra_ sure it was never finished enough to be used. :) (that was meant to be humor.)

Is there any PWA (Progressive Web Apps) framework or package written in nim?

2020-09-11 Thread JohnAD
PWA actually do have a very rigid specification (from Google and ChromeOS) and a standard-in-practice from Apple that is pretty much the same. And, of the requirements, the least understood is the having a service worker. In theory, they are meant to replace stand-alone apps and are meant to be

Can't instantiate generic object with type restriction

2020-09-11 Thread alexeypetrushin
Code below won't work, but if type restriction `J: Job` removed and just the `J` used it works. How to fix that? type Job = object of RootObj id: string Container[J: Job] = object job: J GetPriceJob = object of Job message: stri

How to support compile time regex constructor /abc/ for JS backend?

2020-09-11 Thread juancarlospaco
But thats like an interpreter implementation detail almost an implementation bug, according to the official standard spec those should be basically the same, on other engines may or may not be the same, can even be the reverse. But feel free to send Pull Request if you implement it.

Pros vs. Cons Of Nim In The Large?

2020-09-11 Thread mratsim
. > Compilation speed: Nim is getting slower, with roughly the same number of > files it now takes two times what it used to need to compile last year. Why > is that? I think the maintainers should watch out for this. Everybody praises > nimc speed, but my computer is quite old, so I get to not

Change Nim colour on GitHub

2020-09-11 Thread mratsim
Now Araq can change his forum pic to yellow.

Is there any PWA (Progressive Web Apps) framework or package written in nim?

2020-09-11 Thread enthus1ast
Webview maybe?

Is there any PWA (Progressive Web Apps) framework or package written in nim?

2020-09-11 Thread mrhdias
Thanks for the replies. My idea was to have a tool to create an installable app automatically. For example for the Picheta snake game: /

Difference between configuration via .cfg, .nims, and nimble?

2020-09-11 Thread kaushalmodi
Normally people pick either `nim.cfg` or **config.nims** (I choose the latter). It boils down to preference. You can use config.nims with the nimble packages too. I choose to put only the stuff needed by nimble in the .nimble files. Benefit of this approach: * I have a central `~/.config/nim

Reversed traversal of iterators instead of creating a reversed copy

2020-09-11 Thread adokitkat
Thank you for a nice solution :) I went straight for a macro not considering overloading of an implicit iterator...

Pros vs. Cons Of Nim In The Large?

2020-09-11 Thread michy
Well written critics, thanks.

Change Nim colour on GitHub

2020-09-11 Thread Araq
It wasn't.

Pros vs. Cons Of Nim In The Large?

2020-09-11 Thread Stefan_Salewski
> Compilation speed: Nim is getting slower, with roughly the same number of > files it now takes two times what it used to need to compile last year. Why > is that? I think the maintainers should watch out for this. Everybody praises > nimc speed, but my computer is quite old, so I get to notice

Pros vs. Cons Of Nim In The Large?

2020-09-11 Thread Arrrrrrrrr
> Can anyone comment on the good and the bad points of Nim in larger (> 10KLOC) > projects? _My experience with nim (gamedev, CLOC 45.199, 589 files, ~5 years using it, amateur programmer), this is my personal POV:_ > Bad points **Bugs** : You will have to deal with bugs in the compiler. Som

Change Nim colour on GitHub

2020-09-11 Thread Arrrrrrrrr
Green was better.

Difference between configuration via .cfg, .nims, and nimble?

2020-09-11 Thread Arrrrrrrrr
> What is the difference in the way configuration files (nim.cfg), nimscript > (config.nims), and nimble are used? The difference resides in the set of bugs you have to deal with ;)

Any easy way to compare `==` object variants?

2020-09-11 Thread Arrrrrrrrr
Please, let's fix this once and for all. It is about time. When I get lazy and performance don't matter, I just do `return $this == $that`

Growth of popularity and Nim community

2020-09-11 Thread Arrrrrrrrr
Not always popularity is good, it could change Nim's direction for example (on the other hand, is always evolving). Community-wise, I'm happy how things are now.

openArray vs seq

2020-09-11 Thread Arrrrrrrrr
>needed only because array and seq aren't type-compatible It works for strings >too.

How to support compile time regex constructor /abc/ for JS backend?

2020-09-11 Thread pietroppeter
well, that was my original purpose. The idea could be to make a `cre` (backend compatible regex) module that exports only common functionality. And one first application I was thinking would be to use it to have nim-markdown support also js backend.

How to support compile time regex constructor /abc/ for JS backend?

2020-09-11 Thread xigoi
Unfortunately, JavaScript regex is very different from PCRE.

Exceptions in Threads

2020-09-11 Thread mratsim
`{.raises: [Defect].}` might be good enough. But that would mean that an IndexError might be left over and if it happens you won't be able to read it (or you need to run under GDB, debuggers can capture the exception output somehow)

Reversed traversal of iterators instead of creating a reversed copy

2020-09-11 Thread Arrrrrrrrr
Yeah, an 'ritems/mritems' would be nice, I used the countdown iterator for that purpouse so many times it is strange why I haven't defined my own iterator at this point.

how does `nimble develop` work?

2020-09-11 Thread dom96
What do your .nimble files look like? Nimble will pick `#head` unless you've written `requires "cirruEdn <= 0.1.8"` or similar.

keep signed into forum

2020-09-11 Thread dom96
Should be a fairly simple change, wanna create a PR? :)

How to support compile time regex constructor /abc/ for JS backend?

2020-09-11 Thread dom96
This is a nice module, someone should seriously consider making it seamless with Nim's `re` module so we can write code once and have it work on the C and JS targets.

Exceptions in Threads

2020-09-11 Thread dom96
It sounds like it would make sense for `{.thread.}` to add an implicit `{.raises: [].}` to the proc since no one would like their program to fatal in those circumstances. What does everyone think? @Araq?

About sink and copy: is this expected behavior?

2020-09-11 Thread wt
type A = object val: int B = object val: A proc `=sink`*(dest: var A, source: A) = echo "sink A" dest.val = source.val proc `=`*(dest: var A, source: A) = echo "copy A" `=destroy`(dest) dest.val = source.val

How to support compile time regex constructor /abc/ for JS backend?

2020-09-11 Thread pietroppeter
Well, yes, you are right, I am blushing now. :) Still, that expression literal is "compiled" when the script is loaded, or so [I read](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions). It also says that this could give a performance improvements, although thin

How to support compile time regex constructor /abc/ for JS backend?

2020-09-11 Thread juancarlospaco
Not a compile-time constructor in JavaScript because JavaScript wont compile. :)

How to support compile time regex constructor /abc/ for JS backend?

2020-09-11 Thread pietroppeter
Thanks to @juancarlospaco, we now have [Regular Expressions for the JavaScript target](https://nim-lang.github.io/Nim/jsre.html). In `jsre` module above the runtime regex constructor is supported but the compile time constructor is not. Compile time constructor in javascript looks like this:

Instantiation of uint32 type variables only with a maximum value of 2147483647

2020-09-11 Thread Stefan_Salewski
var i: uint32 = 2147483647 echo i echo typeof(i) echo typeof(2147483647) Run $ nim c -r t.nim 2147483647 uint32 int Run So for this case (non negative int) the compiler does an automatic type conversion. It is compile-tim

how does `nimble develop` work?

2020-09-11 Thread jiyinyiyong
changing to `cirruEdn#head` is likely to work... however it seems not working very correctly. I updated the source code in `cirruEdn` project and run `nimble develop`. Then I run `nimble install` in my current project, it showing type errors based on my updated source. And I run a task, it show

how does `nimble develop` work?

2020-09-11 Thread jiyinyiyong
Hi, I use ClojureScript and TypeScript, and I have some background on CoffeeScript. Nim is a really fast and elegant language(when Rust was designed to be too complicated).

Instantiation of uint32 type variables only with a maximum value of 2147483647

2020-09-11 Thread BugFix
Sorry to ask again. But on one condition: Default literals are of int type. Run shouldn't the following assignment be incorrect too? var i: uint32 = 2147483647 Run `i` is declared as uint32 and is assigned an integer by default. But this is t

how to package C-only project on macOS?

2020-09-11 Thread juancarlospaco
Try `--genScript:on` on the compiler and copy all the .c and nimbase.h and the .sh script to compile.