<< 09-12-2018 >>

00:00:38FromDiscord_<deech> Araq: Yes, I'm just not sure where to look to fix template substitutions.
00:01:16Araqsemtempl.nim checks the template, evaltempl.nim expands templates
00:03:00FromDiscord_<deech> Thanks!
00:21:19*fthe quit (Quit: bye)
00:21:21Araqbut it's likely really hard for a newcomer
00:21:35Araqyou should start with a simpler compiler bug
00:21:52Araqbut I have to sleep now, I can help you more tomorrow
00:22:19*martin1_ joined #nim
00:26:18*Pisuke quit (Ping timeout: 245 seconds)
00:31:41*bozaloshtsh_ quit (Quit: ZNC 1.7.1 - https://znc.in)
00:31:52*bozaloshtsh joined #nim
00:31:52*bozaloshtsh quit (Changing host)
00:31:52*bozaloshtsh joined #nim
01:02:36*martin1_ quit (Ping timeout: 250 seconds)
01:09:31*Pisuke joined #nim
01:10:07*martin1_ joined #nim
01:17:59*jakob0094 joined #nim
01:36:32*Jesin quit (Quit: Leaving)
01:38:50*Jesin joined #nim
01:43:13*jakob0094 quit (Remote host closed the connection)
01:44:43*Jesin quit (Remote host closed the connection)
01:50:19*Jesin joined #nim
01:51:33*theelous3_ quit (Ping timeout: 246 seconds)
01:56:02*zachk quit (Quit: Leaving)
02:05:56*ng0 quit (Quit: Alexa, when is the end of world?)
02:50:46*tefter joined #nim
02:56:25leorizemartin1_: mingw-w64 toolchain is what you need
02:56:56leorizejust try compiling with `nim c -d:mingw`
02:57:43leorizethe variables declaring what compiler to use and where is it is in the default nim.cfg
02:57:50leorizejust look for the string "mingw"
03:03:44leorizeshashlick: the backtrace from gdb does not provide any meaningful data?
03:07:43*banc quit (Quit: Bye)
03:23:28*banc joined #nim
03:45:11*Tyresc quit (Quit: WeeChat 2.3-dev)
04:07:28*shpx joined #nim
04:34:52*martin1__ joined #nim
04:36:26*martin1_ quit (Ping timeout: 244 seconds)
04:44:12*shpx quit (Quit: My MacBook has gone to sleep. ZZZzzz…)
04:46:44*shpx joined #nim
04:48:08*shpx quit (Client Quit)
04:49:11*shpx joined #nim
04:53:27*shpx quit (Ping timeout: 240 seconds)
04:56:16*PrimHelios quit (Quit: Leaving)
05:02:14*lritter quit (Ping timeout: 250 seconds)
05:03:08*lritter joined #nim
05:09:04*Snircle quit (Quit: Textual IRC Client: www.textualapp.com)
05:21:48*nsf joined #nim
05:29:59shashlickmartin1_: https://nim-lang.github.io/Nim/nimc.html#cross-compilation-for-windows - only on devel though
05:30:11shashlickleorize: nope, nothing useful at all
05:36:57*nc-x joined #nim
05:39:03nc-xshashlick: https://github.com/nim-lang/Nim/issues/9893 I am unable to `nim c -r tests/tscinfull.nim` It fails with `Implementation of Scintilla_registerclass expected` at scintilla.nim(1242, 5)
05:40:52nc-xOkay wait
05:40:56nc-xIt works fine for me
05:41:00nc-xwindows 10 1809
05:41:04nc-xusing clang
05:41:47nc-xI had to modify nimgen\src\globals.nim to use `clang` and `clang++` instead of gcc and g++
05:42:08*martin1__ quit (Ping timeout: 245 seconds)
05:42:13nc-xand I ran `nim cpp -r tests/tscinfull.nim` (notice `nim cpp` instead of `nim c`)
05:43:30nc-xmsvc linker barks up a lot of warnings. (clang on windows requires either msvc or mingw installed AFAIK).
05:44:19nc-xBut then I get a small window opened and lots of 0's and a few 1's printed on the console.
05:44:41*endragor joined #nim
05:44:50nc-xLatest nim devel BTW
05:45:51*endragor quit (Remote host closed the connection)
05:47:31*nc-x quit (Quit: Page closed)
05:49:17shashlickthanks nc-x
05:51:37shashlickthat
05:52:08*nc-x joined #nim
05:52:32nc-xBTW which gcc version are you on? Maybe try on some other gcc as well.
05:53:07*nc-x quit (Client Quit)
05:54:03shashlicki'm using mingw gcc 7.3.0
05:56:08shashlickso I migrated from the code I have to using how it is in winim and it is working now for me
05:56:50shashlicksomething about how I have the wrapper is messing up nim
05:57:02shashlickbut note that the same gcc works with nim 0.18.0, but not 0.19.0
05:58:00shashlickunfortunately, I cannot simply import winim since scintilla's HanjaDic.cxx errors on compile if -DWIN32_LEAN_AND_MEAN is defined
05:58:10shashlickbizarre stuff but what can you do
06:00:07shashlickby the way, you can use $CC and $CPP env vars to use clang instead of gcc
06:02:28*leorize quit (Ping timeout: 250 seconds)
06:06:21*anamok joined #nim
06:06:23anamokhi
06:07:49anamokHow to get a reference on an object? Like `&` in C. Ex.: `let node = Node(value: value)`, and later I want its memory address.
06:08:16anamokI'm trying to implement a linked list.
06:09:23*leorize joined #nim
06:09:26anamokI have a head pointer (of type ref Node) that I want to point on a newly created node object.
06:10:47*endragor joined #nim
06:11:28*endragor_ joined #nim
06:14:14leorizeanamok: you can't get a ref of an object, only it's ptr
06:14:30leorizeif you want a ref, you have to create one in the first place
06:15:07*endragor quit (Ping timeout: 244 seconds)
06:18:24leorizeI'd recommend you make your node a ref object by default
06:18:58anamokleorize: Here is my first attempt of a linked list: http://ix.io/1vAJ/nim . Lines 15-20 are problematic.
06:19:44leorize`Node` by itself is already a ref object...
06:19:55leorizeref ref object is certainly not what you want I believe?
06:20:55*nc-x joined #nim
06:21:09nc-xanamok: you could look at how nim stdlib implements these data structures
06:21:36nc-xhttps://github.com/nim-lang/Nim/blob/devel/lib/pure/collections/lists.nim
06:21:41shashlickany idea how to prevent setting -DWIN32_LEAN_AND_MEAN for a specific c file during Nim compilation?
06:22:32leorizecounter it with `-UWIN32_LEAN_AND_MEAN`
06:22:47nc-xshashlick: nope. I never tried interfacing with c/cpp.
06:23:00*nc-x quit (Client Quit)
06:23:06shashlicki don't get it - winim doesn't import winlean anywhere but still during compile you get the -D
06:23:14shashlickand the only place it gets set is winlean
06:23:27leorizemaybe the compiler set it by default?
06:23:57leorizeanyhow, using -UWIN32_LEAN_AND_MEAN should mitigate the effect of it's -D counterpart
06:24:05*dddddd quit (Remote host closed the connection)
06:24:38anamokleorize, I found it out, thanks for the tip: http://ix.io/1vAK/nim
06:24:39shashlickit seems to work
06:25:15anamokleorize, Is it possible to put lines 11-13 into one line?
06:25:33leorizeanamok: you should make Node a ref object and change the type of .next -> Node
06:26:25leorizeonce you're done with that, line 11-13 could be: var node = Node(value: value)
06:27:32leorizeif you want to keep it as it is now, then `var node = new Node; node.value = value`
06:30:46anamokleorize, Thanks, updated: http://ix.io/1vAN
06:31:12anamoknc-x, Thanks, but I wanted to try to do it manually.
06:33:10shashlickWIN32_LEAN_AND_MEAN is only set in winlean with passC, i don't see how winlean comes into this
06:37:36leorizeanamok: I think LinkedList could just be an object instead?
06:37:58leorizeshashlick: have you checked if the C compiler set WIN32_LEAN_AND_MEAN by default?
06:38:07leorizeor if any C headers define it?
06:49:00shashlickwell it shows up on the gcc command generated by nim which means nim put it there for some reason
06:51:57leorizecheck every processed modules?
06:55:46*lritter quit (Ping timeout: 250 seconds)
06:59:15*narimiran joined #nim
07:01:50*endragor_ quit (Remote host closed the connection)
07:10:14*Trustable joined #nim
07:15:57Araqshashlick: maybe you got .cdecl and .stdcall mixed up.
07:16:18Araqthen it works sometimes as you described
07:22:20shashlickAraq: its the same stdcall in winim as well, just as in my snippet
07:22:50Araqscintilla uses stdcall iirc but who knows how it was built
07:42:42shashlickYa is compiled in and wrapped with c2nim using stdcall
07:59:58Araqgist a stacktrace
08:27:30*nsf quit (Quit: WeeChat 2.3)
08:43:29*Trustable quit (Remote host closed the connection)
08:45:27*nc-x joined #nim
08:45:47nc-xAraq: How do I add two tests in same file? (for https://github.com/nim-lang/Nim/pull/9909)
08:46:43nc-xbcos well, the compiler quits after the first error being shown...
08:50:42nc-xAnyways I split it into 2 files for now.
08:51:52*nc-x quit (Quit: Page closed)
08:52:46Araqcmd: 'nim check $file'
08:52:55Araqnimout: '''stuff here the compile should report'''
08:59:35FromDiscord_<Virepri> is it possible to convert a seq to an iterator, or something of that sort?
09:03:24*kapil____ quit (Quit: Connection closed for inactivity)
09:05:50narimiran@Viepri `for elem in mySeq` works
09:12:27FromDiscord_<Virepri> ```proc part2*(): string =
09:12:27FromDiscord_<Virepri> let freqs = sequtils.map(regex.split(input, re"\n"), (str: string) => strutils.parseInt(str))
09:12:27FromDiscord_<Virepri> var seen: HashSet[int] = initSet[int]()
09:12:27FromDiscord_<Virepri> var freq = 0
09:12:27FromDiscord_<Virepri> while !seen.contains(freq):
09:12:28FromDiscord_<Virepri> for freqchange in freqs:
09:12:29FromDiscord_<Virepri> seen.incl(freq)
09:12:31FromDiscord_<Virepri> freq += freqchange
09:12:32FromDiscord_<Virepri> if seen.contains(freq):
09:12:34FromDiscord_<Virepri> break
09:12:35FromDiscord_<Virepri> $freq```
09:12:36leorizeplease
09:12:37FromDiscord_<Virepri> this is REALLY horrible performance
09:12:39FromDiscord_<Virepri> I have to be doing SOMETHING wrong
09:12:48leorizedon't paste directly to discord
09:12:53FromDiscord_<Virepri> oh
09:12:55FromDiscord_<Virepri> sorry
09:13:00FromDiscord_<Virepri> here, I'll upload to hastebin
09:13:15FromDiscord_<Virepri> https://hastebin.com/odadizohob.cs
09:13:37FromDiscord_<Virepri> but like, that takes multiple seconds to run.... I'm surely doing something wrong, right?
09:13:42narimiranre: performance: use `intsets` instead of `HashSet`
09:13:48FromDiscord_<Virepri> oh
09:14:05leorizealso, use mapIt
09:14:09leorizemap is slow
09:14:34narimiranleorize: mapIt is faster than map? i had no idea
09:14:58leorizeyea, map use a closure, so it's always slower than mapIt, which is merely a template expansion
09:15:04FromDiscord_<Virepri> alright
09:15:22Araqregex.split is also terrible given that we have a splitLines iterator
09:16:39narimiran`input.splitlines.map(parseInt)` is how i usually do it
09:17:32Araqand why does 'while !' even compile? use the 'not' operator
09:18:03Araqand use containsOrIncl()
09:18:05FromDiscord_<Virepri> holy cow
09:18:09FromDiscord_<Virepri> yeah that's way way faster
09:18:29narimiran`intsets` is where is at. you're 8 days behind us ;)
09:19:06narimiran(this is AoC day1, right? :))
09:19:28FromDiscord_<Virepri> yeah
09:19:32FromDiscord_<Virepri> I know I'm a couple days behind
09:19:37FromDiscord_<Virepri> I'm restarting in nim
09:19:51FromDiscord_<Virepri> (Am i allowed to advertise my shitty stream here?)
09:20:41narimiranonly if it is not very shitty :P
09:21:25leorize@Virepri: do you come to Nim from Python?
09:21:27Araqnarimiran: we need something better than splitLines.map(parseInt), a variant of scanf would help
09:22:22narimiranAraq: i'm using scanf extensively in this year's AoC, but one line at time. you would like to see multiline version of scanf?
09:22:52FromDiscord_<Virepri> leorize: I actually come from golang. I tried scala initially but wasn't a huge fan
09:23:06FromDiscord_<Virepri> I was mostly just looking to use AoC as an opportunity to learn
09:23:14leorizeoh, I saw you're qualifying symbols there :P
09:23:17AraqI don't know yet, but whenever somebody uses any variant of split() a baby dies
09:23:23FromDiscord_<Virepri> anyway, https://twitch.tv/virepri
09:23:27narimiranAraq: lol
09:23:36FromDiscord_<Virepri> y'all can come suffer with me
09:23:56narimiran@Virepri AoC is a great opportunity to learn Nim! this is what i did last year and it helped me immensely
09:24:09Araqsplit is the poor man's lexing framework, always slow, almost always wrong
09:25:49Araqhere split "this command" for me
09:25:52Araq^ oops.
09:31:58FromDiscord_<Virepri> ok, now, here comes the next dumb question
09:32:10FromDiscord_<Virepri> is it possible to make a seq into a looping linked list for the purpose of iteration?
09:32:17FromDiscord_<Virepri> because that'd be a neat performance hack
09:32:35leorizeno, and why would it be a performance hack?
09:33:04narimiran@Virepri i've used `itertools.cycle`, mostly because that is my nimble package :)
09:34:06narimiranif you're asking because of the second part where you iterate multiple times through the list
09:34:16FromDiscord_<Virepri> yup
09:51:33Araqthe cost of a seq is its materialization, once you have it, iteration over it is as fast as it can get
09:51:53*nc-x joined #nim
09:51:56Araq"seq to iterator" is possible but slower
09:52:14nc-xAraq: Any idea re https://travis-ci.org/nim-lang/Nim/jobs/465546822#L3886
09:53:49Araqno but it should be easy to reproduce locally
09:54:25FromDiscord_<Virepri> https://nim-lang.org/docs/tables.html is there something more efficient than this for mapping a set of characters to a set of integers?
09:54:40FromDiscord_<Virepri> because last time I got caught up using hashset, when intset was more efficient
09:54:52FromDiscord_<Virepri> and I mostly just want to make sure I'm not seeing one thing and getting distracted
09:55:02narimiran@Virepri you can use arrays ;)
09:55:17leorizearray of tuples :P
09:55:19nc-xAraq: I don't have linux/mac and it passes on windows locally/appveyor both.
09:56:23Araqnc-x: ask narimiran to run it ;-)
09:56:39AraqI'm busy with the bloody testament refactorings
09:56:42nc-xAnyone with linux can try https://github.com/nim-lang/Nim/pull/9911 and run `koch tests c modules`?
09:56:54nc-xnarimiran: ^^^
09:57:02narimirannc-x: i'll do it :)
09:57:10nc-xthanks!
10:00:41FromDiscord_<Virepri> `var seen: array[char, int]` does this technically initialize the array? I mean, I doubt it does, but I don't know the "proper" way to do it.
10:00:42CalinouI'll test it too
10:00:51narimirannc-x: maybe you know how do i easily pull your branch?
10:00:56FromDiscord_<Virepri> it doesn't error out when I'm compiling 👀
10:01:03FromDiscord_<Virepri> it feels sketch man
10:01:06leorizeVirepri: yes, it initialize by default
10:01:09Calinouan easy way is to install hub (https://hub.github.com/) and run "hub checkout <PR URL>"
10:01:09FromDiscord_<Virepri> o
10:01:12FromDiscord_<Virepri> aight
10:01:13narimiran@Virepri it will create an array with zeros
10:01:15FromGitter<mratsim> > *<Araq>* I don't know yet, but whenever somebody uses any variant of split() a baby dies ⏎ ⏎ I killed a baby yesterday. Was trying to do a sentiment analysis example on 50k IMDB reviews, it was too damn slow. I need to build a custom string parser/tokenizer: https://github.com/mratsim/Arraymancer/blob/example-sentiment-analysis/examples/ex06_helpers.nim#L108-L127
10:01:15Calinouit will automatically switch to the branch
10:01:36leorizeVirepri: wouldn't that array be a bit... too big?
10:01:53leorizeare you gonna use all of the 255 possible values?
10:02:22narimiran@Verpri leorize: `array['a'..'z', int]` or something like that should be enough
10:02:23CalinouI find myself using split since I don't know enough about lexers :P
10:02:23FromGitter<mratsim> @Virepri, just use countTable https://nim-lang.org/docs/tables.html#CountTable
10:02:50nc-xnarimiran: https://stackoverflow.com/a/30584951
10:02:56leorizeCalinou: scanf is supposed to make it simple :P
10:03:13FromGitter<mratsim> @Calinou, I want something that is reasonably fast on the 1 billion words dataset: http://www.statmt.org/lm-benchmark/
10:03:24FromGitter<mratsim> using split would be crazy :D
10:03:28narimirannc-x: thanks!
10:04:36Calinouone failure, https://hastebin.com/izahoyubup.txt
10:04:58Araqmratsim: Maybe some nice guy will revive my Lexim project
10:05:00FromGitter<mratsim> @Calinou, if you want an easy weekend project to learn about lexer, just try to do a brainfuck VM. For example this is my lexer: https://github.com/mratsim/jitterland/blob/master/bfVM_v02.nim#L30-L58
10:05:01CalinouI don't know if this is related to my system, I use GCC 8.2.1 on Fedora 29
10:05:32leorizetry running it by hand?
10:05:43nc-xCalinou: thanks. can you manually try `nim c tests/modules/t9627.nim`
10:05:43CalinouI had a class on grammars like EBNF but I didn't understand it much since we didn't implement anything using it :|
10:05:58Araqmratsim: seem a terrible lexer to me ;-)
10:06:18Calinouhttps://hastebin.com/ojacivuqat.txt
10:06:44FromGitter<mratsim> a generator would take lots more space;)
10:07:06Araqlexbase is a stdlib module
10:07:10FromGitter<mratsim> @Calinou I think this is a good example of what lexers are supposed to do: http://www.craftinginterpreters.com/scanning.html#the-scanner-class and you can check the JSON module as well
10:07:45leorizenc-x: you should rename your modules folder...
10:08:18nc-xAh ok... **** linux and mac -.-
10:08:20narimirannc-x: http://ix.io/1vBy
10:09:13FromDiscord_<Virepri> narimiran: no I wasn't, and yeah, your suggestion was good
10:09:28FromDiscord_<Virepri> didn't know I could get fancy like that
10:09:32FromDiscord_<Virepri> thanks for pointing it out
10:09:49nc-xnarimiran: Thanks but found the issue.
10:10:04narimirannc-x: ok, ping me later if needed
10:10:41nc-xAraq: Can we implement your executable_name.elf idea on linux and similar for mac? ;)
10:11:37leorizeno, linux users will kill you :P
10:13:23nc-x:P
10:14:09FromDiscord_<Virepri> any good way to find the intersection between two strings?
10:15:07*nc-x quit (Quit: Page closed)
10:16:18leorizemy overly complex way: split the strings by words, then feed them to a HashSet
10:17:38FromDiscord_<technicallyagd> Does the order matter?
10:17:50Araqmratsim: he puts every token in a list. that's not required by any parser I've ever written
10:17:51FromDiscord_<Virepri> yes
10:18:15FromDiscord_<Virepri> it has to be in the same order as the first string. The strings are the same length
10:18:15FromDiscord_<Virepri> so
10:18:34Araqyou can "stream" these things easily
10:18:34FromDiscord_<Virepri> abcde
10:18:34FromDiscord_<Virepri> abcee
10:18:34FromDiscord_<Virepri> would give
10:18:34FromDiscord_<Virepri> abce
10:18:51FromDiscord_<Virepri> my current solution just zips them together, filters, and then folds
10:18:58FromDiscord_<Virepri> :P
10:19:27FromDiscord_<technicallyagd> I went with for loop hell lol
10:19:29FromGitter<mratsim> @Araq, Ah you’re right
10:19:51Calinouthanks for the link to Crafting Interpreters by the way, I should try following it
10:21:04Araqno, read this instead, https://sites.google.com/site/lccretargetablecompiler/
10:22:11Araqor "Modern compiler construction in ML/Java/C"
10:23:48Araqor this one http://www.ethoberon.ethz.ch/WirthPubl/CBEAll.pdf
10:25:08FromGitter<mratsim> I need a fast lexer/parser for English/French/Chines/ … not for programming language ;)
10:26:19Araqlexbase can do it, it's just an efficient way to handle an input buffer
10:26:35FromGitter<mratsim> Yeah, I’ve used it a bit before.
10:26:50FromGitter<alehander42> Araq, split might be often the wrong choice, but splitLines is extremely normal: a huge amount of stuff is naturally separated by newlines
10:26:52Calinouthe test works by the way now
10:26:57Calinou(the one that failed above)
10:27:10FromGitter<alehander42> now, having it as an iterator might be often more useful
10:27:14FromGitter<alehander42> but that's a different problem
10:27:21Araqalehander42: two points
10:27:41*nc-x joined #nim
10:27:56nc-xCalinou: thanks for checking.
10:27:57Araqfirstly, \n remains a separator in your input stream, no need to preprocess that step
10:28:39Araqsecondly, many things have the backslash as a line continuation character
10:29:24Araqand then you have splitLines + mergeLinesWithBackslashesIntoOne + codeThatGoesOverEveryCharacterAnyway
10:29:32FromGitter<alehander42> Araq, well e.g. for all kind of competition/test outputs you dont have anything complicated
10:29:46FromGitter<alehander42> continuation characters come in full blown languages/formats
10:29:55FromGitter<alehander42> obviously you need lex/parsers for those
10:30:17FromGitter<alehander42> for example "you have n lines with 3 numbers on each"
10:30:47AraqI dunno, I can just iterate over the input and after every 3rd number I do something
10:30:50FromGitter<alehander42> here you do need to produce n "objects" with 3 "subobjects"
10:31:04FromGitter<alehander42> so its natural to do 2 "mappings"
10:32:05Araqit's natural but the alternative is usually much better
10:32:12Araqand not more code.
10:32:20FromGitter<alehander42> what is shorter than a.splitLines.mapIt(it.splitWhitespace)
10:32:28leorizea macro? :P
10:33:05FromGitter<alehander42> it.splitWhitespace.mapIt(it.parseInt) *
10:33:08FromGitter<alehander42> you can have probably
10:33:30FromGitter<alehander42> a.splitWhitespace.mapIt(it.parseInt).group_n(3)
10:34:49FromGitter<mratsim> splitWhispace is not an iterator though?
10:34:54Araqok, it's not *much* more code. and in addition to that you learn how program instead of relying a never ending list of builtins
10:35:22FromGitter<mratsim> I feel like we need an iterator/range base strutils otherwise we will be plagued by strings allocations
10:35:24FromGitter<alehander42> grammar: ⏎ Input => *(Data nl) ⏎ Data => 3 (Number ws)
10:36:03FromGitter<alehander42> Araq, that doesnt make any sense, simple tasks should be simple to write
10:36:10FromGitter<alehander42> and still perform well
10:36:22FromGitter<alehander42> composing builtins is good design
10:36:45FromGitter<alehander42> now, you might want a more powerful builtin, like some kind of lexer/parser dsl
10:37:54Araq"er, sorry, we now have data with ';' in it, so we added some escaping mechanism to the CSV file"
10:38:13Araqyour approach: you need to throw away your code.
10:38:21FromGitter<alehander42> well yes
10:38:25FromGitter<alehander42> still better than
10:38:29Araqmy approach: I tweak the parser slightly.
10:38:38FromGitter<alehander42> lets overcomplicate our code just in case in the future we might need X feature
10:39:13FromGitter<mratsim> ah CSV … when simple “specs” lead to bloat hell
10:39:17FromGitter<alehander42> the point is that the first version would've taken 20 seconds to write, so you're not really losing anything if you rewrite it
10:39:30Araqusually I agree with YAGNI but these toy input formats are all terrible
10:39:31FromGitter<alehander42> the sunk cost fallacy doesn't work here
10:40:00Araqit takes 20 seconds to write and then it doesn't work in a production setting
10:40:05FromGitter<alehander42> they are, but my point is people often have such things, which are always going to be very simple to process
10:40:09Araqwhen the amount of data increases
10:40:12FromGitter<alehander42> of course for more complicated formats
10:40:18FromGitter<alehander42> you should use a proper parser
10:40:21Araqor when somebody figures out his data can actually contain semicolons...
10:40:21FromGitter<mratsim> I always think of those links when parsing CSV: http://secretgeek.net/csv_trouble, http://thomasburette.com/blog/2014/05/25/so-you-want-to-write-your-own-CSV-code/
10:41:16anamokI read the previous comments and people suggested not to use split. What to use instead?
10:41:32FromGitter<mratsim> split the iterator is probably OK
10:41:53FromGitter<mratsim> split the one that allocates seq[string] is too slow.
10:42:39anamokmratsim, "split the iterator is probably OK" What do you mean? Do you have a small example?
10:42:46FromGitter<mratsim> well it depends on your scale, but in my case i work with millions to billions of words: https://github.com/karpathy/char-rnn/blob/master/data/tinyshakespeare/input.txt
10:43:40FromGitter<mratsim> https://nim-lang.org/docs/strutils.html#split.i%2Cstring%2Cset%5Bchar%5D%2Cint
10:44:10FromGitter<alehander42> @anamok honestly depends on your usecase, if you really need a list of substrings that are really separated by X, split is fine
10:45:00anamokmratsim, OK, take your input. How do you iterate over the words one by one? I would use text.splitWhitespace() .
10:45:06FromGitter<alehander42> if you have huge amounts of data , whatever you do should be optimized anyway, not only splitting
10:45:22Araqand it's not about high level vs low level code, split and friends are the wrong tools, they don't *compose* well. your combination of splitLines + splitWhitespace happens to work because newlines are not substrings of spaces
10:45:56FromGitter<alehander42> no?
10:46:19FromGitter<mratsim> I think the string processing story in Nim is at kindergarten level :/
10:46:25FromGitter<alehander42> you split on newlines: now you dont have any newlines, it doesnt matter if they are in WhitespaceChars
10:46:29FromGitter<mratsim> (maybe it’s in C in general)
10:46:56FromGitter<mratsim> It’s too easy to create something super slow.
10:47:06Araqmratsim: How so? scanf is pretty good, lexbase is elegant IMO
10:47:22FromGitter<mratsim> well, strutils is the first thing people will look into
10:47:33FromGitter<mratsim> and it’s ladden with pitfalls
10:47:47FromGitter<mratsim> I agree with @Krux02 when he said the pretty radical, we should get rid of it.
10:48:00FromGitter<mratsim> (and rebuild from the ground up)
10:48:16AraqI don't agree. String processing done by programmers is at the kindergarten level.
10:49:24FromGitter<mratsim> Anyway I guess that’s my future lib. A string processing library that scales.
10:49:34anamokWhat is advanced level of string processing? How to do it correctly?
10:50:45Araquse flex or re2c, unfortunately Nim only has 'lexim' which I don't have time to maintain
10:50:50FromGitter<mratsim> I don’t know yet but I want to parse and tokenize books and web pages to feed AI
10:52:02FromGitter<alehander42> there is no reason for splitLines.mapIt(Obj.init(it.splitWhitespace(3))) to not work very quickly except for the fact that splits are not iterators and that we cant chain iterators well
10:52:04FromGitter<mratsim> and it should deal with English, French, Chinese, HTML tags like <br />
10:52:32FromGitter<alehander42> if you chain several iterators you can have your deferred "lex and process without an intermediate seq" thing
10:52:40Araqalehander42: No that is wrong.
10:52:49FromGitter<alehander42> its wrong for some usecases
10:52:53FromGitter<alehander42> its ok for others
10:53:01FromGitter<mratsim> https://github.com/nim-lang/Nim/issues/4516
10:53:05FromGitter<alehander42> not everything needs a lexer
10:53:20FromGitter<alehander42> obviously @mratsim needs it
10:53:21Araqif your primitives are incapable of describing "a list of words is separated by whitespace unless in quotes"
10:53:32Araqthen you throw away the primitives.
10:53:54FromGitter<alehander42> no, you use the primitives for the thousands of cases where you dont actually have quoted strings
10:54:00FromGitter<alehander42> and when you do have
10:54:13FromGitter<alehander42> you use other primitives (e.g. lex dsl-s to handle those)
10:54:45Araqthe other primitives are all you need though.
10:54:58FromGitter<alehander42> i'd even argue that lexers suck
10:55:06FromGitter<alehander42> if you need a lexer, most of the time you need a parser
10:55:17FromGitter<alehander42> because rarely everything is just a flat list of data
10:55:28FromGitter<alehander42> (lexers as an end user dsl)
10:55:59Araqnot in my experience. a lexer can go a long way
10:56:04Araqand split can't.
10:56:18*nc-x quit (Quit: Page closed)
10:57:01FromGitter<alehander42> right tool for the job: if split can do X correct and efficiently, do it ⏎ if else: use lexing, if you need to directly generate a hierarchical structrue, use parsing
10:57:16FromGitter<alehander42> its like saying "use macros ALWAYS because often functions are not sufficients"
10:58:09FromGitter<alehander42> how would "generate a list of Coord from text file with n X Y lines" work with a lex DSL
10:58:36Araqno it's like saying "I don't need a roller, I have a bike".
11:02:45FromGitter<alehander42> its like saying "i dont need a car to go the shop, its 50 feet away, I can go by feet man"
11:02:53Araq const input = "(1,2,4)"
11:02:53Araq var x, y, z: int
11:02:53Araq if scanf(input, "($i,$i,$i)", x, y, z):
11:02:55Araq echo "matches and x is ", x, " y is ", y, " z is ", z
11:03:13Araq^ scanf can do it
11:05:29Araqalehander42: well yes, you can go by car or by foot. but not by a broken bike.
11:06:12Araqand for me split is broken, for you it's acceptable.
11:06:36FromGitter<alehander42> eh the input is "(1,2,4)\n(2,5,7)\n(4,3,1)\n"
11:06:54*nsf joined #nim
11:07:07Araqstill works but requires a loop, but that's beside the point.
11:07:47Araqscanf is not good enough, we need a lexer generator :P
11:09:42FromGitter<alehander42> or you can just have ⏎ ⏎ grammar: ⏎ __ Input as seq => *(Coord nl) ⏎ __ Coord => "(" int "," int ")" [https://gitter.im/nim-lang/Nim?at=5c0cf7f611bb5b250488895b]
11:10:06FromGitter<alehander42> this now look absolutely fucked in gitter
11:10:24FromGitter<alehander42> but you see my point, we need parser generators :D
11:12:55CalinouI didn't know about scanf
11:13:15Calinoufor simple use cases, it looks far more elegant than a bunch of splits :p
11:13:49Calinouthat's what I wrote a few weeks ago for instance https://github.com/Calinou/escape-space/blob/master/menu/update_checker.gd#L68-L80
11:17:01FromGitter<alehander42> that requires proper parsing indeed, I dont argue that split is always a good option
11:17:54FromGitter<alehander42> Araq: however your logic is very similar to "we should pattern match everywhere, if/case are broken and work only for very simple cases" ⏎ scanf is literally pattern matching inside a string
11:22:16*narimiran quit (Ping timeout: 250 seconds)
11:36:03*stefanos82 joined #nim
11:45:38*martin1__ joined #nim
11:45:48Araqnot really, it's just that split is a bad tool for lots of reasons.
11:47:07Araqand it is frequently misused. proof: it has grown a 'maxsplits' parameter
12:05:03*Snircle joined #nim
12:06:17FromGitter<arnetheduck> Araq, what are you doing to testament?
12:08:49Araqarnetheduck: we join the tests into one big one to save about 20minutes of testing time
12:11:16FromGitter<arnetheduck> Right.. Seen that.. Would be nice if the tests were included together they can still be run individually.. Same think as blocks, just using include
12:12:50FromGitter<arnetheduck> Hehe, getting closer to c++ problems and solutions.. Compiler times getting fixed by unity builds
12:15:30Araqyeah, I'm doing that
12:15:44Araqif you run a single category it processes them individually
12:18:07FromGitter<Varriount> Araq: What about failures that crash the executable?
12:19:18Araqwell testament gives you an "expected but got" diff for the "megatest"
12:20:21Araqcrashes lead to incomplete output and/or an exit code != 0, nothing hard about them
12:20:41FromGitter<alehander42> Araq: I agree, sorry if I sounded dismissive, lexing/parsing is better most of the time, but the maxsplit arg is not perfect: you need something like that in lexing/parsing too
12:22:59Araqyes and no, the problem description in lexing/parsing doesn't state "split by ':' but stop after N splits", it more like "in this state, the next token is from ':' until the end of the line"
12:24:17Araqwhich is the difference between a hack and a real solution.
12:25:22FromGitter<alehander42> eh, sometimes you know you need =/<= n repetitions
12:27:34FromGitter<alehander42> also, I am talking about a declarative definition, e.g. grammer("Line => (Number ';'){9}")
12:28:32FromGitter<alehander42> not very often needed, I agree
12:32:28*rockcavera quit (Read error: Connection reset by peer)
12:33:21Araqthat says 9 numbers are in it. it doesn't say "join all the rest together into a token and ignore the error"
12:33:36*rockcavera joined #nim
12:33:36*rockcavera quit (Changing host)
12:33:36*rockcavera joined #nim
12:33:42Araqwhich is what split(maxsplit=9) does
12:40:25FromGitter<alehander42> ah this is maxsplit
12:40:50FromGitter<alehander42> well, how would you describe with a lex dsl the same, its often useful
12:45:43*dddddd joined #nim
12:50:29FromGitter<arnetheduck> @Araq nice, high granularity is very useful for pinpointing stuff
12:52:50FromGitter<arnetheduck> brw, I saw `allPathsAsgnResult` in cgen.. isn't that more of a `sem`thing?
12:55:45*hwallann joined #nim
12:58:28FromGitter<Varriount> Araq: Yes, but won't this mega test make finding what caused the crash difficult?
13:04:27*martin1__ quit (Quit: WeeChat 2.1)
13:04:29*EastByte quit (Quit: WeeChat 2.2)
13:11:04*theelous3_ joined #nim
13:14:26*bitstoppa[m] left #nim ("User left")
13:20:56*EastByte joined #nim
13:23:00*EastByte quit (Client Quit)
13:24:41*fthe joined #nim
13:27:48*endragor joined #nim
13:36:16*kapil____ joined #nim
13:38:06*jakob0094 joined #nim
13:46:45*EastByte joined #nim
13:50:51*EastByte quit (Client Quit)
13:51:03*EastByte joined #nim
13:51:45*noonien quit (Quit: Connection closed for inactivity)
13:58:33edcraggi see there is the module lists, i see it has doubly linked lists, etc, but these only have append() and prepend() functions, and iterators over nodes, this seems to make it very cumbersome to insert a node in the middle of the list, for example
14:00:26*banc quit (Ping timeout: 250 seconds)
14:01:44*banc joined #nim
14:11:15*narimiran joined #nim
14:13:08ftheedcragg: seqs have insert()
14:15:19narimiranedcragg: AoC day9? :)
14:16:38narimiranfthe: `seq.insert` is quite expensive, and if you have to do it that much time as in AoC day9, you gonna have a bad time ;)
14:17:19ftheah, not on day 9 yet, I'm late :)
14:18:31narimiranfthe: when you come to it, seq.insert might give you the result for part1, but for part2 you need to be smarter than that :)
14:18:37Zevvnarimiran: yeah that was a nice surprice, part II telling you to basically "throw away and think again"
14:19:05Zevvfunny is that my part II solution is much simpler and smaller then part I
14:20:44edcragg:) aoc, indeed
14:22:05narimiranedcragg: you're on a right path with your idea ;)
14:23:10fthecurious: does nim have a way of marking an object field immutable? (like c# readonly, java final)
14:24:26dom96nope, but you can make it private and create an accessor proc that's exported
14:24:43fthemakes sense!
14:29:11*PMunch joined #nim
14:52:03*endragor quit (Ping timeout: 246 seconds)
14:54:15*endragor joined #nim
14:55:05M37[m]Today's AoC was great. Finally got to try nim's implementation of insert spoiler.
14:55:57M37[m]Does that jamie guy on the leaderboard hang around here? He got 5th today for part 1.
14:56:44M37[m]Pretty impressive.
14:58:09*endragor_ joined #nim
14:58:39narimiranM37[m]: agreed that today was great. i also liked yesterday's task and day5
15:01:32*endragor quit (Ping timeout: 250 seconds)
15:04:54*endragor_ quit (Remote host closed the connection)
15:06:46M37[m]narimiran: same. So far, those days have seemed the most elegant.
15:08:03M37[m]I did today's part 1 the lazy way, hoping that I'd be forced to do it properly for part 2 :)
15:10:00FromGitter<zacharycarter> hmm - trying to build with `-d:useNimRtl` and getting the error - ⏎ ⏎ ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5c0d30485e409525033cff75]
15:10:29M37[m]I also liked day 6. And day 4 is memorable.
15:11:10FromGitter<zacharycarter> ah I found an issue on it - I think I understand why
15:13:11narimiranM37[m]: i had trouble with day6, i don't remember exactly what it was, but i know it took me way too long to get the correct solution
15:13:46narimiranhmmm, or was that day7?
15:17:19FromGitter<zacharycarter> what are the disadvantages of using the C++ backend over the C backend? just portability?
15:17:31FromGitter<zacharycarter> and performance?
15:19:22FromGitter<zacharycarter> also - if I'm using dlopen / close and thus using `useNimRtl` - do both the main application (the one calling dlopen / close), and the shared library need to be linked against nimrtl.dll - or just the plugin?
15:19:28FromGitter<zacharycarter> slightly confused on that part
15:21:54PMunchI think it's both
15:22:05PMunchBut I've never gotten that to work properly
15:22:10narimiranM37[m]: what is your memory consumption for day9?
15:22:43FromGitter<zacharycarter> it sounds maybe - like it's only the plugin
15:23:07FromGitter<zacharycarter> `This means that every generated Nim DLL depends on nimrtl.dll`
15:23:21FromGitter<zacharycarter> going to play around with it
15:23:50dom96bah, feel like I missed out on this whole thing. Starting on day 9 seems far too late
15:24:22PMunchday9 part 2.. It's Sunday, that's no day for optimizing code..
15:24:43PMunchI consider just leaving it to run for a couple hours..
15:25:02PMunchOr however long this will take..
15:25:05narimirandom96: start with day5, then day8 and day9
15:25:15narimiranothers are not as fun as those
15:25:38fthe...I'm late, just finished day 7. Day 6 took way longer than I care to admit :/
15:26:24dom96narimiran: Might do that, but skipping days makes me feel uncomfortable heh
15:26:41narimiranPMunch: wait, i thought sunday was *the* day for optimizing :)
15:27:04narimirandom96: heh, start with those to get going and after that solve your OCD :D
15:27:13PMunchI'm hungover and lazy..
15:29:04narimiranmy memory consumption for day9 is over 300MB! i feel very dirty
15:29:20M37[m]narimiran: I'll investigate in a little bit. I didn't optimise it yet - it looked like everything would fit in uint32. But part 2 runs in 3 ms on an old laptop.
15:29:41M37[m]How are you profiling it?
15:29:56M37[m]valgrind?
15:30:13narimiranM37[m]: wait what? your day9, part2 runs in 3ms!? wow! mine takes 0.8 s!
15:30:13*endragor joined #nim
15:31:13narimiranM37[m]: nah, just a ruby script i found somewhere which measures time and memory. and i usually measure time by running a program 100 times and then divide by 100
15:33:31FromGitter<zacharycarter> if I generate a shared library with Nim and then want to call it - do I call it using the nimcall calling convention?
15:33:32FromGitter<zacharycarter> or stdcall?
15:39:15M37[m]narimiran: Haha, I thought my runtime was too good to be true. It's actually 500 ms. After I finished I wrote "assert answer == " at the end instead of doAssert :p
15:39:38M37[m]So it's probably the same speed as yours, if I remember our runtime differences from last week.
15:40:14FromGitter<zacharycarter> got my stupid example working finally - just compiled the dylib with `-d:useNimRtl` and used `nimcall` as the calling convention and made sure to `exportc` the proc in the shared lib
15:40:26FromGitter<zacharycarter> and I was able to call a proc declared inside of it without having anything blow up
15:40:30narimiranM37[m]: oh ok, you scared me there! i thought i need to spend the rest of the sunday heavily optimizing :D
15:40:46FromGitter<zacharycarter> now to work on progressing to the point where nothing works :)
15:42:29*endragor quit (Remote host closed the connection)
15:42:49*endragor joined #nim
15:44:37FromGitter<zacharycarter> I guess I should really use cdecl and not nimcall
15:44:43M37[m]narimiran: But today I was puzzled for a while because I had `--gc:markAndSweep` set somewhere. Try that with part 2 and you'll have a bad time.
15:55:44narimiranwhen i try to use `nimprof`, i'm greeted with "system/profiler.nim(91, 23) Error: undeclared identifier: 'framePtr'" anybody knows what's going on? (cc dom96 )
15:55:47*Trustable joined #nim
15:56:15dom96narimiran: have you tried following: https://nim-lang.org/blog/2017/10/02/documenting-profiling-and-debugging-nim-code.html#profiling-your-code ?
15:56:24Zevvdom96: not sure about the getaddrinfo
15:56:56narimirandom96: yes, i'm using nimprof the same way as i used to before: i import nimprof, and compile with --profiler:on --stacktrace:on
15:56:56Zevvbecause just below getAddrString() is the getSockName()
15:57:04Zevvwhich seems a better fit to implement getsockname() :)
15:57:51dom96Zevv: I'm not sure myself, I'm not the author of the code :)
15:58:09dom96narimiran: it's a regression then
15:59:39ZevvHm i'll take a second look, but I wasn't sure the first time, thus my naive implemnetation.
15:59:58narimirandom96: it might be because Araq removed this line "{.deprecated: [TStackTrace: StackTrace, TProfilerHook: ProfilerHook].}" 3 weeks ago
16:00:02Zevvanother (stupid?) question: why does the CI fail?
16:00:13dom96narimiran: should be an easy fix then :)
16:00:34Zevvnativesockets.nim(487, 37) Error: undeclared identifier: 'nativeAfUnix' on the linux build?
16:01:17*kapil____ quit (Quit: Connection closed for inactivity)
16:05:45narimirandom96: hmmm, even stable throws the same error. i guess this goes way back then....
16:08:54stefanos82Araq and dom96: will you inform me via ticket reply (#9889) when a fix is provided for the crashing?
16:09:08narimirancan anybody please try to reproduce? does nimprof work at your end?
16:13:04*nsf quit (Quit: WeeChat 2.3)
16:13:51*nc-x joined #nim
16:14:00nc-xnarimiran https://github.com/nim-lang/Nim/issues/8991
16:14:20narimirannc-x: yup, that's it
16:14:31narimiranthanks!
16:14:39leorizeI guess you can always resort to gprof?
16:16:45FromGitter<zacharycarter> dom96: would you be interested in expanding that blog post to talk about instrumenting / profiling tools on macOS?
16:16:51FromGitter<zacharycarter> or having someone expand it for you
16:17:00FromGitter<zacharycarter> because valgrind really isn't a viable option for macOS
16:17:08FromGitter<zacharycarter> if you're using clang / llvm
16:17:14dom96Why not? I've used it on macOS IIRC
16:17:33dom96It might be better if you create a new article, this one is now quite old
16:17:37FromGitter<zacharycarter> lots and lots of false positives - making it so you have to get deep into exclusion rule crap to really make it useful
16:17:58FromGitter<zacharycarter> maybe I should ask if there's interest on the forum first
16:18:11FromGitter<zacharycarter> the tools I'm speaking to are like address sanitizer, leaks, etc
16:18:38nc-xnarimiran: try this https://github.com/nim-lang/Nim/issues/4446#issuecomment-239356177
16:19:36FromGitter<zacharycarter> I'm not even sure how many people are using Nim + macOS - could be an interesting survey question to see what operating systems Nim is running on
16:20:15nc-xthere are atleast 3 issues open regarding this framePtr
16:21:10narimirannc-x: removing confing.nims solves the issue, thank you!
16:21:42nc-x:D
16:30:04*nc-x quit (Quit: Page closed)
16:32:34*theelous3_ quit (Quit: is outty)
16:44:37*endragor quit (Remote host closed the connection)
16:56:22Araqstefanos82: I fixed that one yesterday?
16:56:44stefanos82OK, let me fetch the latest updates and check it again then
17:01:50*Vladar joined #nim
17:03:59stefanos82Araq: still crashes
17:05:47stefanos82Araq: http://paste.debian.net/1055040/
17:18:00*crem quit (Ping timeout: 252 seconds)
17:20:05*crem joined #nim
17:20:30shashlickdom96: adding packages to the nimble directory has become way too much of a chore
17:31:47Araqit doesn't crash
17:31:50Araq../../GIT_CODES/Nim/lib/system.nim(467, 10) Error: 'nil' is now
17:31:50Araqinvalid for 'string'; compile with --nilseqs:on for a migration period;
17:31:50Araqusage of '==' is a user-defined error
17:32:04Araqthe code doesn't compile because it's outdated.
17:32:31Araq... utils.nim(289, 11) template/generic instantiation of `!=` from
17:32:31Araqhere
17:44:34ZevvAraq, I feel stupid: why does my job CI job break on 'undeclared identifyier: native
17:44:38ZevvAfUnix'?
17:45:10ZevvIt's declared at the same place as nativeAfInet
17:48:46Araqyou can usually do 'nim doc blah.nim' to reproduce locally
17:49:06Zevvah thanks
17:54:02Zevvooh 'nimdoc' enables 'useWinVersion'. That's kind of unexpected
18:23:39*nsf joined #nim
18:26:46stefanos82Araq: should I add this flag in front of nimble?
18:33:48Araqstefanos82: I doubt nimble supports this flag. but fixing the code is usually not hard and should be done
18:34:00stefanos82I see
19:02:22*shashlick quit (Ping timeout: 244 seconds)
19:16:48*lritter joined #nim
19:16:54*Jesin quit (Quit: Leaving)
19:18:09*lritter quit (Read error: Connection reset by peer)
19:21:32*anamok quit (Remote host closed the connection)
19:22:58*lritter joined #nim
19:28:56stefanos82Araq: the aforementioned flag is supported with nimble as well
19:30:24*nsf quit (Quit: WeeChat 2.3)
19:35:10stefanos82dom96: I have managed to compile it with nimble build --nilseqs:on, but fails miserably during execution lol.
19:35:39stefanos82http://paste.debian.net/1055063/
19:37:58*martin__ joined #nim
19:46:21*lucasb joined #nim
19:48:10*shashlick joined #nim
19:51:09*tefter quit (Remote host closed the connection)
19:58:45*Jesin joined #nim
20:06:48xacewhen i `import <lib>` how does nim find <lib>? in this case i installed it with nimble, but i would like to add my own local/personal commonly used proc do I just add a ~/.nimble/mylib-0.0.1 ?
20:08:30ZevvI believe 'nim dump' gifs a list of searched paths
20:10:24xaceyeah, it seems like it mentions the ~/.choosenim/ paths but no reference to the ~/.nimble directory
20:18:33*Trustable quit (Remote host closed the connection)
20:25:00*martin__ quit (Read error: Connection reset by peer)
20:25:17*martin__ joined #nim
20:44:14*narimiran quit (Remote host closed the connection)
21:00:37*platoff joined #nim
21:02:36*Vladar quit (Remote host closed the connection)
21:37:58dom96xace: If you have my book the chapter on Nimble has a good figure for that
21:38:09dom96otherwise: Nim searches through each --path it gets
21:38:52dom96nim also gets --nimblePath:~/.nimble/pkgs which just searches through ~/.nimble/pkgs and adds each (latest) package in there with --path
21:39:26dom96In any case, you likely want to create a package and install it (or use `develop`, search for this in the Nimble readme to learn more)
21:47:32*stefanos82 quit (Remote host closed the connection)
22:06:14*Lavos joined #nim
22:12:36*Jesin quit (Quit: Leaving)
22:14:35*platoff quit (Quit: My MacBook has gone to sleep. ZZZzzz…)
22:17:37*Lavos quit (Remote host closed the connection)
22:37:33*martin__ quit (Ping timeout: 245 seconds)
22:50:18*kapil____ joined #nim
22:58:42*martin__ joined #nim
23:05:28*platoff joined #nim
23:16:03*fthe quit (Ping timeout: 246 seconds)