VS Code Nim Extension in Nim

2020-09-29 Thread saem
I took a quick scan and this looks like exactly what I need, thanks so much! Also gives me another place to go spelunking because there is a bunch of overlap in this area. I also did a quick search in the git repo and I see hits in `nimsuggest` and `nimfind`, which got me thinking does a `findA

nimterop - sigjmp_buf

2020-09-29 Thread shirleyquirk
this sounds like a tough problem to debug, I doubt i'll be able to help, unless this: cImport(includeDir/"mupdf/fitz.h", dynlib="dynlibFile", flags="-f:ast2", recurse=true) Run is a typo: should that be `dynlib=dynlibFile` without the quotes?

using db_odbc with ms sql server on windows 10

2020-09-29 Thread shirleyquirk
I was able to replicate your error, on Linux, using microsoft sql-server, and the ms odbc driver. working on 1.2.0, not working on 1.2.6. but bleeding edge devel did fix it for me. Its not enough to `choosenim devel`, you need to `choosenim devel --latest` if you use choosenim. if the install d

faststreams and std async sockets

2020-09-29 Thread mratsim
Some Status libraries suffer from README driven development. That particular feature does exist and has a proof of concept but it was deemed too risky to add it at the moment given our time constraint, audit schedule and an Ethereum 2 launch just around the corner. Note that we don't use the st

Looking for collaborators!

2020-09-29 Thread mratsim
Big projects like this are always hard to approach. You should have a small guides of areas were people can contribute and how they can get started say: * parser * code generation * VM * test cases * examples * ...

weird nim parser problem

2020-09-29 Thread xigoi
> But `(1 +1)` cannot be interpreted as a function call. It will still be parsed like that because it might be useful in a macro. Parsing it differently would introduce a syntactic inconsistency.

[noob] Help with sets

2020-09-29 Thread xigoi
I don't think the point has been made clearly enough: the default `set` is a bitset. For _every possible value of the type_ , it stores a bit indicating whether it's present in the set. So you should use it only if the type has a limited range of possible values — usually with `enum` or `range`

using db_odbc with ms sql server on windows 10

2020-09-29 Thread sdmcallister
@shirleyquirk Just now switched over to devel branch. Built the same file that I've confirmed works on 1.2.0 but I see the same error: db_common.nim(100) dbError Error: unhandled exception: Error: unable to set ODBC driver version. [DbError] Run

faststreams and std async sockets

2020-09-29 Thread QMaster
Is there any ready to use implementation of async sockets with faststreams? The docs says that it is already there, but I hadn't found it.

nimx - image

2020-09-29 Thread mantielero
I am trying to load an image in `nimx`, but it always adds the current directory plus `/res`. It is related to [this issue](https://github.com/yglukhov/nimx/issues/435) I posted in github. Does anybody know how to avoid that behaviour? I just want to use [this](https://github.com/yglukhov/nimx

Looking for collaborators!

2020-09-29 Thread nocturn9x
Hi all folks! I'm writing this because I'm looking for collaborators for one of my side projects, it's a bytecode virtual machine for a (currently) toy language that I've been developing lately following an amazing book available for free at craftinginterpreters.com, you may find more technical

nimterop - sigjmp_buf

2020-09-29 Thread mantielero
I have a question, and I don't know the right place to raise it. I am trying to wrap MuPDF. To do so, I have **wrapper.nim** : import os, strformat import nimterop/[cimport, git] when defined(windows): # Windows specific symbols, options and files

weird nim parser problem

2020-09-29 Thread slonik_az
This is true for something like `(foo +1)`. But `(1 +1)` cannot be interpreted as a function call. In any case, I am not criticizing Nim's design decisions and I like the fact that it is different from other languages in a good way. But when it is "unexpectedly different" one needs to properly d

using db_odbc with ms sql server on windows 10

2020-09-29 Thread shirleyquirk
fix in latest devel now, so you can try that instead

weird nim parser problem

2020-09-29 Thread Araq
Well yes, but `+` is a unary operator. In fact, the spacing determines if an operator is unary or not. And that's what the manual says, you quoted the section.

weird nim parser problem

2020-09-29 Thread slonik_az
> > but 1+ 1 or 1 +1 result in error. Weird... > Believe it or not, I consider this to be a nice feature. First of all, it > means that the call syntax via juxtaposition (also used in eg. echo "hello > world") is not compromised too much. Secondly, it prevents ugly code like > yours that could

weird nim parser problem

2020-09-29 Thread Araq
> but 1+ 1 or 1 +1 result in error. Weird... Believe it or not, I consider this to be a nice feature. First of all, it means that the call syntax via juxtaposition (also used in eg. `echo "hello world"`) is not compromised too much. Secondly, it prevents ugly code like yours that couldn't get t

weird nim parser problem

2020-09-29 Thread spip
[Similar parsing features](https://forum.nim-lang.org/t/6189). Using correct spacing is important in Nim, for the parser and for those who read your code.

Update on --gc:arc

2020-09-29 Thread Araq
No, immutable data structures continue to be problematic for non-atomic reference counts. But you can use atomic reference counting for that and hack around the fact that it is "logically immutable -- except for the reference count operations".

weird nim parser problem

2020-09-29 Thread slonik_az
> Also note that whitespace will change precedence of `1 + 2 * 2` vs `1+2 * 2` No, it is not: echo (1 + 2 * 2) == (1+2 * 2) # returns true Run \--Leo| ---|---

it there general gitignore configs for binaries?

2020-09-29 Thread juancarlospaco
Devel has `nim r` that wont spamm EXEs.

weird nim parser problem

2020-09-29 Thread mratsim
That was why we removed the unary `<` operator when people started to have bugs in their `1 .. <10` expression. Also note that whitespace will change precedence of `1 + 2 * 2` vs `1+2 * 2`

Calling same-named-function from abstruct object

2020-09-29 Thread slonik_az
I think Nim already has all the mechanisms needed to prevent this type of code injection. If I have a module `foo.nim` with templates containing late binding `mixin` code I, as a provider, can only expose my clients to a carefully restricted `foo_api.nim` that only exports safe and hygienic code

Update on --gc:arc

2020-09-29 Thread e
Will immutable imply isolated? The [RFC244](https://github.com/nim-lang/RFCs/issues/244) doesn't say so, but [write-tracking](https://nim-lang.org/blog/2020/09/01/write-tracking.html) is coming, and would make sharing immutable structures possible.

weird nim parser problem

2020-09-29 Thread slonik_az
I found the following behavior puzzling: echo(1+1)# prints 2 as expectted echo(1 +1) # Error: in expression '1 1': identifier expected, but found '1' Run Notice a space between `1` and `+` in the second line. That makes all of the difference. Apparently, on

[noob] Help with sets

2020-09-29 Thread Levlan
ok. thanks.

it there general gitignore configs for binaries?

2020-09-29 Thread jiyinyiyong
Error: 'run' command not available; rebuild with -d:tinyc Run looks like I have to somehow reinstall nim before making it work...

it there general gitignore configs for binaries?

2020-09-29 Thread jyapayne
I usually use something like this: * !/**/ !*.* *.exe # anything else you want to ignore Run The top section will ignore everything, then add back directories and anything with an extension. Kind of a hack, but it works.

it there general gitignore configs for binaries?

2020-09-29 Thread cblake
Not sure about `.gitignore`, but you might also avoid your problem with `nim r tests/xxx.nim` which is fewer keystrokes and also should put the binary executables in the build cache directory (whatever `nimcache` is set to in the relevant `nim.cfg` | `config.nims` file).

[noob] Help with sets

2020-09-29 Thread exelotl
> So it seems i need to write the first number's type in the set explicitly to > define the sets type. Yeah, that's right, it's the same for seqs/arrays too. For example `[1, 2, 3]` is an array of `int`, while `[1'u, 2, 3]` is an array of `uint`. The compiler needs a helping hand to figure out

[noob] Help with sets

2020-09-29 Thread exelotl
> For signed integers the set's base type is defined to be in the range 0 .. > MaxSetElements-1 where MaxSetElements is currently always 2^16. The quoted text presumably means that the set's base type will be shifted into a suitable range so that the lowest possible value (e.g. `-32768`) corresp

it there general gitignore configs for binaries?

2020-09-29 Thread jiyinyiyong
`nimble c -r tests/xxx.nim` always generate binary files. I used it to run tests very frequently thus generated several binaries in different names. Can be annoying sometimes. Do you have any general configs of `.gitignore` for handling this?

[noob] Help with sets

2020-09-29 Thread Levlan
I know that int alone is int64 cause int is defined to be as the size of a pointer and int64 is not allowed as written in the tutorial. So it seems i need to write the first number's type in the set explicitly to define the sets type.

[noob] Help with sets

2020-09-29 Thread juancarlospaco
`var s = {2.int16, 7, 8, 9, 10}` If you write just the literal digit its an `int` and not an `int16`. `int` is an alias for `int64`, on 64 Bit hardware.

[noob] Help with sets

2020-09-29 Thread Araq
var s: set[uint16] = {2u16, 7, 8, 9, 10} Run But the memory consumption is not what you want, instead use a hash set from `sets.nim`: import sets var s1 = toHashSet([9, 5, 1]) Run

[noob] Help with sets

2020-09-29 Thread Levlan
Hello I'm trying to create a set using this line: var s: set[int16] = {2, 7, 8, 9, 10} Run and i get error saying: Error: type mismatch: got but expected 'set[uint16]' Run I tried to read the explanation in the tutorial but i can't get to

Define and call static proc of an object

2020-09-29 Thread mratsim
When you use callbacks like type S2[T;F:static[proc(a:T, b:T):T]] = object # can be defined discard Run The slowness is if those callback are actually closure that would be dynamically allocated. Instead you can ensure that the call is from a proc that is static

Calling same-named-function from abstruct object

2020-09-29 Thread chaemon
Thanks @Araq and @Stefan_Salewski. For now, heapqueue doesn't support custom comparison function. It only allows `<`. It is very inconvenient...

using db_odbc with ms sql server on windows 10

2020-09-29 Thread sdmcallister
@shirleyquirk I'll try that branch to see if it works. On nim version 1.2.0 I was able to get things working. Part of the issue had to do with configurations on my end with the drivers. The coded db errors msgs I received when using 1.2.0 helped me sort it out. I tried the working script using

Define and call static proc of an object

2020-09-29 Thread chaemon
Yes! I know it. I will explain the detail. I want to make an object that have data and do some operation among these data. These data and operation should be settable by user. For example, the following code will do such thing, i.e. proc f in S can be set any function like `+`, `*`, min, max.

Calling same-named-function from abstruct object

2020-09-29 Thread Araq
The scope of your `<` must be the global scope. (And we should really have that in the spec...)

Calling same-named-function from abstruct object

2020-09-29 Thread Stefan_Salewski
`import heapqueue type Q = object d:int #mixin `<` proc `<`(a, b:Q):bool = a.d < b.d proc main() = var q = initHeapQueue[Q]() for d in [3, 1, 4, 1, 5, 9, 2, 6, 5]: q.push(Q(d:d)) while q.len > 0: var a = q.pop() echo a.d main() ` Run

Calling same-named-function from abstruct object

2020-09-29 Thread chaemon
Is this a similar issue? I can't define operator `<` even if I insert mixin statement. import heapqueue proc main() = type Q = object d:int mixin `<` proc `<`(a, b:Q):bool = a.d < b.d var q = initHeapQueue[Q]() for d in [3,

Define and call static proc of an object

2020-09-29 Thread Stefan_Salewski
I do not really understand your question, and I still wonder what a "abstruct" from your other thread is. But do you know that you can use typedesc as proc parameters? So you can declare class methods or static methods as known from other languages like Python, see

VS Code Nim Extension in Nim

2020-09-29 Thread Araq
How to determine the main entry point of a project is encoded in compiler/options.nim, `proc findProjectNimFile`.

VS Code Nim Extension in Nim

2020-09-29 Thread saem
> Something I want to mention is that the original vscode extension (and by > extent also your translation) have a some half functional attempts at things > which I want to discuss. Yes please, there is a bunch of history I've been trying to suss out. On top of which just developing good taste

VS Code Nim Extension in Nim

2020-09-29 Thread saem
That stuff is a bit flaky because of the some of the changes I made and at some point it became pickier about `nim check` related errors. For now perhaps open an issue with relevant details.