00:00:55 | FromDiscord_ | <exelotl> I used nim at work today! |
00:00:56 | FromGitter | <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:26 | FromGitter | <rayman22201> @exelotl! woohoo 🎊 |
00:02:02 | FromDiscord_ | <exelotl> nothing really important but I wrote like a 6 line script to change a bunch of JSON files in one go |
00:02:21 | FromGitter | <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:40 | FromGitter | <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:25 | Araq | citycide, what's wrong with os.nim? ;-) |
07:27:15 | FromGitter | <citycide> Araq: heh it doesn't support full glob syntax on all platforms in pure nim |
07:36:15 | Araq | you can iterate over the dir and apply a regex for more complex cases but fair enough |
07:38:54 | Araq | about your question, os.nim uses a filter based on a set, you could do the same because |
07:39:00 | Araq | - wait for it! - |
07:39:17 | Araq | consistency. (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:40 | FromGitter | <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:35 | FromGitter | <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:24 | FromGitter | <citycide> looking for files seems most common |
08:22:28 | FromGitter | <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:43 | FromGitter | <citycide> any means* |
08:24:54 | * | stefanos82 joined #nim |
08:46:43 | * | omniphage joined #nim |
08:58:00 | * | anamok joined #nim |
08:58:08 | anamok | hallo Leute |
08:58:45 | anamok | What is the difference between `fmt"..."` and `&"..."` ? |
08:59:10 | anamok | Are they equivalent? |
08:59:13 | FromGitter | <gogolxdong> Have no idea why nimble keeps error : `... Could not download: invalid integer: "", username "", password "", hostname "", port "", path "", query "", anchor "", opaque false)` |
09:04:55 | leorize | anamok: the strformat module already explains them |
09:05:12 | leorize | http://nim-lang.github.io/Nim/strformat.html |
09:07:14 | anamok | @leorize, OK, thanks. |
09:08:43 | * | Trustable joined #nim |
09:08:54 | narimiran | anamok: very similar but not equivalent |
09:09:08 | narimiran | for example they handle `\n` differently |
09:09:24 | * | vlad1777d joined #nim |
09:09:35 | anamok | I 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:27 | anamok | I have some ideas how to extend the stdlib with some useful functions. Should I open issues for them? |
10:50:01 | narimiran | anamok: write them first here, to get some initial feedback |
10:51:36 | anamok | OK. 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:37 | narimiran | since you already have a solution, creating a PR is better than just opening an issue |
10:55:36 | anamok | Can I send like this or should I reformat them somehow? |
10:56:04 | FromGitter | <tim-st> isnt there already removePrefix and removeSuffix? |
10:56:31 | narimiran | @tim-st indeed there is |
10:56:36 | narimiran | https://nim-lang.org/docs/strutils.html#removeSuffix%2Cstring%2Cchar |
10:56:58 | FromGitter | <tim-st> but they are inplace, only difference |
10:57:31 | anamok | oh, I didn't know them... But they modify the string in-place. |
10:57:54 | FromGitter | <tim-st> unfortunately we dont have a clear pattern for having every stringutils proc in place and not in place :\ |
10:59:27 | FromGitter | <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:28 | anamok | It'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:49 | FromGitter | <tim-st> yes, exactly. I told that before, but all others said, it's good... |
11:00:10 | FromGitter | <tim-st> it's literally `strip` for chars |
11:01:12 | anamok | I'll keep lchop and rchop in my own library then. |
11:02:53 | anamok | Do you know a pastebin alternative with Nim syntax coloring? |
11:03:07 | narimiran | ix.io has nim syntax coloring |
11:03:13 | FromGitter | <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:00 | anamok | Two other functions that could be useful: lstrip and rstrip (they work like in Python): http://ix.io/1sck (they are not colored :( ) |
11:07:32 | FromGitter | <tim-st> anamok: The same I said before too, I was the only one who liked this... |
11:07:54 | FromGitter | <tim-st> especially because there is lsplit and rsplit and split |
11:08:45 | anamok | tim-st: if so many things are taken from Python, these should also be part of the stdlib. We are two then. |
11:08:49 | narimiran | anamok: create a PR that adds these stuff to `strutils.nim`, but as @tim-st said: don't get your hopes too high |
11:09:14 | FromGitter | <tim-st> anamok: even this (the python argumentation) I said too :D |
11:09:40 | anamok | And what did they say? Why did they turn it down? |
11:09:56 | FromGitter | <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:36 | FromGitter | <tim-st> anamok: not much, I *think* the bad thing is longer compiler times and maybe bigger binary size |
11:10:43 | anamok | I was surprised when I saw how similar string handling is. So yeah, take everything from Python :) |
11:11:06 | FromGitter | <tim-st> and very important is also every proc in place and not in place |
11:11:14 | FromGitter | <tim-st> (from strutils only) |
11:12:36 | anamok | narimiran, I didn't get syntax highlight: http://ix.io/1sck . I posted with cat file.nim | curl -F 'f:1=<-' ix.io |
11:13:05 | FromGitter | <Vindaar> @anamok just add a `/nim` http://ix.io/1sck/nim |
11:13:19 | anamok | ohhh |
11:13:39 | anamok | cool |
11:15:19 | narimiran | or just `/` might be enough too! |
11:15:42 | narimiran | (sometimes) |
11:17:33 | narimiran | anamok: depending on your OS, there is `ix` package that you can install, which simplifies uploads |
11:17:46 | narimiran | you can then just do `ix myFile.nim` |
11:22:38 | anamok | Thanks, 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:09 | anamok | What 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:28 | leorize | exactly |
13:11:28 | anamok | Thanks. 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:52 | leorize | what are you using to get the webpage? |
13:21:50 | anamok | I want to do it from Nim. |
13:23:25 | anamok | With 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:45 | FromGitter | <stephenwithav> @anamok Look in httpcore: https://nim-lang.org/docs/httpcore.html |
13:28:16 | anamok | Found it: echo int(code(r)) , where r is a Response object. |
13:28:44 | anamok | I put together a small working example. |
13:29:21 | leorize | I don't think you should convert it to int |
13:29:34 | leorize | there should be a constant like Http401 that you can compare with |
13:33:01 | anamok | That could be a better way. Here is a working example: http://ix.io/1scT/nim |
13:47:37 | FromGitter | <alehander42> but you don't want to use an int: this is not typesafe |
13:47:52 | FromGitter | <alehander42> HttpCode is defined as https://nim-lang.org/docs/httpcore.html#HttpCode |
13:54:43 | anamok | In the source code they also use int conversion: https://github.com/nim-lang/Nim/blob/master/lib/pure/httpcore.nim#L227 |
13:57:05 | FromGitter | <alehander42> yeah, well they shouldn't |
13:57:10 | FromGitter | <alehander42> in this case |
13:57:30 | FromGitter | <alehander42> you write 432 by mistake |
13:57:33 | FromGitter | <alehander42> and nothing catches it |
13:58:12 | FromGitter | <alehander42> you can use it of course if you literally need the int value |
13:58:22 | FromGitter | <alehander42> but if you just want to check if it equals something |
13:58:28 | FromGitter | <alehander42> it's better to stay with the distinct type |
14:31:26 | * | stefanos82 quit (Quit: Quitting for now...) |
14:34:39 | anamok | alehander42: thanks for the explanation |
14:35:52 | FromGitter | <tim-st> should this be supported `proc min*T (args: varargs[T]): int` ? |
14:36:28 | FromGitter | <tim-st> (in system.nim) |
14:38:55 | * | Zevv joined #nim |
14:40:03 | * | kapil____ joined #nim |
14:40:10 | leorize | Araq 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:39 | anamok | bye |
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:20 | shashlick | Meh, 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:35 | FromDiscord_ | <JGiraffe> Hi this language is awesome |
18:33:16 | narimiran | true :) |
18:44:04 | FromGitter | <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:41 | FromDiscord_ | <PusiteGA> ~~~ |
21:50:25 | FromDiscord_ | <PusiteGA> ``` |
21:50:26 | FromDiscord_ | <PusiteGA> var v1="abcd" |
21:50:26 | FromDiscord_ | <PusiteGA> for i in 0..5 |
21:50:26 | FromDiscord_ | <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:26 | FromDiscord_ | <PusiteGA> #bla bla some work |
21:50:26 | FromDiscord_ | <PusiteGA> ``` |
21:50:44 | FromDiscord_ | <PusiteGA> on 4 will be out of bounds 😃 |
21:52:07 | FromDiscord_ | <PusiteGA> @JGiraffe this lang is awesome https://esolangs.org/wiki/chicken |
21:52:46 | narimiran | why don't you do it `for i in 0..<v1.len`? |
21:55:44 | FromDiscord_ | <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:29 | FromDiscord_ | <PusiteGA> ``` |
21:58:29 | FromDiscord_ | <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:29 | FromDiscord_ | <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:29 | FromDiscord_ | <PusiteGA> count.inc |
21:58:29 | FromDiscord_ | <PusiteGA> else: |
21:58:31 | FromDiscord_ | <PusiteGA> result= result & count.intToStr & atmchar |
21:58:33 | * | Jesin quit (Ping timeout: 276 seconds) |
21:58:33 | FromDiscord_ | <PusiteGA> count=1; |
21:58:34 | FromDiscord_ | <PusiteGA> atmchar=wrd[i] |
21:58:36 | FromDiscord_ | <PusiteGA> ``` |
22:01:01 | FromDiscord_ | <PusiteGA> hmm but again i am intrudicing 2 ifs and i thinked i could avoid that |
22:03:54 | FromDiscord_ | <PusiteGA> guess its better to rewrite then fix wrong way of doing it 😃 |
22:06:20 | FromGitter | <zetashift> @PusiteGA try to pastebin your code when you paste it, irc/gitter don't show it as nicely as discord |
22:07:13 | FromDiscord_ | <PusiteGA> ok will in future, but for this atm i solved it in my head |
22:12:29 | * | natrys quit (Quit: natrys) |
22:16:46 | narimiran | if 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:03 | FromDiscord_ | <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:11 | FromDiscord_ | <PusiteGA> ye i know about semicolons just am usied to c# so i still write them somtimes acidencly |
22:54:49 | FromDiscord_ | <PusiteGA> narimiran yep i know that but issue is not that simple |
22:54:55 | FromDiscord_ | <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:22 | FromDiscord_ | <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:53 | FromDiscord_ | <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:23 | FromDiscord_ | <exelotl> @JGiraffe something like this? https://gist.github.com/geckojsc/673d8258e697ddb2cd56af5bab9180bb |
23:25:12 | sendell[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:34 | sendell[m] | seems a bit contradictory |
23:27:19 | FromDiscord_ | <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:54 | FromDiscord_ | <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:33 | FromDiscord_ | <exelotl> e.g. var items: arr[5..10, float] is an array with valid indexes between 5 and 10 inclusive |
23:31:43 | FromDiscord_ | <exelotl> but the indexes actually aren't limited to integer values, you can use any 'ordinal type' which includes enums |
23:34:44 | FromDiscord_ | <JGiraffe> Haven't learned what an enum is yet 😬 |
23:40:15 | FromDiscord_ | <PusiteGA> @JGiraffe if you know c# heres simple explanation https://www.dotnetperls.com/enum |
23:42:43 | FromDiscord_ | <exelotl> @JGiraffe here's an example of what you might do without enums: https://gist.github.com/geckojsc/3837f20601c208c9125912144ecc1e4f |
23:45:40 | FromDiscord_ | <JGiraffe> In that example wouldn't the rows/columns need to be labeled with the type numbers? |
23:47:20 | FromDiscord_ | <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:52 | FromDiscord_ | <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:08 | FromDiscord_ | <exelotl> it turns out you can label the items for clarity, if you wish: https://gist.github.com/geckojsc/dd79bdad5b2366ba7a94d27b9e861a34 |
23:50:12 | FromDiscord_ | <PusiteGA> is there in Nim some think like tryPhrase for int to char |
23:50:18 | FromDiscord_ | <PusiteGA> *from char to int |
23:51:03 | FromDiscord_ | <PusiteGA> i want to do like if( charCanBeInt ) do soemthing |
23:51:57 | FromDiscord_ | <JGiraffe> If it doesn't need me to label them I definitely won't |
23:59:50 | FromDiscord_ | <PusiteGA> anyone how can i check if char is a number or not? |