Re: Is this a bug or just unallowed naming?

2020-02-25 Thread miran
> I know I can change the file name to resolve the problem

Or, more pragmatically, you change the name of the type to `Foo` (uppercase 
`F`), as that is the idiomatic Nim.


Re: Is this a bug or just unallowed naming?

2020-02-25 Thread Hlaaftana
This is a bug, I haven't tested it but if you use `foo.foo` for the type it 
should work.


NGA Card Search Appears To Be Missing Taramir: The Dark Tide

2020-02-25 Thread johnken
Click on Card Search on the top right corner of this page to get to a place 
where you can see all sorts of player made cards. On that page, in the Set 
field, click on Taramir: The Dark Tide and then click the Search button and the 
results will come up empty. I do not know if the link is somehow broken, if the 
set simply does not exist (or at least within the card search database), or 
whatever else may be going on. All of the other sets come up fine when I click 
on them so I doubt it is something on my end. 


Is this a bug or just unallowed naming?

2020-02-25 Thread Ward
Should I report this as a bug? I know I can change the file name to resolve the 
problem, but it works well before I use table.

foo.nim 


type
  foo* = ref object of RootObj
data: int


Run

bug.nim 


import tables
import foo

type
  R = ref object of RootObj
T: Table[int, foo]

var f: foo # succeed
# var r: R # Error: internal error: getTypeDescAux(tyVoid)


Run


Re: How to get Nim running on iOS and Android using GLFM.

2020-02-25 Thread treeform
It looks like your wiish project is exactly what I want!

