<< 04-08-2018 >>

00:01:05FromGitter<mratsim> last link I promise: https://www.reddit.com/r/programming/comments/862f7j/article_project_from_hell/dw1ywm2/
00:01:45FromGitter<mratsim> If you’re still up for more, just read random stories from here: https://thedailywtf.com/
00:05:04*xylef quit (Quit: WeeChat 2.2)
00:12:48*SenasOzys__ joined #nim
00:12:57*SenasOzys quit (Ping timeout: 240 seconds)
00:13:37stefanos82@mratsim: the project failures link you shared above...it just made me nauseous
00:36:09*Sembei joined #nim
00:36:35*Pisuke quit (Ping timeout: 240 seconds)
01:03:34*stefanos82 quit (Quit: Quitting for now...)
01:43:33*wildlander quit (Quit: Konversation terminated!)
02:09:58*Matrixiumn joined #nim
02:10:54*Matrixiumn quit (Killed (Sigyn (Spam is off topic on freenode.)))
02:25:31*bthesorceror joined #nim
02:30:00*lunaaa joined #nim
02:31:46*lunaaa quit (Remote host closed the connection)
02:37:57*SenasOzys__ quit (Ping timeout: 240 seconds)
02:38:18*SenasOzys joined #nim
02:39:04FromGitter<kayabaNerve> TDWTF is my new favorite site. Thanks @mratsim
03:00:30*kaushalmodi joined #nim
03:56:48*krux02 quit (Remote host closed the connection)
04:06:38*thevdude1 joined #nim
04:07:07*thevdude1 quit (Remote host closed the connection)
04:15:42*rockcavera quit (Remote host closed the connection)
04:25:10*rockcavera joined #nim
04:35:35*dorelix quit (Ping timeout: 240 seconds)
04:49:07*dorelix joined #nim
04:51:05*bthesorceror quit (Ping timeout: 240 seconds)
05:12:43*kaushalmodi quit (Quit: Connection closed for inactivity)
05:17:27*smt` quit (Read error: Connection reset by peer)
05:17:49*smt` joined #nim
05:23:09*doomsday joined #nim
05:30:23*Gentle joined #nim
05:30:27*xylef joined #nim
05:32:07*Gentle quit (Remote host closed the connection)
05:38:38*kaushalmodi joined #nim
05:45:18*Ocdd joined #nim
05:55:54*xylef quit (Quit: WeeChat 2.2)
05:56:09*bthesorceror joined #nim
06:09:44*Trustable joined #nim
06:09:54*Vladar joined #nim
06:11:06*doomsday left #nim (#nim)
06:23:20*dorelix quit (Quit: Leaving)
06:38:24*kobi_ joined #nim
06:39:10*kobi_ quit (Client Quit)
06:39:27*kobi7 joined #nim
06:43:22*yglukhov[i] joined #nim
06:57:52*kobi7 quit (Quit: Leaving)
07:04:19*nsf joined #nim
07:09:09*yglukhov[i] quit (Remote host closed the connection)
07:21:34*bthesorceror quit (Quit: Lost terminal)
07:29:06FromGitter<mratsim> This is pretty: https://github.com/google/filament " ⏎ Filament is a physically based rendering engine for Android, Linux, macOS and Windows. This rendering engine was designed to be as small as possible and as efficient as possible on Android."
07:52:43*kaushalmodi quit (Quit: Connection closed for inactivity)
07:55:19*yglukhov[i] joined #nim
08:03:23*gmpreussner joined #nim
08:04:34*gmpreussner_ quit (Ping timeout: 264 seconds)
08:06:08*loppy2 joined #nim
08:07:55*loppy2 quit (Remote host closed the connection)
08:14:00*yglukhov[i] quit (Remote host closed the connection)
08:18:22*yglukhov[i] joined #nim
08:20:31*syncretism_mbl14 joined #nim
08:20:34*Ocdd quit (Quit: Leaving)
08:21:39*syncretism_mbl14 quit (Killed (Sigyn (Spam is off topic on freenode.)))
08:22:00*echotangoecho joined #nim
08:28:58*ng0 joined #nim
09:05:07*echotangoecho quit (Quit: Lost terminal)
09:33:17*Xgc19 joined #nim
09:33:32*Xgc19 quit (Remote host closed the connection)
10:00:56*Randy11 joined #nim
10:01:23*Randy11 quit (Remote host closed the connection)
10:03:40*wildlander joined #nim
11:08:42zacharycarter[m]mratsim: that's the rendering engine they're using for their new OS
11:09:01zacharycarter[m]I think specifically to power the rendering of specific material design aspects
11:09:04zacharycarter[m]like their corners etc
11:09:14zacharycarter[m]so they've integrated it with flutter inside fuschia I believe
11:11:37*ng0 quit (Quit: Alexa, when is the end of world?)
11:35:48*raSter^9 joined #nim
11:40:47*batman427 joined #nim
11:40:51*raSter^9 quit (Remote host closed the connection)
11:42:31*batman427 quit (Remote host closed the connection)
11:53:41*raynold joined #nim
11:53:57*Vlad17 joined #nim
11:54:11*raynold quit (Killed (Sigyn (Spam is off topic on freenode.)))
11:54:18*VampiricPadraig joined #nim
11:54:58*VampiricPadraig quit (Remote host closed the connection)
11:55:09*Vlad17 quit (Killed (Unit193 (Spam is not permitted on freenode.)))
11:59:44*joepie9121 joined #nim
12:00:25*joepie9121 quit (Remote host closed the connection)
12:00:42*Krenair13 joined #nim
12:01:02*Carlos061125 joined #nim
12:01:07*yglukhov[i] quit (Remote host closed the connection)
12:02:03*Carlos061125 quit (Read error: Connection reset by peer)
12:02:34*Krenair13 quit (Remote host closed the connection)
12:03:51*rtard joined #nim
12:04:58*Guest83394 joined #nim
12:05:28*Guest83394 quit (Killed (Sigyn (Spam is off topic on freenode.)))
12:08:18*RoBz28 joined #nim
12:09:50*RoBz28 quit (Killed (Sigyn (Spam is off topic on freenode.)))
12:10:05*ThiefMaster7 joined #nim
12:11:11*ThiefMaster7 quit (Remote host closed the connection)
12:11:58*weq28 joined #nim
12:12:40*weq28 quit (Killed (Sigyn (Spam is off topic on freenode.)))
12:12:59*sn0wmonster3 joined #nim
12:13:21*sn0wmonster3 quit (Remote host closed the connection)
12:14:05*beaver23 joined #nim
12:18:35*ecks9 joined #nim
12:18:57*beaver23 quit (Ping timeout: 240 seconds)
12:19:16*ecks9 quit (Killed (Sigyn (Spam is off topic on freenode.)))
12:23:20*riidom_ joined #nim
12:25:34*riidom quit (Ping timeout: 260 seconds)
12:28:08*gildarts_ joined #nim
12:28:20*gildarts_ is now known as Guest3376
12:29:24*Guest3376 quit (Killed (Sigyn (Spam is off topic on freenode.)))
12:35:23*Turbo-Folker joined #nim
12:37:02*xet7 joined #nim
12:41:05*Turbo-Folker quit (Ping timeout: 240 seconds)
12:41:41*pointfree3 joined #nim
12:42:32*pointfree3 quit (Killed (Unit193 (Spam is not permitted on freenode.)))
13:15:37*Vladar quit (Quit: Leaving)
13:32:10*Vladar joined #nim
13:50:54*drazan quit (Remote host closed the connection)
13:54:12*drazan joined #nim
13:58:15*BitPuffin joined #nim
14:01:34*krux02 joined #nim
14:18:54*rtard quit (Quit: Leaving)
14:20:51*endragor joined #nim
14:25:25Araqyay, biggest showstopper bug seems to be fixed
14:27:49*endragor quit (Remote host closed the connection)
14:42:50*smt_ joined #nim
14:44:47zacharycarter[m]😃
14:46:35*smt` quit (Ping timeout: 268 seconds)
14:52:47*rtarded joined #nim
14:52:47*MyMind joined #nim
14:52:54rtardedHello
14:53:22*Sembei quit (Ping timeout: 268 seconds)
14:53:23rtardedIs there a list of value/object types out there? For example, are slices value types or objects?
14:54:55leorizertarded: https://nim-lang.org/docs/system.html#HSlice
14:55:39rtardedty
14:55:45rtardedextends object
14:55:47rtardedso yea
14:56:21rtardedguys, are there list comprehensions in nim?
14:57:25leorizeit's in the `future` module
14:58:04rtardedgreat, ty
14:59:24rtardedthe syntax is terrible though
14:59:28rtardednot very intuitive
15:03:07krux02rtarded, don't use that list comprehension
15:03:15rtardedkrux02
15:03:21rtardedwhich one should one use?
15:03:53krux02there is none
15:04:34leorizethen why shouldn't one use that lc?
15:04:52Araqleorize, cause we like to deprecate it
15:05:24Araqrtarded, https://nim-lang.org/docs/system.html "Group by type"
15:06:48krux02Araq: I think that list comprehension should be deprecated now, just to make a situation like today not happen anymore.
15:07:03rtardedwhy do you guys hate them so much?
15:07:18krux02Nim has python syntax people assume that there are python like features and then go for that lc
15:07:18Araqkrux02, well better offer something better first. any ideas?
15:07:51Araqrtarded, cause they are not good enough.
15:07:55krux02I can write a marco for that
15:07:58rtardedgot it
15:08:08Araqkrux02, how? :-)
15:08:20Araqmy own attempts failed
15:08:27krux02well list comprehenion isn't very special
15:08:29Araqwell I tried to extend the language core
15:08:40Araqand it was messier than expected
15:08:44krux02it is just the special syntax that a macro could not do
15:09:56krux02it is just this ``listCoprehension(<expr>, <ident>, <iteratorExpr>)``
15:10:34krux02does everything list comprehension does, except the syntax
15:10:46AraqtoSeq ?
15:11:01krux02almost
15:11:27Araqwhat does it translate to?
15:14:10krux02(var tmp = newSeq[type(<expr>)](); for <ident> in <iteratorExpr>: tmp.add(<expr>))
15:14:11*FromGitter quit (Remote host closed the connection)
15:14:25Araqok, so it does produce a seq
15:14:26*FromGitter joined #nim
15:14:31krux02yes
15:14:49krux02that is the point
15:15:00Araqwhat's the difference to toSeq?
15:16:08krux02toSeq only has the <iteratorExpr>, list comprecenison has the trasformation in <expr>
15:16:51krux02other programming languages have ``map`` that does the exact same thing.
15:17:09krux02for example in scala:
15:17:11Araqsounds like it's a toSeqIt
15:17:42Araqwhich is the same as mapIt
15:17:43krux02(1 to 100).map(x => sin(x) + cos(x))
15:18:32krux02what is a toSeqIt for you?
15:19:00krux02the same as my listComprehension but with <ident> always as `it`?
15:19:11AraqI think so
15:20:28krux02yea I think that would work.
15:20:31Araqfor x in a # if not an iterator, rewritten to 'for x in items(a)'
15:20:57krux02isn't that what the compiler automatically does(
15:20:59krux02?
15:21:00Araqcase x # if not known, rewritten to 'case match(x)'
15:21:21Araq# but the 'match' also gets the of-branches in the second parameter
15:21:37Araqdid I finally sovle pattern matching for Nim?
15:21:47krux02I don't know.
15:21:49*askatasuna left #nim ("WeeChat 2.0.1")
15:21:53krux02I really have to think about it.
15:22:15AraqI think I did. :P
15:23:08krux02well maybe
15:23:28krux02I think about pattern matching with regular expressions
15:24:18krux02I think it would be best when there are multiple patterns, that all regular expressions are joined into a single regular expression, so that matching can be done more efficiently.
15:24:36krux02I realized that in my ast pattern matching.
15:24:54Araqthat's a solved problem, look at lexim which tries to follow the state of the art for regexes
15:25:09krux02it is not very efficient to look sequential through all patterns, when the patterns could also be joined into a single state machine.
15:26:18krux02well it is also not hard to do, it just needs a view of the pattern matching that sees the entire matching tree
15:26:28Araqyup
15:26:29krux02compining regular exprissions isn't hard
15:26:49Araqit is, but it's also well documented
15:26:49krux02(<expr1>)|(<expr2>)|...
15:27:14AraqHopcroft's algorithm for DFA optimization
15:27:20krux02the hard part is then done in the regular expression library
15:28:02krux02I would just need to test which subexpression actually matched.
15:28:04Araqor you use Lexim which uses the real algorithms, not the NP complete ones
15:28:12*endragor joined #nim
15:28:19krux02I think this regular expression joining is regularly done within emacs.
15:29:43krux02NP complete is an attribute of a problem, not an algorithm
15:30:01*endragor quit (Remote host closed the connection)
15:30:10krux02so just doing a different algorithm won't make NP complete to anything else
15:31:00Araqiirc it's only NP complete when you allow for backreferences
15:31:01krux02transforming a NFA into a DFA is potentionally exponential, because every state combination is possible.
15:31:13Araqwhich regexes usually do and lexer generators usually don't
15:32:06AraqNFA to DFA is exponential but it's done at compile-time and then you optimize the DFA to the bare mimimum
15:32:36krux02backreferences are not part of computer science regular expressions
15:32:44AraqNFA to DFA is only possilbe when you don't have backrefs nor submatches iirc
15:33:06Araqcomp-science regexes are totally unlike "real" regexes :P
15:35:07*themagician joined #nim
15:35:27krux02well I still don't think that as a programmer need to do anything but merging the expressions into a bigger expression and then let the regular expression library handle the rest.
15:35:55krux02It is not like that regular expression libraries haven't been around for decades reliably.
15:36:05Araqas I tried to tell you.
15:36:26Araqa regex library solves a slight different problem.
15:36:36Araq*slightly
15:41:29krux02well apart from that I think I kind of should finish the sizeof alignof thing in the compiler
15:41:37krux02there was quite some activity recently.
15:42:09krux02Not really helping at actually fixing any problems with it, but it showed people really want it.
15:42:13krux02Me included
15:42:25Araqyeah, go for it
15:42:58krux02For it to work correctly, I think I need a pragma for c2nim struct types.
15:43:20Araqwhy?
15:44:11rtardedCould somebody please tell me what this is? proc high*(x: string): int {.magic: "High", noSideEffect.} ... Calling it on a string gives me the index of the last element, but I don't understand how it's implemented
15:44:14krux02the problem that the tests are failing is the extreme rare use case of the tuple (float64,float32) on a 32bit architecture on a specific os, I don't know exactly which one it was.
15:45:07krux02rtarded, it just gives you the last element, when you want to find the implementation look for the string mhigh in the compiler or look at the generated C source code.
15:45:13krux02the implementation depends on the backend used.
15:45:13*crayon26 joined #nim
15:46:19*crayon26 quit (Killed (Sigyn (Spam is off topic on freenode.)))
15:46:19krux02Araq: the problem is, float64 does align on some platforms to just 4 bytes, even though on those platforms it should better be aligned to 8 bytes for performance reasons.
15:47:39*zhongfu14 joined #nim
15:47:59krux02the problem is, this exceptional adds a lot of complexity to be handled when in reality nobody really cares about it.
15:48:20*zhongfu14 quit (Remote host closed the connection)
15:48:31krux02there is a compier flag for gcc x86 that makes all float64 self aligned (8 bytes)
15:49:18krux02that would make dealing with all these weird special cases unnecessary.
15:49:30krux02the only problem is, interfacing with C structs
15:50:23krux02when a struct is from an actual C version ported over to nim and needs ABI, then the alignment should be like in C.
15:50:53krux02for those types I would then say at compile time "can't figure out alignment of C types"
15:50:56*vdamewood joined #nim
15:51:17krux02but that requires a tag for c2nim types
15:52:05*vdamewood quit (Remote host closed the connection)
15:52:45krux02another pragmatic approach would be to just put in the docs "in Nim all basic types are self aligned"
15:54:01krux02so when someone wants to use a C type with binary compatibility then it will probably just work because the difference is really a rare thing, But when it matters, they are in hell to find out about this difference
15:54:58*arecaceae quit (Remote host closed the connection)
15:55:16*arecaceae joined #nim
15:57:00rtardedGuys, is there a 'map' function that works on any iterable? string,seq, set, etc
15:58:44rtardedI guess not
15:58:51Araqkrux02, I fail to see the problem. we know what the C compiler does for the particular platform and need to follow it
15:59:02Yardanicortarded, mapIt ?
15:59:09Yardanicoah, any iterable
15:59:35Yardanicowell, you can create your own using concepts ;)
16:00:12rtardedYardanico, is there a "supertype" of all iterables?
16:00:54Yardanicortarded, there's not, but a lot of types have `items` proc defined
16:01:31Yardanicortarded, so you can create Iterable concept like that - https://github.com/Yardanico/nimpylib/blob/master/src/pylib.nim#L8
16:01:38Yardanico(items here is called implicitly)
16:01:39rtardedcan I create a method that only accepts (compile type) calls with objects that have items() defined?
16:02:00Yardanicoyes, but *proc (not method)
16:02:13Yardanicowith concepts you can do that
16:02:45rtardedoh, nice feature. Saw your code
16:02:49rtardedyeah, cool
16:02:59*basic`11 joined #nim
16:03:03rtardedty
16:03:04Yardanicoconcepts are compile-time only
16:04:02*tacocat16 joined #nim
16:04:51*basic`11 quit (Remote host closed the connection)
16:06:02*tacocat16 quit (Remote host closed the connection)
16:07:03*Notkea quit (Remote host closed the connection)
16:07:38*Notkea joined #nim
16:11:20rtardedYardanico. You seem to be really advanced in nim. If you don't mind, for how long have you been using the language?
16:13:02Yardanicortarded, well, I wouldn't say that I'm really advanced in the languagy (maybe only in some high-level parts), I've been actually using it since the start of 2017 but not always actively, so actually maybe 3-7 months of active usage
16:13:17rtardeddayum
16:13:41rtardedhow many years of programming experience (any lang) do you have?
16:14:57Yardanicortarded, I've been only using Python (for like 1 year, but not always actively) before I learned that Nim exists :)
16:15:09YardanicoI wouldn't say that I'm actually a pro in Nim
16:15:48rtardedNo, I was basically asking, how many years of programming experience you have in total (no just in nim or nim like langs)
16:16:45krux02Araq: I just relized I already implemented that stupid logic: https://github.com/krux02/Nim/blob/7a9419b409f77fd94781d8ced38fe629da3b260a/compiler/sizealignoffsetimpl.nim#L244
16:16:51krux02but then I don't know what is failing
16:17:08*LooCfur joined #nim
16:17:23Yardanicortarded, maybe 1 year of _actual_ programming experience in all languages :)
16:17:35rtardedthat's really impressive
16:17:39rtardednice
16:17:45Yardanicowell, nim is very simple :)
16:18:21Araqthat's not true. but you can safely use a simple subset
16:18:31Araqand more and more gotchas are eliminated.
16:19:40*LooCfur quit (Remote host closed the connection)
16:23:54rtardedyea, it's definitely not simple. It's got way too many concepts. It's much more complicated that anything I've toyed with (C#, Kotlin)
16:25:49Araqdunno about Kotlin but C# is a complex beast too, it's just exceptionally good at hiding its complexity
16:26:16Araqthe superior tooling definitely helps too
16:28:31Araqrtarded, what would you remove from Nim?
16:28:53Araq(THE question these days.)
16:29:13*moigagoo joined #nim
16:29:57Araqmoigagoo, what would you remove from Nim?
16:30:14rtardedI don't know enough about it to be able to answer that question, but I'm simply scared by the amount of features I've never seen in other languages: pragmas, templates, macros, concepts and more
16:30:15FromDiscord<treeform> I would remove the bugs 😃
16:30:45rtardedlol
16:30:52Araqtreeform: fair enough.
16:31:16Araqrtarded, pragmas are C#'s annotations
16:31:35Araqthe rest may indeed be new to you.
16:33:12*CC660 joined #nim
16:36:36Araqkrux02, good news, the GC can finally deal with the new nil/empty strings
16:36:58Araqso isNil can now be deprecated
16:38:25*CC660 quit (Ping timeout: 248 seconds)
16:38:28*moigagoo quit (Quit: Mutter: www.mutterirc.com)
16:41:02*xboner13 joined #nim
16:41:42*xboner13 quit (Killed (Sigyn (Spam is off topic on freenode.)))
16:46:46krux02you mean all instances of ``isNil``?
16:48:21Araqobviously not.
16:48:24krux02rtarded, the templates are very similar to ``macros`` in C, the generics are very similar to c++ templates, and macros, yea don't worry about it in the beginning it just enables great libraries to exist
16:48:28Araqthe isNil for strings and seqs
16:49:18krux02Araq: ``template isNil(x: string | seq): bool = false``
16:49:36Araqit's better to deprecate it
16:49:41Araqcode needs to be adapted
16:49:59krux02yes, that, too.
16:51:58rtardedty krux02, Araq
16:52:41rtardedGuys. Is there an == operator for custom types? Looked into system but I can only find one for primitive types. Where is the == that is called for seqs, arrays and custom types?
16:53:45*Tools1 joined #nim
16:55:06krux02yes there is
16:55:16krux02proc `==`*[T: tuple|object](x, y: T): bool =
16:55:36*Tools1 quit (Remote host closed the connection)
16:56:40rtardedyeah, the search function only showed the ones for primitive types for some reason
16:56:42rtardedsilly me
16:56:57*moigagoo joined #nim
16:58:27rtardedalso. How can I check if two vars point to the same heap object? THe == method seems to compare the fields
17:01:16*moigagoo quit (Client Quit)
17:03:20*stefanos82 joined #nim
17:06:42*nkelly joined #nim
17:09:39*nekits quit (Ping timeout: 260 seconds)
17:11:02krux02rtarded, they don't
17:11:11krux02object and tuple are not on the heap
17:11:37krux02rtarded, or ref and ptr types you can call ``==`` and that compares the memory location
17:12:11rtardedkrux02, and what if you want to compare the values of two ref type objects?
17:12:26krux02you can unref them with []
17:12:43rtardeda[] == b[]? Something like that?
17:12:47krux02yes
17:12:47*moigagoo joined #nim
17:12:49rtardedty
17:14:01*EastByte quit (Quit: WeeChat 2.0.1)
17:15:16krux02rtarded, something that comes up all the time, people want to prevent memory copies and pass an object type as a point to a function or something like that. Don't do that Nim does that automatically for yout.
17:15:44*EastByte joined #nim
17:16:52rtardedso you're saying that passing an int to a method that doesn't declare the param with var doesn't copy the value?
17:16:59rtardedweird
17:17:18*moigagoo quit (Client Quit)
17:18:16rtardedand also, is there any difference between proc x(y: ref int) and proc x(y: var int)?
17:18:38krux02an int is passed by valcue
17:18:40krux02value
17:18:53krux02yes there is a difference
17:19:20krux02ref int can only handle ints that are allocated on the heap
17:19:25krux02(gc heap)
17:20:55*Phanes joined #nim
17:20:59*avsej_ joined #nim
17:21:00*avsej_ quit (Changing host)
17:21:00*avsej_ joined #nim
17:21:10*avsej quit (Ping timeout: 240 seconds)
17:21:10*avsej_ is now known as avsej
17:22:27*Phanes quit (Remote host closed the connection)
17:24:59*rtard joined #nim
17:26:48*rtarded quit (Disconnected by services)
17:27:06*rtard left #nim (#nim)
17:27:18*rtarded joined #nim
17:27:23rtarded.
17:27:29rtardedkrux02
17:27:40rtardedhow can I create an int on the heap?
17:27:45rtardedvar nHeap: ref int = new(int(10))
17:27:50rtardedsomething like this doesn't work
17:28:23*shodan45 quit (Quit: No Ping reply in 180 seconds.)
17:28:23*federico3 quit (Ping timeout: 256 seconds)
17:28:26rtardedneither does this
17:28:27rtardedtype CoolInt = ref object of int
17:29:38rtardedthis worked: var nHeap: ref int = new(int)
17:29:38rtardednHeap[] = 200
17:29:51Araqyeah but it's bad. don't allocate ints on the heap
17:30:01Araquse a 'var' parameter if you need the mutability
17:30:09*shodan45 joined #nim
17:30:33Araqshodan45! SS3 is confirmed!
17:30:36*federico3 joined #nim
17:31:57*BitPuffin quit (Ping timeout: 240 seconds)
17:33:45rtardedI think i've found a bug
17:35:03FromGitter<kayabaNerve> If I have ⏎ Pointer -> C struct -> Pointer -> ref object ⏎ And I'm deleting the pointer of the struct (which I can't since other objects use it but the GC doesn't track that), but a memcopy doesn't cover the pointer in the struct, is my best bet to use GC_ref and GC_unref to manually add/remove references?
17:36:06FromGitter<kayabaNerve> Or a custom reference system since I don't care about the ref object but the pointer in the ref object?
17:36:33FromGitter<kayabaNerve> Currently I'm thinking custom, added ref on \`=\`, removed ref on destruction.
17:36:40rtardedAraq: is this expected? https://pastebin.com/bABGpbEN
17:37:11Araqrtarded, yes, refs are not vars
17:37:32rtardedI am confused
17:37:33Araqff2(nHeap[]) works
17:37:46rtardeddidn't I create a ref Animal and a ref int?
17:37:48*gangstacat quit (Ping timeout: 256 seconds)
17:37:49*Cthalupa quit (Ping timeout: 256 seconds)
17:37:57FromGitter<kayabaNerve> The function definition has var int though
17:38:02FromGitter<kayabaNerve> You have a var ref int
17:38:04rtardedin the first case, passing a ref Animal to the var method, it works
17:38:04*to joined #nim
17:38:20FromGitter<kayabaNerve> Because it's a ref object
17:38:27FromGitter<kayabaNerve> var Animal = var ref object
17:38:28*to is now known as Guest70117
17:38:48FromGitter<kayabaNerve> But you have var int when you're passing var ref int
17:38:56*leorize1 joined #nim
17:38:56*leorize quit (Ping timeout: 256 seconds)
17:38:59Araqproc ff2(num: var ref int) would work too
17:39:10Araqand resemble your 'printColor' definition
17:39:12*Cthalupa joined #nim
17:39:18*gangstacat joined #nim
17:39:27Araqit's 100% consistent.
17:40:12rtardedyou are right, it took me some time to understand my stupidity
17:40:17rtardedproc printColor(animal: var ref Animal) =
17:40:18rtardedyay
17:40:23rtardednow the call fails
17:40:28rtardedwhich is expected
17:40:29rtardedty
17:41:19rtardedalso, is there any difference between "new(Animal); a.color = "red"" and "Animal(color:"red")"?
17:41:29FromGitter<kayabaNerve> Nope
17:41:47Araqthe latter is much better for the compiler to reason about
17:43:11*BlaXpirit joined #nim
17:43:36*Amun_Ra quit (Ping timeout: 256 seconds)
17:43:36*oprypin quit (Ping timeout: 256 seconds)
17:43:37*BlaXpirit is now known as oprypin
17:44:01*Guest70117 quit (Ping timeout: 248 seconds)
17:44:34*Amun_Ra joined #nim
17:45:05*moigagoo joined #nim
17:48:11*Taylor7 joined #nim
17:48:18*moigagoo quit (Client Quit)
17:48:41*Taylor7 quit (Killed (Unit193 (Spam is not permitted on freenode.)))
17:49:41*PMunch joined #nim
17:53:37rtardedTy guys. Also: how is proc ff3(num: var ref int) different from proc ff1(num: ref int). proc ff2(num: var int) seems to let me update num, even though it might be on the stack. Is there any added benefit in ff3?
17:55:57Araqonly ff2 is idiomatic.
17:57:17rtardedyeah. That one seems to work as I would expect, with both stack and head allocated ints.
17:58:32rtardedbut obviously, I have to dereference the ref int in the call
17:59:14*xet7 quit (Quit: Leaving)
18:02:27*death916 quit (Ping timeout: 240 seconds)
18:04:30*Death916 joined #nim
18:07:41rtardedGuys: why does this work "proc init(): Animal =
18:07:41rtarded new(result)", but this doesn;t var a1 = new(Animal(color:""))
18:08:09Araqbecause 'new' is not at all as C#'s new
18:08:16Araq*like
18:09:50*Thanks joined #nim
18:09:57*krushia joined #nim
18:10:09rtardedit's a bit weird though. It seems that at that point (in the call), result is actually null, not an "empty" animal
18:10:17rtardedbut calling new(nil) fails
18:10:19*Thanks quit (Killed (Unit193 (Spam is not permitted on freenode.)))
18:10:59rtardedoh
18:11:01Araqwhat the heck would 'new(nil)' do?
18:11:25rtardedwhy should new(result) when result is nill work?
18:11:39rtardedI just saw that new actually takes a ref
18:11:48Araq'new' takes a 'var ref' :P
18:11:49rtardedso it probably cares about the type not of the
18:11:55rtardedvalue
18:12:00Araqit cares about both
18:13:28rtardeddoes it clone it if it's not nil?
18:14:35*krushia quit (Ping timeout: 240 seconds)
18:15:00rtardedanyway. I'm the fact that new(result) works and something like "var a1 = Animal(color:"")
18:15:01rtardeddiscard new(a1)" does not
18:15:28*moigagoo joined #nim
18:15:45rtardedor even "var a1: Animal= nil
18:15:45rtarded discard new(a1)"
18:17:01Araqthere is nothing to clone, new(x) sets x to a newly allocated heap object of the type of x
18:17:42Araqit takes a 'var ref T', so it mutates the ref pointer itself
18:17:52Araqand not what it may point to.
18:18:10*moigagoo quit (Remote host closed the connection)
18:18:36rtardedyou previous said that new also cares about the underlying value, not just about the type, so I guessed (wrongly) that if the value exist, it copies the fields
18:18:43Araqnew(x) is the same as x = type(x)()
18:19:16stefanos82Araq: is type(T) something like C++'s decltype(T)?
18:19:18Araqwell it cares about the value of the pointer as it needs it to overwrite it ... something like that
18:19:30rtardedanyways. If new (x) creates a new object based on the type of x, shouldn't "var a1: Animal= nil
18:19:30rtarded; discard new(a1)" (outside of proc) also work?
18:19:30Araqstefanos82, also known as 'typeof' yes
18:19:40stefanos82yep, like GCC's typeof() extension
18:20:08Araqrtarded, 'discard new(a1)' should not work as 'new' does not return anything that could be discarded
18:20:38rtardedAraq: var a2 = new(a1) then, but it still fails to compile
18:21:21rtarded"expression new(a1) has no type or is ambiguous"
18:21:43rtardedfor var a2:Animal = new(a1), same err
18:21:51Araqsame err, same reason
18:22:12Araq'new' doesn't return a value it mutates the pointer you pass to it
18:22:26Araq(except for the other variant of 'new' that we will deprecate)
18:22:44rtardedlmao. I finally understand what you are tying to say. Srry (check out my nickname)
18:24:06Araqif it helps you, I can tell you, you are not retarded.
18:24:42Araq'new' is a confusing beast at first, coming from Delphi and not from C++, C#, Java...
18:26:10*moigagoo joined #nim
18:30:37*moigagoo quit (Client Quit)
18:32:04krux02Araq: I currently resolve merge conflics for sizeof alignof branch, this is something i noticed: http://ix.io/1jbE
18:32:26krux02or a bit more contexthttp://ix.io/1jbF
18:32:42krux02did the assignment node change?
18:33:16*yglukhov[i] joined #nim
18:33:29krux02can an assignment be something be a different symbol than `=`?
18:33:51krux02wasn't it even that the nnkAsgn doesn't even list the assignment symbol, it just has two children?
18:42:33*moigagoo joined #nim
18:47:05*bthesorceror joined #nim
18:47:54*moigagoo quit (Remote host closed the connection)
18:56:10Araqwell nkAsgn is not mAsgn
18:56:40AraqnkAsgn has 2 children, mAsgn in the assignment operator `=`(a, b)
18:56:46Araqand so would have 3 children
18:59:33*smt_ quit (Ping timeout: 244 seconds)
18:59:39krux02Araq: is there another assignment operator than `=`?
18:59:57*bthesorceror quit (Ping timeout: 240 seconds)
19:01:49*yglukhov[i] quit (Remote host closed the connection)
19:02:43*clyybber joined #nim
19:02:51Araqkrux02, it has 2 different representations
19:03:05Araqa "call of the '=' operator" representation
19:03:18Araqand then the 'a = b' assignment nkAsgn
19:03:43Araqsame is true for overloaded [], []= operators
19:04:53FromGitter<imdaveho> hi all, trying to use the terminal from stdlib to create a similar lib as termbox, just two quick questions after toying around...1) can't seem to specify the color to print out with writeStyled, and even without passing in a style, the text output is black not white...2) does getch() also handle modifer keys like shift, alt, and ctrl?
19:09:36Araqsorry, I don't know
19:11:47clyybberAraq Would it make sense to implement generic procs as syntactic sugar for typedescs?
19:11:54*rtarded quit (Quit: Leaving)
19:12:02*rtarded joined #nim
19:12:11*rtarded quit (Client Quit)
19:12:39*yglukhov[i] joined #nim
19:12:50Araqwhat do you mean?
19:13:25*Jesin quit (Remote host closed the connection)
19:15:06*clyybber quit (Quit: good night)
19:15:16*endragor joined #nim
19:16:39*clyybber joined #nim
19:17:07*moigagoo joined #nim
19:19:47*moigagoo quit (Client Quit)
19:20:02*kungtotte joined #nim
19:20:50*ozy1 joined #nim
19:20:57*clyybber quit (Ping timeout: 240 seconds)
19:21:54*rtarded joined #nim
19:22:13rtardedGuys. Is there an universal way for listing all of the running processes?
19:23:10rtarded* not those started via Nim
19:23:20rtardedos process list
19:23:30rtardedsomething like ps in linux
19:23:57*ozy1 quit (K-Lined)
19:28:32FromGitter<rayman22201> @krux02 thanks for working on the alignof
19:28:43FromGitter<rayman22201> I'm excited about that pr
19:33:46Araqrtarded: nah, that's beyond the stdlib's reach
19:33:55rtardedok
19:55:30*clyybber joined #nim
19:55:52*kaushalmodi joined #nim
19:59:06FromGitter<Bennyelg> (https://files.gitter.im/nim-lang/Nim/SIHa/image.png)
19:59:43krux02rtarded, to list all running processes just run "ps -aux" on the terminal
19:59:47FromGitter<Bennyelg> (https://files.gitter.im/nim-lang/Nim/mDmv/image.png)
19:59:55FromGitter<Bennyelg> niming for fun
20:00:11clyybberAraq I mean the idea that "proc foo[T](a: T)" gets transformed to "proc foo(T: typedesc, a: T)"
20:00:30rtardedkrux02, yes I know. I was looking for a Nim way of getting a list of osproc.Process instances, no matter the platofrm
20:00:34krux02clyybber, why would you want that?
20:00:35clyybberAnd if it would make sense to implement generics for procs that way
20:01:05krux02rtarded, Windows has a linux subsystem now, doesn't it?
20:01:21krux02well my hint is probably not very useful
20:01:35krux02clyybber, why?
20:01:36rtardedyes, but I want to list the Windows processes, not those in Ubuntu
20:01:48clyybberI thought it would make the generics implementation for procs easier.
20:01:54krux02I don't know
20:02:02rtardedanyway. I'll use tasklist in Windows, and parse it via regex
20:02:08krux02all programming I did on windows was Basic
20:02:17krux02ok not entirely true, but generally
20:02:51clyybberkrux02 I thought it would make the implementation of generic procs simpler
20:03:10krux02clyybber, well I don't think so at all
20:03:38clyybberYeah thats why I am asking, because I have no idea if thats a good idea
20:03:47krux02I think it is better if you treat the type T not as a value expression.
20:04:01krux02clyybber, probably not
20:04:45krux02``proc foo[T](a: T)`` is something I understand, ``proc foo(T: typedesc, a: T)`` seems very obscure to me
20:05:11krux02typedesc are generic, too
20:05:23krux02they have a hidden generic argument
20:05:36krux02so if you want the typedescriptor, it is internally something like this
20:05:53krux02``proc foo[T](t: typedesc[T], a: T)``
20:06:05krux02I don't see where that helps you anywherer at all.
20:06:25clyybberI see, it doesn't
20:06:45rtardedGuys: is there an easy way of consuming an iterator? Looking for something other that a "for loop" solution if possible. myIt().items() doesn't work
20:07:10clyybberkrux02 How are procs with multiple typedesc arguments represented internally
20:07:12clyybber?
20:07:30krux02clyybber, with multiple generics
20:08:27krux02rtarded, iterators are consumed with a for loop, that is what they are there for. But you write a template/macro that generates the for loop for you if you prefer that.
20:08:44clyybberkrux02 So in essence typedescs are kind of syntactic sugar for generics?
20:08:49rtardedWent for the loop solution. Ty
20:09:02krux02clyybber, ``proc foo[A,B](a: typedesc[A], b: typedesc[B])``
20:09:17krux02clyybber, not really
20:09:35krux02not at all I would rather say
20:10:03krux02typedesc are one of the weakly designed parts of the Nim language, so it would be nice if you try to avoid them as much as you can.
20:10:36krux02what I think typedesc arguments are good far are cases where you want to map from type to some value at compile time
20:10:41krux02then you can write a template
20:10:50*FromGitter quit (Remote host closed the connection)
20:10:56clyybberkrux02 I see
20:11:05*FromGitter joined #nim
20:11:16krux02``template typeattribute(_ : typedesc[int]): string = "it is an int"``
20:11:49krux02``template typeattribute(_ : typedesc[float]): string = "wow, it is a float impressive"``
20:12:13Araqthey are not weakly designed, but they are super subtle
20:12:15krux02then you can get the typeattribute with typeattribute(int)
20:12:24krux02or typeattribute(type(myvar))
20:12:26Araqin fact, I often don't know what to do with them :P
20:12:34Araq"cannot interpret ..."
20:12:44clyybberkrux02 Can we say that "proc foo(a: typedesc)" is syntactic sugar(/salt) for "proc foo[A](a: typedesc[A])" ?
20:13:00krux02clyybber, yes
20:13:25krux02you can do that generally in Nim
20:13:30krux02not just with typedesc
20:13:35clyybberkrux02 Ok thank you. I think this is implemented very elegant then
20:13:49krux02but I prefer to write the generic argument
20:14:24*Guest65578 joined #nim
20:14:35clyybberkrux02 Yeah it differentiates types from actual values, i guess thats good
20:15:20*xylef joined #nim
20:15:47clyybberAraq What do you mean with "cannot interpret ..."?
20:16:12*Guest65578 quit (Read error: Connection reset by peer)
20:16:42Araqit's a famous bug error message
20:19:26*kungtotte quit (Quit: leaving)
20:20:43*endragor quit (Remote host closed the connection)
20:22:34*bthesorceror joined #nim
20:22:47krux02Araq: how do I get a ContextRef from a PContext?
20:23:58rtardedGuys. Is import osproc supposed to fail in "nim secret"?
20:24:46krux02rtarded, nim secret is a secrat
20:24:50krux02so nothing is supported
20:24:57rtardedokay
20:25:10krux02be lucky if something works
20:31:50FromGitter<kayabaNerve> Can I overload `=` for a ref object or assign a custom destructor/finalizer to an object?
20:37:29*Vladar quit (Remote host closed the connection)
20:37:56*Vladar joined #nim
20:38:53*yglukhov[i] quit (Read error: Connection reset by peer)
20:39:09krux02kayabaNerve: well better if you don't do it
20:39:28krux02it is again one of the weaker things in Nim.
20:39:41*yglukhov[i] joined #nim
20:40:07krux02it is better if you design your types in a way thet the default assignment works, and that you don't need spcial finalizers.
20:42:11*rockcavera quit (Remote host closed the connection)
20:43:07FromGitter<kayabaNerve> ... I can't? It's a wrapper.
20:44:12FromGitter<kayabaNerve> I solved my ref/destroy issue. Now I'm stuck with `cannot bind another '=' to: BN`
20:45:20*xet7 joined #nim
20:46:29FromGitter<kayabaNerve> BN is an `object` defined in that file. It has no other `=` defined anywhere. The function definition is: `proc \`=\`*(x: var BN, y: BN) =`
20:47:40rtardedDoes anybody know how to install the pcre (for regex) dll? Where should I place is so that the nim compiles sees it by default?
20:47:44rtardedWindows*
20:48:14FromGitter<kayabaNerve> Next to the EXE or in your OS folders?
20:48:49rtardedright, but is it possible to somehow include the necessary code in the ninm executable? Static linking?
20:49:48rtardedwell, I tried copying the dll in mingw's bin folder. I'm not getting the expected results
20:50:04*Sentreen quit (Ping timeout: 256 seconds)
20:52:49FromGitter<kayabaNerve> 1) That's not the right place at all. ⏎ 2) I'm pretty sure you can't static link a DLL at compile time. ⏎ 3) There are some ways to do it afterwards but not easily. ⏎ 4) This isn't why DLLs exist. ⏎ 5) If you don't use a DLL but instead compile the source into a .a, you can easily. [https://gitter.im/nim-lang/Nim?at=5b66122185278d705e85cb66]
20:56:53*iDanoo12 joined #nim
20:59:28*f17 joined #nim
21:00:17*craigger quit (Quit: bye)
21:00:22*f17 quit (Remote host closed the connection)
21:00:22*iDanoo12 quit (Remote host closed the connection)
21:00:41*craigger joined #nim
21:07:33*ng0 joined #nim
21:12:39*Vladar quit (Remote host closed the connection)
21:12:59*brainproxy quit (Quit: WeeChat 2.2)
21:16:51*Sentreen joined #nim
21:18:09FromGitter<mratsim> @krux02 Personally, I care about aligning float32 to 8 bytes, and Intel also recommends it for efficient tensor and matrix computations: https://github.com/mratsim/Arraymancer/issues/102
21:20:32rtardedGuys. How do you refer to methods, types in documentation comments?
21:21:19FromGitter<mratsim> I don’t understand? You mean link to something? doc comments use .rst formatting
21:21:46rtardednevermind. found an example online: ## a short form for ``re(r"[abc]")``.
21:23:21*ng0 quit (Quit: Alexa, when is the end of world?)
21:24:52krux02mratsim: well if you want to align float32 to 8 bytes I think you better put in padding bytes
21:25:22krux02rtarded, I usually do ``procname``.
21:25:55krux02but be aware the procname alone is not uniquely identifying.
21:26:40FromGitter<mratsim> @krux02, I need to be able to align tensors of millions of float32
21:27:05FromGitter<mratsim> i.e. seq\[float32\] as a backend
21:28:52*ksft28 joined #nim
21:29:11rtardedGuys. is there something like nameof() in Nim? Method that returns the name of a variable, class, method
21:29:24rtardednameof(int) -> "int"
21:29:31rtardedso that it aids in refactoring
21:30:06*ksft28 quit (Killed (Unit193 (Spam is not permitted on freenode.)))
21:32:06rtardedmore like nameof(someCustomProc)
21:33:17*geocar quit (Quit: Connection closed for inactivity)
21:33:20rtardedcool
21:33:28rtardedfound name in typetraits
21:33:28FromGitter<mratsim> I’m pretty sure you are trying a dynamic typing idoms here where it is not needed
21:33:35FromGitter<mratsim> name is for types only
21:33:40rtardedoh
21:33:44rtardedyea
21:33:47rtardedgood enough
21:33:54rtardedis there any for other constructs?
21:34:08*nsf quit (Quit: WeeChat 2.2)
21:34:22rtardedC# has it, and it's statically typed
21:34:28rtardedand compile time
21:34:46*NimBot joined #nim
21:34:49FromGitter<mratsim> in a macro you can use $x to print an ident
21:35:09FromGitter<mratsim> (i.e. the symbol of anything, variable, type, proc)
21:35:44rtardedhaven't looked into macros yet. will probably look into them tomorrow. I was actually looking for a simple, built in function to achieve this. Ty though
21:36:07FromGitter<mratsim> That’s called reflection iirc, and really it’s probably not needed
21:37:22FromGitter<mratsim> you can use fields and fieldpairs as well to access the field of an object via an iterator
21:40:37krux02seq[float32] is always 4 byte aligned
21:40:53krux02mratsim: why do you want float32 to be 8 byte aligned?
21:41:08FromGitter<mratsim> because it is faster
21:41:38krux02rtarded, there is instanciation info for macros
21:42:06krux02mratsim I don't think so, it would mean that you would waste 50% of the memory
21:42:31krux02so you might end up being memory mound
21:42:33krux02bound
21:43:45FromGitter<mratsim> no, I mean, the first float should start on a 8 byte boundary
21:43:51rtardedDoes anybody know why: assert running("notepad.exe").not() works but assert not(running("notepad.exe")) does not?
21:43:52FromGitter<mratsim> then everything else is packed
21:44:06krux02mratsim: that is something that works by default
21:44:18krux02allocation is done in blocks and those are bigger than 8 bytes
21:44:57rtardedfull code: https://pastecode.xyz/view/642d69f7
21:45:26FromGitter<mratsim> Are you sure Nim is not aligning seq\[T\] to sizeof T boundaries?
21:46:44rtardednvm. I'm a moron
21:47:35krux02so it is not aligning to sizeof(T) boundaries, pretty sure
21:49:05krux02when you allocate a seq, the heap data will contain some pointer sized capacity at the beginning and after that it will start with your data
21:49:38krux02there might come some padding though, depending on the alignment value of T
21:50:16krux02so for simd instructions you even might need higher alignment values than 8 bytes
21:51:02krux02if you have such data there will be additional padding
21:53:10krux02alignof(T) ≤ sizeof(T). always
21:53:17krux02unless you are in glsl land
22:02:16*Trustable quit (Remote host closed the connection)
22:05:34*kaushalmodi quit (Quit: Connection closed for inactivity)
22:05:52rtardedGuys. Is it possible to debug Nim code? Preferably in VSCODE
22:06:11rtardedI'm unable to add breakpoints
22:06:16rtardedthe Nim extension is installed
22:07:44*khronosschoty27 joined #nim
22:08:13rtardednot properly supported yet: https://github.com/pragmagic/vscode-nim/issues/65
22:08:14rtarded:(
22:09:05*khronosschoty27 quit (Read error: Connection reset by peer)
22:10:02Calinouyeah, I use print statement debugging
22:14:34zacharycarter[m]Most get along fine w/ gdb / lldb
22:15:46*rtarded quit (Quit: Leaving)
22:17:10*yglukhov[i] quit (Remote host closed the connection)
22:17:59*yglukhov[i] joined #nim
22:19:25FromGitter<zetashift> @rtarded maybe this could help? https://nim-lang.org/blog/2017/10/02/documenting-profiling-and-debugging-nim-code.html#debugging-nim-code
22:21:50*brynjar7 joined #nim
22:22:26*yglukhov[i] quit (Ping timeout: 256 seconds)
22:22:50*brynjar7 quit (Remote host closed the connection)
22:32:54zacharycarter[m]figured out a minimal example for one of my issues
22:33:29zacharycarter[m]https://gist.github.com/zacharycarter/e44274861f211bb2345d4fb2a1bd87a6
22:35:10krux02I try to run the test tsizeof in Nim and I get an error in some parseJson
22:35:17krux02wtf?
22:35:56zacharycarter[m]wnt me to try?
22:35:59zacharycarter[m]is it in devel?
22:41:00*PMunch quit (Quit: leaving)
22:42:52*vok`2 joined #nim
22:47:02krux02ok I got the problem
22:47:15krux02still weird bug
22:47:30krux02the test did not compile and the error messages had nothint to do with it.
22:47:36krux02zacharycarter[m], but thanks for the offer
22:49:04*vok`2 quit (Ping timeout: 256 seconds)
22:49:40zacharycarter[m]np
23:33:54*Pugabyte6 joined #nim
23:40:04*Pugabyte6 quit (Ping timeout: 256 seconds)
23:40:50krux02Araq: ast.SpecialSemMagics isn't used anywhere in the compiler, can I just delete it?
23:48:14*xet7 quit (Quit: Leaving)
23:51:47*was joined #nim
23:53:26*was quit (Remote host closed the connection)
23:56:52*kaushalmodi joined #nim