<< 17-11-2018 >>

00:00:55FromDiscord_<exelotl> I used nim at work today!
00:00:56FromGitter<rayman22201> Yes. In theory gc:none is supposed to not allow any implicit allocations. (obviously if you explicitly call alloc and friends it will let you)
00:01:26FromGitter<rayman22201> @exelotl! woohoo 🎊
00:02:02FromDiscord_<exelotl> nothing really important but I wrote like a 6 line script to change a bunch of JSON files in one go
00:02:21FromGitter<rayman22201> That's how it starts :-P
00:16:14*theelous3 joined #nim
00:43:19*Jesin joined #nim
00:50:15*craigger quit (Quit: bye)
00:50:27*Jesin quit (Quit: Leaving)
00:52:42*craigger joined #nim
01:08:23*deech quit (Ping timeout: 245 seconds)
01:08:50*zachk quit (Read error: Connection reset by peer)
01:09:29*zachk joined #nim
01:15:44*theelous3 quit (Ping timeout: 272 seconds)
01:19:27*zachk quit (Quit: Leaving)
01:32:42*Snircle quit (Quit: Textual IRC Client: www.textualapp.com)
02:14:56*ftsf joined #nim
02:38:09*seni quit (Quit: Leaving)
02:56:38*Jesin joined #nim
03:02:28*vlad1777d quit (Ping timeout: 244 seconds)
03:05:36*banc quit (Quit: ZNC - http://znc.in)
03:21:42*banc joined #nim
03:26:05*kapil____ joined #nim
03:41:12*dddddd quit (Remote host closed the connection)
03:55:22*Snircle joined #nim
04:12:38*Snircle quit (Quit: Textual IRC Client: www.textualapp.com)
04:31:40FromGitter<citycide> hey everyone - looking for opinions for the `glob` library on whether directories should be included by default in the results vs. requiring an `includeDirs` flag. see https://github.com/citycide/glob/issues/18
04:36:30*ftsf quit (Ping timeout: 272 seconds)
06:25:12*kapil____ quit (Quit: Connection closed for inactivity)
06:34:18*kapil____ joined #nim
06:59:27*mech422_ joined #nim
07:02:54*mech422__ quit (Ping timeout: 252 seconds)
07:14:25Araqcitycide, what's wrong with os.nim? ;-)
07:27:15FromGitter<citycide> Araq: heh it doesn't support full glob syntax on all platforms in pure nim
07:36:15Araqyou can iterate over the dir and apply a regex for more complex cases but fair enough
07:38:54Araqabout your question, os.nim uses a filter based on a set, you could do the same because
07:39:00Araq- wait for it! -
07:39:17Araqconsistency. (with the stdlib)
07:51:35*wildlander quit (Quit: Konversation terminated!)
07:58:35*narimiran joined #nim
07:59:56*norbux joined #nim
08:00:08*norbux left #nim ("Leaving")
08:08:40FromGitter<citycide> Araq: I did basically that originally, but it was too clumsy with all the other possible flags. there are also filter procs
08:19:55*tribly quit (Quit: WeeChat 2.2)
08:20:35FromGitter<citycide> that's a decent argument for keeping glob's current behavior though. `os.walkDirRec` defaults to yielding only files, not directories
08:20:45*tribly joined #nim
08:21:24FromGitter<citycide> looking for files seems most common
08:22:28FromGitter<citycide> > you can iterate over the dir and apply a regex ⏎ to this point, the kind of regexes you'd have to use for cross-platform path matching are not pleasant to read or write by an means
08:22:43FromGitter<citycide> any means*
08:24:54*stefanos82 joined #nim
08:46:43*omniphage joined #nim
08:58:00*anamok joined #nim
08:58:08anamokhallo Leute
08:58:45anamokWhat is the difference between `fmt"..."` and `&"..."` ?
08:59:10anamokAre they equivalent?
08:59:13FromGitter<gogolxdong> Have no idea why nimble keeps error : `... Could not download: invalid integer: "", username "", password "", hostname "", port "", path "", query "", anchor "", opaque false)`
09:04:55leorizeanamok: the strformat module already explains them
09:05:12leorizehttp://nim-lang.github.io/Nim/strformat.html
09:07:14anamok@leorize, OK, thanks.
09:08:43*Trustable joined #nim
09:08:54narimirananamok: very similar but not equivalent
09:09:08narimiranfor example they handle `\n` differently
09:09:24*vlad1777d joined #nim
09:09:35anamokI think `&"..."` is more intuitive, it has less gotchas.
09:24:13*anamok quit (Ping timeout: 245 seconds)
10:35:19*anamok joined #nim
10:40:03*rockcavera quit (Ping timeout: 245 seconds)
10:49:27anamokI have some ideas how to extend the stdlib with some useful functions. Should I open issues for them?
10:50:01narimirananamok: write them first here, to get some initial feedback
10:51:36anamokOK. For the strings, I think lchop and rchop would be useful. I put them here: https://pastebin.com/ZwqXXpvK . They remove prefix and postfix of a string, respectively.
10:54:37narimiransince you already have a solution, creating a PR is better than just opening an issue
10:55:36anamokCan I send like this or should I reformat them somehow?
10:56:04FromGitter<tim-st> isnt there already removePrefix and removeSuffix?
10:56:31narimiran@tim-st indeed there is
10:56:36narimiranhttps://nim-lang.org/docs/strutils.html#removeSuffix%2Cstring%2Cchar
10:56:58FromGitter<tim-st> but they are inplace, only difference
10:57:31anamokoh, I didn't know them... But they modify the string in-place.
10:57:54FromGitter<tim-st> unfortunately we dont have a clear pattern for having every stringutils proc in place and not in place :\
10:59:27FromGitter<tim-st> it could get overloaded, but we discussed that before for `strip` and it seems I was the only one who wanted this
10:59:28anamokIt's weird. If the suffix is a char, it removes all occurrences. If it's a string, it removes just the first occurrence.
10:59:49FromGitter<tim-st> yes, exactly. I told that before, but all others said, it's good...
11:00:10FromGitter<tim-st> it's literally `strip` for chars
11:01:12anamokI'll keep lchop and rchop in my own library then.
11:02:53anamokDo you know a pastebin alternative with Nim syntax coloring?
11:03:07narimiranix.io has nim syntax coloring
11:03:13FromGitter<tim-st> in `algorithm` we have `sort` and `sorted` but it wasnt applied for strutils, also just overloading `var string -> void` with `string -> string` would work
11:07:00anamokTwo other functions that could be useful: lstrip and rstrip (they work like in Python): http://ix.io/1sck (they are not colored :( )
11:07:32FromGitter<tim-st> anamok: The same I said before too, I was the only one who liked this...
11:07:54FromGitter<tim-st> especially because there is lsplit and rsplit and split
11:08:45anamoktim-st: if so many things are taken from Python, these should also be part of the stdlib. We are two then.
11:08:49narimirananamok: create a PR that adds these stuff to `strutils.nim`, but as @tim-st said: don't get your hopes too high
11:09:14FromGitter<tim-st> anamok: even this (the python argumentation) I said too :D
11:09:40anamokAnd what did they say? Why did they turn it down?
11:09:56FromGitter<tim-st> btw: latest surveys show that python is the most liked language, thus it wouldnt be a very bad idea to have strutils very similar
11:10:36FromGitter<tim-st> anamok: not much, I *think* the bad thing is longer compiler times and maybe bigger binary size
11:10:43anamokI was surprised when I saw how similar string handling is. So yeah, take everything from Python :)
11:11:06FromGitter<tim-st> and very important is also every proc in place and not in place
11:11:14FromGitter<tim-st> (from strutils only)
11:12:36anamoknarimiran, I didn't get syntax highlight: http://ix.io/1sck . I posted with cat file.nim | curl -F 'f:1=<-' ix.io
11:13:05FromGitter<Vindaar> @anamok just add a `/nim` http://ix.io/1sck/nim
11:13:19anamokohhh
11:13:39anamokcool
11:15:19narimiranor just `/` might be enough too!
11:15:42narimiran(sometimes)
11:17:33narimirananamok: depending on your OS, there is `ix` package that you can install, which simplifies uploads
11:17:46narimiranyou can then just do `ix myFile.nim`
11:22:38anamokThanks, got it.
11:43:16*gmpreussner quit (Quit: kthxbye)
11:43:27*narimiran quit (Ping timeout: 240 seconds)
11:51:02*gmpreussner joined #nim
12:52:08*leorize quit (Quit: WeeChat 2.3)
12:52:23*leorize joined #nim
13:02:09anamokWhat happens if I use const inside a proc or func? Is that evaluated only once, upon compilation? If I use let, is that evaluated every time I call the proc / func?
13:04:28leorizeexactly
13:11:28anamokThanks. Another question: I want to test if a webpage exists or not, i.e. I want to catch the return codes (200, 404, etc.). How to do that?
13:17:52leorizewhat are you using to get the webpage?
13:21:50anamokI want to do it from Nim.
13:23:25anamokWith httpclient I could get a Response object. But r.status returns a string, e.g. "401 UNAUTHORIZED". Parsing it seems strange. There should be a way to get the return code.
13:25:11*kapil____ quit (Quit: Connection closed for inactivity)
13:26:45FromGitter<stephenwithav> @anamok Look in httpcore: https://nim-lang.org/docs/httpcore.html
13:28:16anamokFound it: echo int(code(r)) , where r is a Response object.
13:28:44anamokI put together a small working example.
13:29:21leorizeI don't think you should convert it to int
13:29:34leorizethere should be a constant like Http401 that you can compare with
13:33:01anamokThat could be a better way. Here is a working example: http://ix.io/1scT/nim
13:47:37FromGitter<alehander42> but you don't want to use an int: this is not typesafe
13:47:52FromGitter<alehander42> HttpCode is defined as https://nim-lang.org/docs/httpcore.html#HttpCode
13:54:43anamokIn the source code they also use int conversion: https://github.com/nim-lang/Nim/blob/master/lib/pure/httpcore.nim#L227
13:57:05FromGitter<alehander42> yeah, well they shouldn't
13:57:10FromGitter<alehander42> in this case
13:57:30FromGitter<alehander42> you write 432 by mistake
13:57:33FromGitter<alehander42> and nothing catches it
13:58:12FromGitter<alehander42> you can use it of course if you literally need the int value
13:58:22FromGitter<alehander42> but if you just want to check if it equals something
13:58:28FromGitter<alehander42> it's better to stay with the distinct type
14:31:26*stefanos82 quit (Quit: Quitting for now...)
14:34:39anamokalehander42: thanks for the explanation
14:35:52FromGitter<tim-st> should this be supported `proc min*T (args: varargs[T]): int` ?
14:36:28FromGitter<tim-st> (in system.nim)
14:38:55*Zevv joined #nim
14:40:03*kapil____ joined #nim
14:40:10leorizeAraq certainly wouldn't like adding things to system.nim
14:48:32*xace quit (Remote host closed the connection)
14:50:45*xace joined #nim
14:54:39anamokbye
14:54:42*anamok quit (Remote host closed the connection)
14:55:51*wildlander joined #nim
14:56:59*Snircle joined #nim
15:01:10*nsf joined #nim
15:21:49*narimiran joined #nim
15:25:50*stefanos82 joined #nim
16:06:26*shashlick joined #nim
16:08:20shashlickMeh, rebooted my server and forgot to restart my slack bridge
16:13:40*leorize quit (Quit: WeeChat 2.3)
16:14:41*NimBot joined #nim
17:25:18*Snircle quit (Quit: Textual IRC Client: www.textualapp.com)
17:27:37*dada78641 quit (Quit: bye)
17:28:10*dada78641 joined #nim
17:28:35*dada78641 quit (Client Quit)
17:36:29*craigger quit (Quit: bye)
17:39:10*craigger joined #nim
17:40:13*Zevv left #nim (#nim)
17:40:17*dddddd joined #nim
18:24:55*Snircle joined #nim
18:26:37*nsf quit (Quit: WeeChat 2.3)
18:27:02*craigger quit (Quit: bye)
18:28:03*craigger joined #nim
18:32:35FromDiscord_<JGiraffe> Hi this language is awesome
18:33:16narimirantrue :)
18:44:04FromGitter<Epictek> no this language is Nim :)
18:51:50*natrys joined #nim
19:59:10*zachk joined #nim
19:59:47*zachk quit (Changing host)
19:59:48*zachk joined #nim
20:07:15*zachk quit (Remote host closed the connection)
20:08:01*zachk joined #nim
20:08:45*zachk quit (Remote host closed the connection)
20:22:10*theelous3 joined #nim
20:22:30*lukd quit (Quit: WeeChat 2.3)
20:26:17*lukd joined #nim
20:43:47*stefanos82 quit (Quit: Quitting for now...)
20:47:59*brainproxy quit (Quit: WeeChat 2.3)
20:50:14*zachk joined #nim
20:56:03*nsf joined #nim
21:09:38*Trustable quit (Remote host closed the connection)
21:16:46*V-X joined #nim
21:42:59*zachk quit (Changing host)
21:42:59*zachk joined #nim
21:47:41FromDiscord_<PusiteGA> ~~~
21:50:25FromDiscord_<PusiteGA> ```
21:50:26FromDiscord_<PusiteGA> var v1="abcd"
21:50:26FromDiscord_<PusiteGA> for i in 0..5
21:50:26FromDiscord_<PusiteGA> if v1[i]: # on 5 int it will be out of bounds, can i somhow check if its out of bouds like do if v1[i] !=OutOfBounds ?
21:50:26FromDiscord_<PusiteGA> #bla bla some work
21:50:26FromDiscord_<PusiteGA> ```
21:50:44FromDiscord_<PusiteGA> on 4 will be out of bounds 😃
21:52:07FromDiscord_<PusiteGA> @JGiraffe this lang is awesome https://esolangs.org/wiki/chicken
21:52:46narimiranwhy don't you do it `for i in 0..<v1.len`?
21:55:44FromDiscord_<PusiteGA> i am doing exercise on exercise.io or whatwer is called the site, so now i have to check if char[i] is equal to next char and when i reach last char it ofc crashes with out of bounds
21:58:29FromDiscord_<PusiteGA> ```
21:58:29FromDiscord_<PusiteGA> for i in 1..<wrd.len: # so in my dumb code i need to go out of bounds by 1 to check last time, or rewrite logic xD
21:58:29FromDiscord_<PusiteGA> if wrd[i]==atmchar: #so if i go out here it crashes , i can solve all this bu just writing 1 more if that first checks if , hmm i think i solved it , YEY
21:58:29FromDiscord_<PusiteGA> count.inc
21:58:29FromDiscord_<PusiteGA> else:
21:58:31FromDiscord_<PusiteGA> result= result & count.intToStr & atmchar
21:58:33*Jesin quit (Ping timeout: 276 seconds)
21:58:33FromDiscord_<PusiteGA> count=1;
21:58:34FromDiscord_<PusiteGA> atmchar=wrd[i]
21:58:36FromDiscord_<PusiteGA> ```
22:01:01FromDiscord_<PusiteGA> hmm but again i am intrudicing 2 ifs and i thinked i could avoid that
22:03:54FromDiscord_<PusiteGA> guess its better to rewrite then fix wrong way of doing it 😃
22:06:20FromGitter<zetashift> @PusiteGA try to pastebin your code when you paste it, irc/gitter don't show it as nicely as discord
22:07:13FromDiscord_<PusiteGA> ok will in future, but for this atm i solved it in my head
22:12:29*natrys quit (Quit: natrys)
22:16:46narimiranif you're comparing two consecutive characters, you just do `for i in 0 ..< v1.len-1: if v1[i] == v1[i+1]` or `for i in 1 ..< v1.len: if v1[i-1] == v1[i]`, and you will not be out of bounds
22:27:44*jjido joined #nim
22:32:14*wildlander quit (Quit: Konversation terminated!)
22:33:03FromDiscord_<Calinou> note that Nim doesn't require semicolons at the end of lines too
22:36:46*wildlander joined #nim
22:38:54*narimiran quit (Remote host closed the connection)
22:45:11*kapil____ quit (Quit: Connection closed for inactivity)
22:52:50*Zevv joined #nim
22:54:11FromDiscord_<PusiteGA> ye i know about semicolons just am usied to c# so i still write them somtimes acidencly
22:54:49FromDiscord_<PusiteGA> narimiran yep i know that but issue is not that simple
22:54:55FromDiscord_<PusiteGA> but i think i solve it
22:55:36*Snircle quit (Quit: Textual IRC Client: www.textualapp.com)
23:01:17*Snircle joined #nim
23:04:22FromDiscord_<JGiraffe> I'm trying to build my first app which is basically my own version of this https://pkmn.help with different types. I'm not sure how to best assign all the matchups to each type. For example fire does 2*damage to grass, .5*damage to water, 4* damage to a grass/ice type, and .25*damage to a water/air type.
23:04:53FromDiscord_<JGiraffe> I'm trying to build my first app which is basically my own version of this https://pkmn.help with different types. I'm not sure how to best assign all the matchups to each type. For example fire does 2 x damage to grass, .5 x damage to water, 4 x damage to a grass/ice type, and .25 x damage to a water/air type.
23:15:09*Snircle quit (Quit: Textual IRC Client: www.textualapp.com)
23:20:21*jjido quit (Remote host closed the connection)
23:21:23FromDiscord_<exelotl> @JGiraffe something like this? https://gist.github.com/geckojsc/673d8258e697ddb2cd56af5bab9180bb
23:25:12sendell[m]why is the ".this" pragma deprecated if it's supposed to "become the default directive for the whole language", as stated in manual?
23:25:34sendell[m]seems a bit contradictory
23:27:19FromDiscord_<JGiraffe> Sorry if this is a dumb question I just started learning to program with Nim. So it seems like I could just use this table format for all 18 types so it would just be 18 columns wide and 18 rows long and as long as I preserve the x axis the function(?) will be able to refer to any of them?
23:29:54FromDiscord_<exelotl> Yeah so in most languages, arrays start counting from 0. That's the default in Nim, but you can actually choose to start counting from 1 or anything else
23:30:33FromDiscord_<exelotl> e.g. var items: arr[5..10, float] is an array with valid indexes between 5 and 10 inclusive
23:31:43FromDiscord_<exelotl> but the indexes actually aren't limited to integer values, you can use any 'ordinal type' which includes enums
23:34:44FromDiscord_<JGiraffe> Haven't learned what an enum is yet 😬
23:40:15FromDiscord_<PusiteGA> @JGiraffe if you know c# heres simple explanation https://www.dotnetperls.com/enum
23:42:43FromDiscord_<exelotl> @JGiraffe here's an example of what you might do without enums: https://gist.github.com/geckojsc/3837f20601c208c9125912144ecc1e4f
23:45:40FromDiscord_<JGiraffe> In that example wouldn't the rows/columns need to be labeled with the type numbers?
23:47:20FromDiscord_<exelotl> no, because it knows to start with Fire and end with Electric (they have an order, that's what is meant by ordinal)
23:47:52FromDiscord_<exelotl> btw using an enum in this case is preferred because a) it's more type safe (you can't accidentally make a bulbasaur with poketype 1000 which is not a valid poketype) b) you don't have to manually pick the values Fire=0, Water=1, etc.
23:50:08FromDiscord_<exelotl> it turns out you can label the items for clarity, if you wish: https://gist.github.com/geckojsc/dd79bdad5b2366ba7a94d27b9e861a34
23:50:12FromDiscord_<PusiteGA> is there in Nim some think like tryPhrase for int to char
23:50:18FromDiscord_<PusiteGA> *from char to int
23:51:03FromDiscord_<PusiteGA> i want to do like if( charCanBeInt ) do soemthing
23:51:57FromDiscord_<JGiraffe> If it doesn't need me to label them I definitely won't
23:59:50FromDiscord_<PusiteGA> anyone how can i check if char is a number or not?