I am working on my own UI thing called fidget ( 
[https://github.com/treeform/fidget](https://github.com/treeform/fidget)/ ) - 
my long term goal is to make fidget just work on Android and iOS, just like it 
does on Win/Mac/Linux and Web now.

I'll be looking at your thing very closely. Thank you for doing this.


Re: I have a super doubt

2020-02-25 Thread adilh
Hello, if you learn by example you could take a look at exercism: 
[https://exercism.io](https://exercism.io)/ there's a nim track there. I found 
that the mentors didn't seem to be around (my guess is they were very busy with 
their day jobs), but you can choose practice mode and then you can see how 
other folks solved the problem. hth adil


Re: How does nim infer that a cpu on windows is 64-bit

2020-02-25 Thread shashlick
I just tried your test on my Windows setup and it worked fine for me. Following 
are the md5sum of the DLLs that got installed by choosenim.

> md5sum sqlite3_32.dll => 943d354608f9b87ad5e6c5c632e7272c
> 
> md5sum sqlite3_64.dll => d25af52d213f114aefa16370ec699f88

Not sure what else to tell you.


Uploading large files via httpclient request

2020-02-25 Thread adilh
Hello, I would like to upload a large file to a NextCloud instance using Nim. I 
have figured out how to authenticate. What I was wondering is how can I upload 
a large file. Clearly, I can't open the file and read the whole file into 
memory (it's 10GB). I was wondering if I have to do something like:

create http client

open file and read in chunks:
http put chunk to next cloud

close http client

I am puzzling over the httpclient.request procedure. It seems as if I would be 
doing lots of separate put requests and not streaming the data. Is it possible 
to open the file and pass the filehandle to the request and then the request 
procedure would just read the file in chunks and send it to the server?

Sorry if this is a bit confused. I can upload a small file, but larger files 
are puzzling me.

Many thanks for your help, adil


Re: How to get Nim running on iOS and Android using GLFM.

2020-02-25 Thread iffy1
@treeform I think compiling of the app and the bundling should be separate 
tools/steps. I've been working on wiish as I try to get my own mobile app out: 
[https://github.com/iffy/wiish](https://github.com/iffy/wiish)

It works somewhat well (SDL and webview apps). I'm going to be focusing more on 
webview apps for now (since that's what I'm making). The goal is to be able to 
do:


wiish init
wiish run --ios
wiish build --target ios


Run

And end up with an iOS app. The above works today on my computer, at least :) 
It also somewhat works for Android. There's also a `wiish doctor` tool to help 
you get your computer ready to go.


Re: How does nim infer that a cpu on windows is 64-bit

2020-02-25 Thread pietroppeter
today to try and solve this issue I did remove all previous nim folders and I 
installed it again using the most recent choosenim I could find: the release 
choosenim-0.5.1_windows_amd64 from github. I would assume that to install the 
64bit version of Nim but maybe I am wrong (or maybe choosenim tries to infer 
the architecture and install the version he thinks is the correct).

Regardless of arch, even moving the dll sqlite3_32.dll in the same folder as my 
nim test file (and the resulting .exe) the error is still (when running the 
exe): could not load sqlite3_32.dll


Re: How does nim infer that a cpu on windows is 64-bit

2020-02-25 Thread shashlick
You need to install the 64bit version of Nim to match your new gcc. If you 
didn't have gcc when you started, choosenim would install 32bit by default. 
This was recently improved but you probably have an older choosenim.

Regardless of arch, the problem is the dll so please try copying it to the same 
dir as the exe and try that. You don't need to fiddle with arch unless you have 
a specific need that depends on arch. 


Re: How does nim infer that a cpu on windows is 64-bit

2020-02-25 Thread pietroppeter
thank you, I did download mingw64 (I actually used the one which would have 
been downloaded from choosenim at url 
[https://nim-lang.org/download/mingw64.7z](https://nim-lang.org/download/mingw64.7z))
 and now I have a different error message when compiling a simple `echo 
"hello"` program which is quite explicit (nim compiler and gcc do not agree on 
target architecture):


In file included from 
C:\Users\ppeterlongo\nimcache\hello_d\@mhello.nim.c:9:0:
C:\Users\ppeterlongo\.choosenim\toolchains\nim-1.0.6\lib/nimbase.h:457:13: 
error: size of array 'Nim_and_C_compiler_disagree_on_target_architecture' is 
negative
 typedef int Nim_and_C_compiler_disagree_on_target_architecture[sizeof(NI) 
== sizeof(void*) && NIM_INTBITS == sizeof(NI)*8 ? 1 : -1];
 ^~


Run

So it appears I am back to square one. Even if my gcc compiler is a 64 bit one 
now, nim compiler still thinks I am on a 32 bit architecture (which is probably 
also the reason why chooesnim installed mingw32 instead of mingw64).


Re: How does nim infer that a cpu on windows is 64-bit

2020-02-25 Thread pietroppeter
thank you, I see now that mingw is the 32 bit version (I did learn that 
i686-w64-mingw32 is 32 bits while x86_64-w64-mingw32 would be the 64 bit 
version). I think I will try first to download and install mingw64. Yes, I 
checked and the dlls are in my path.


Re: How does nim infer that a cpu on windows is 64-bit

2020-02-25 Thread Hlaaftana
You have to download [mingw64](http://mingw-w64.org/doku.php), your GCC is 
mingw32, then you can either add it to your Path or set Nim's GCC compiler path 
to mingw64 like `nim c --gcc.path=C:\mingw64\bin` (I think). Here is a Nim 
compiler user guide: 
[https://nim-lang.org/docs/nimc.html](https://nim-lang.org/docs/nimc.html)


Re: How does nim infer that a cpu on windows is 64-bit

2020-02-25 Thread shashlick
As you can see, your compilers are 32bit so you need the 32bit version of the 
dll. Is it really in your path? 


Re: How does nim infer that a cpu on windows is 64-bit

2020-02-25 Thread pietroppeter
yes, sure.


-v

Nim Compiler Version 1.0.6 [Windows: i386]
Compiled at 2020-01-23
Copyright (c) 2006-2019 by Andreas Rumpf

git hash: 89b39ee8fe271d0e1b75c15a4c6cf82eb9c13aea
active boot switches: -d:release


Run


 -v

Using built-in specs.
COLLECT_GCC=C:\Users\ppeterlongo\.choosenim\toolchains\mingw32\bin\gcc.exe

COLLECT_LTO_WRAPPER=C:/Users/ppeterlongo/.choosenim/toolchains/mingw32/bin/../libexec/gcc/i686-w64-mingw32/6.3.0/lto-wrapper.exe
Target: i686-w64-mingw32
Configured with: ../../../src/gcc-6.3.0/configure --host=i686-w64-mingw32 
--build=i686-w64-mingw32 --target=i686-w64-mingw32 --prefix=/mingw32 
--with-sysroot=/c/mingw630/i686-630-win32-dwarf-rt_v5-rev1/mingw32 
--enable-shared --enable-static --disable-multilib 
--enable-languages=c,c++,fortran,lto --enable-libstdcxx-debug 
--enable-libstdcxx-time=yes --enable-threads=win32 --enable-libgomp 
--enable-libatomic --enable-lto --enable-graphite --enable-checking=release 
--enable-fully-dynamic-string --enable-version-specific-runtime-libs 
--enable-libstdcxx-filesystem-ts=yes --disable-sjlj-exceptions --with-dwarf2 
--disable-libstdcxx-pch --disable-libstdcxx-debug --enable-bootstrap 
--disable-rpath --disable-win32-registry --disable-nls --disable-werror 
--disable-symvers --with-gnu-as --with-gnu-ld --with-arch=i686 
--with-tune=generic --with-libiconv --with-system-zlib 
--with-gmp=/c/mingw630/prerequisites/i686-w64-mingw32-static 
--with-mpfr=/c/mingw630/prerequisites/i686-w64-mingw32-static 
--with-mpc=/c/mingw630/prerequisites/i686-w64-mingw32-static 
--with-isl=/c/mingw630/prerequisites/i686-w64-mingw32-static 
--with-pkgversion='i686-win32-dwarf-rev1, Built by MinGW-W64 project' 
--with-bugurl=http://sourceforge.net/projects/mingw-w64 CFLAGS='-O2 -pipe 
-fno-ident -I/c/mingw630/i686-630-win32-dwarf-rt_v5-rev1/mingw32/opt/include 
-I/c/mingw630/prerequisites/i686-zlib-static/include 
-I/c/mingw630/prerequisites/i686-w64-mingw32-static/include' CXXFLAGS='-O2 
-pipe -fno-ident 
-I/c/mingw630/i686-630-win32-dwarf-rt_v5-rev1/mingw32/opt/include 
-I/c/mingw630/prerequisites/i686-zlib-static/include 
-I/c/mingw630/prerequisites/i686-w64-mingw32-static/include' CPPFLAGS=' 
-I/c/mingw630/i686-630-win32-dwarf-rt_v5-rev1/mingw32/opt/include 
-I/c/mingw630/prerequisites/i686-zlib-static/include 
-I/c/mingw630/prerequisites/i686-w64-mingw32-static/include' LDFLAGS='-pipe 
-fno-ident -L/c/mingw630/i686-630-win32-dwarf-rt_v5-rev1/mingw32/opt/lib 
-L/c/mingw630/prerequisites/i686-zlib-static/lib 
-L/c/mingw630/prerequisites/i686-w64-mingw32-static/lib 
-Wl,--large-address-aware'
Thread model: win32
gcc version 6.3.0 (i686-win32-dwarf-rev1, Built by MinGW-W64 project)


Run

I actually did a fresh install using latest released choosenim (for windows 64 
bit).


Re: Nim's float issue?

2020-02-25 Thread ffred60
another option when in need for accuracy and to avoid rounding problem (like in 
financial activities) is to use a Decimal library..

[http://net-informations.com/q/faq/float.html](http://net-informations.com/q/faq/float.html)


How does nim infer that a cpu on windows is 64-bit

2020-02-25 Thread pietroppeter
Hi, I am trying to understand why Nim compiler thinks that my windows CPU is 32 
bits.

I ran into this while trying to sue sqlite where the smallest reproducible 
error would be:


import db_sqlite

var db = open(connection="test.db", user="test", password="",
  database="test")


Run

and the error of the compiler is `could not load: sqlite3_32.dll`. I did try to 
understand if this was a path problem but the dll are correct so I suppose it 
is due to the fact that the library selected is the wrong one and it should try 
to load `sqlite3_64.dll`.

in fact if I run `echo hostCPU` the result is `i386` and I see from source that 
it is due to compiler magic.

My Windiws system instead thinks that my cpu is this one: 
`https://en.wikichip.org/wiki/intel/core_i5/i5-8350u`


Re: How does nim infer that a cpu on windows is 64-bit

2020-02-25 Thread shashlick
Can you share the output of nim -v and gcc -v?


Re: Nim talk at FOSDEM

2020-02-25 Thread enthus1ast
I'm still waiting too :) 
[https://forum.nim-lang.org/t/5866](https://forum.nim-lang.org/t/5866)


Re: Nim's float issue?

2020-02-25 Thread kaushalmodi
Wow! I didn't know of [https://float.exposed/](https://float.exposed/). Cool 
website!


Re: Nim's float issue?

2020-02-25 Thread jva
Maybe I'm wrong but I think the answer is fine, did not notice any arrogance 
IMHO.

He just points out the docs first. It is really important to get used to docs 
although no one likes them.

So called "CS degrees" are also very useful, you learn a ton of interesting 
things there.


Re: Weird Behaviour

2020-02-25 Thread sigmapie8
Okay. Thanks!


Re: Weird Behaviour

2020-02-25 Thread demotomohiro
According to Nim manual: 
[https://nim-lang.org/docs/manual.html#syntax-precedence](https://nim-lang.org/docs/manual.html#syntax-precedence)

> Whether an operator is used a prefix operator is also affected by preceding 
> whitespace (this parsing change was introduced with version 0.13.0):
> 
> echo $foo
> 
> # is parsed as
> 
> echo($foo)

See how Nim parse your code: 


import macros

dumpTree:
  var x = number.len-2
  var y = number.len - 2
  var z = number.len- 2
  var a = number.len -2


Run

Output: 


StmtList
  VarSection
IdentDefs
  Ident "x"
  Empty
  Infix
Ident "-"
DotExpr
  Ident "number"
  Ident "len"
IntLit 2
  VarSection
IdentDefs
  Ident "y"
  Empty
  Infix
Ident "-"
DotExpr
  Ident "number"
  Ident "len"
IntLit 2
  VarSection
IdentDefs
  Ident "z"
  Empty
  Infix
Ident "-"
DotExpr
  Ident "number"
  Ident "len"
IntLit 2
  VarSection
IdentDefs
  Ident "a"
  Empty
  Command
DotExpr
  Ident "number"
  Ident "len"
Prefix
  Ident "-"
  IntLit 2


Run


Re: Nim's float issue?

2020-02-25 Thread demotomohiro
You can learn how float works in following web sites:

[https://float.exposed](https://float.exposed)/

[https://en.wikipedia.org/wiki/IEEE_754](https://en.wikipedia.org/wiki/IEEE_754)


Re: Nim's float issue?

2020-02-25 Thread Divy
The answer is really good but please respect that everyone here is learning and 
some might not be from a CS background! I'm 15 and certainly not yet graduated 
yet I code and love Nim. I guess it would be really nice if we leave arrogance 
and so called "CS degrees" aside and talk Nim :)


Re: Interlanguage communication

2020-02-25 Thread Divy
It basically executes the command node script.js It isn't complete yet. I just 
wanted to know the basic idea behind communication between languages


Re: Interlanguage communication

2020-02-25 Thread r3c
Like in any other language node script.js -param1 -param2 etc.

But if you want to pass data from client to server, you do that with Ajax or 
RESTful service.


Re: Nim's float issue?

2020-02-25 Thread juancarlospaco
`round` is Deprecated. 


Re: Nim's float issue?

2020-02-25 Thread r3c
I think @adnan is right, in the round function output like 88.91 is 
expected, but fmt should trim it to 2 decimals.


Re: Nim's float issue?

2020-02-25 Thread kaushalmodi
Your answer was nice but I think you it was equally helpful without:

> It's a bit hard to believe that this is a serious question because of..

and

> But maybe you missed that and have no CS experience.

I think most people would have stumbled across this in one programming language 
or another. 


Re: Nim's float issue?

2020-02-25 Thread adnan
[https://0.30004.com](https://0.30004.com)/


Re: Nim's float issue?

2020-02-25 Thread Stefan_Salewski
It`s a bit hard to believe that this is a serious question because of

[https://nim-lang.org/docs/math.html#round%2CT%2Cint](https://nim-lang.org/docs/math.html#round%2CT%2Cint)

But maybe you missed that and have no CS experience.

The basic fact is that we can not present each decimal number exact in a 64 bit 
floating point intern computer representation. That is not a Nim issue, but 
occurs from representation of floats in the CPU. I can not remember details how 
exactly the float format was defined by computer manufactures, but it should be 
known that float math is never exact, so for example it can occur that a + (b + 
c) != (a + b) + c. For your output, I would assume the the "strange" values 
like 66.04 can not be presented exactly, so there is only an approximaton 
available internally. So the round() function should be not used if printout is 
the desire, but instead other functions which have the goal to make a nice 
human readable output. Maybe use strformat module as recommended in the round() 
function description. And note, the round() function is still very useful, I 
think it should not be called deprecated. Assume you have a CAD program, and 
user uses a mm coordinate space with a grid of 0.01 mm. When we draw something 
then we may want that the mouse should jump to nearest grid position. For that 
we would want to use the round() proc. 


Re: A 'made with Nim' website?!

2020-02-25 Thread hyl
@JohnAD do you go looking for games to add or wait for people to add their 
games to your site? It's a nice site but there are only three games on it, and 
just a little bit of searching for games and game engine examples on github can 
get you some nice ones (eg: nico  has small trek 
as an example, game: 
[https://impbox.itch.io/smalltrek](https://impbox.itch.io/smalltrek), code: 
[https://github.com/ftsf/ld38-smalltrek](https://github.com/ftsf/ld38-smalltrek)
 ).


Re: Code cleanup suggestions: ctors

2020-02-25 Thread sky_khan
> So I realized ptr of Husband can be a key to a Table, ref can't.

Yes, it can

[https://nim-lang.org/docs/tables.html#basic-usage-hashing](https://nim-lang.org/docs/tables.html#basic-usage-hashing)


Re: Code cleanup suggestions: ctors

2020-02-25 Thread andrea
I think it would be better to give your objects ids and use those as keys to 
the table. Pointers, by design, can be moved


Nim talk at FOSDEM

2020-02-25 Thread Clonk
Hello,

Is there any audio / script for this talk : 
[https://fosdem.org/2020/schedule/event/nimultralowoverheadruntime](https://fosdem.org/2020/schedule/event/nimultralowoverheadruntime)/
 ?

I was able to listen the other 3 but I didn't find anything beside the slides 
on this one.


Re: Code cleanup suggestions: ctors

2020-02-25 Thread adnan
> Why are you using ptrs instead of refs?

So I realized ptr of Husband can be a key to a Table, ref can't.

[https://play.nim-lang.org/#ix=2cCN](https://play.nim-lang.org/#ix=2cCN)


Re: What prevents you from using Nim as your main programming language?

2020-02-25 Thread kidandcat
Man, I work with large Go codebases, Go is the equal or more strict than Rust, 
and anyway you may find unmaintainable code in extremes that your head explode.

>From my extense experience, bad developers can use the most strict language 
>ever created and the codebase will still be an enormus shit.

And good developers can code in the most random languages (aka PHP) and you can 
find million lines codebases with the most beautiful, simple and understable 
code you have ever seen.

So it's a matter of people, not languages


Nim's float issue?

2020-02-25 Thread Nam
I'm following "Nim basics" tutorial and stumbled to this case when I was trying 
to convert in to cm:


import math,strformat

echo " in | cm"
echo "-"
for i in 1 .. 40:
  echo fmt"{i:3}", " | ",  round(float(i) * 2.54, 1)


Run

Results:


 in | cm
-
  1 | 2.5
  2 | 5.1
  3 | 7.6
  4 | 10.2
  5 | 12.7
  6 | 15.2
  7 | 17.8
  8 | 20.3
  9 | 22.9
 10 | 25.4
 11 | 27.9
 12 | 30.5
 13 | 33.0
 14 | 35.6
 15 | 38.1
 16 | 40.6
 17 | 43.2
 18 | 45.7
 19 | 48.3
 20 | 50.8
 21 | 53.3
 22 | 55.9
 23 | 58.4
 24 | 61.0
 25 | 63.5
 26 | 66.0
 27 | 68.59
 28 | 71.09
 29 | 73.7
 30 | 76.2
 31 | 78.7
 32 | 81.3
 33 | 83.8
 34 | 86.41
 35 | 88.91
 36 | 91.41
 37 | 94.0
 38 | 96.5
 39 | 99.09
 40 | 101.6


Run

What makes these odd floats?


Re: Weird Behaviour

2020-02-25 Thread cumulonimbus
> var a = number.len -2 #throws invalid Indentation error

That's because it is equivalent to `number.len(-2)` and/or `len(number, -2)` ; 
 followed by something that looks like a negative number is a 
negative number (and not a "subtract" operation).


Re: Weird Behaviour

2020-02-25 Thread Divy
Make sure you are not having any extra whitespace at the end of lines. If not, 
then check for indentations and replace them with spaces.

If done correctly, your program should work fine.


Interlanguage communication

2020-02-25 Thread Divy
I have a Node.js program and a nim program. When a nim procedure is called, it 
triggers the js script with input as argument. How do I get back the output to 
nim?


Re: Using async Nim procedures in Python

2020-02-25 Thread yglukhov
Second to what dom96 said. Making nimpy async compatible is something I thought 
about and definitely it should be possible and not that hard. Doesn't mean I'm 
doing it right now, but prs are welcome, and feel free to ask details should 
you need any.


Weird Behaviour

2020-02-25 Thread sigmapie8
`proc check_number(number: string): bool = var x = number.len-2 #works var y = 
number.len - 2 #works var z = number.len- 2 #works var a = number.len -2 
#throws invalid Indentation error echo x, y, z, a return true echo 
check_number("1234") `

Run


Re: What prevents you from using Nim as your main programming language?

2020-02-25 Thread SolitudeSF
oh, its another blogpost from person who just read the tutorial and never wrote 
more than 100 lines of nim, and never seen another nim codebase, who just needs 
an excuse to use rust/go/whatever. its like you dont use vscode or vim with ide 
features already for knowing "where the stuff comes from".


Re: Weird Behaviour

2020-02-25 Thread enthus1ast
Please format your question properly.