<< 06-12-2015 >>

00:25:21*shodan45 joined #nim
00:33:40*irrequietus quit ()
00:33:44*joelmo quit (Quit: Connection closed for inactivity)
00:39:35*juanfra quit (Quit: juanfra)
00:43:28*juanfra joined #nim
00:46:46*Trustable_2 quit (Quit: Leaving)
01:00:31*jakesyl quit (Ping timeout: 260 seconds)
01:05:38*jaco60 quit (Ping timeout: 260 seconds)
01:12:56*jakesyl joined #nim
01:45:55*lokulin quit (Changing host)
01:45:55*lokulin joined #nim
02:04:10*yglukhov joined #nim
02:08:29*yglukhov quit (Ping timeout: 246 seconds)
02:12:22*vendethiel quit (Ping timeout: 260 seconds)
02:16:56*pregressive joined #nim
02:34:30*vendethiel joined #nim
02:35:16*nicktick joined #nim
02:38:01cryzedIs it just me or does nre not behave properly with anonymous capturing groups
02:38:10cryzedthey show up in the RegexMatch.captures but really shouldn't
02:38:51cryzedah nevermind, they don't
02:46:42*pregressive quit (Remote host closed the connection)
02:48:54*theduke quit (Ping timeout: 245 seconds)
02:55:44*vendethiel quit (Ping timeout: 246 seconds)
03:03:05*theduke joined #nim
03:06:59*nicktick quit (Ping timeout: 260 seconds)
03:09:22*Demon_Fox joined #nim
03:15:00*bjz quit (Quit: My MacBook Pro has gone to sleep. ZZZzzz…)
03:17:08*bjz joined #nim
03:33:53*makoLine quit (Ping timeout: 246 seconds)
04:23:59*ephja quit (Ping timeout: 260 seconds)
04:51:35*makoLine joined #nim
04:58:03*makoLine quit (Ping timeout: 260 seconds)
05:01:25cryzed:)
05:14:30*makoLine joined #nim
05:33:20*darkf joined #nim
05:40:09*yglukhov joined #nim
05:44:26*yglukhov quit (Ping timeout: 246 seconds)
05:47:33*bjz quit (Quit: My MacBook Pro has gone to sleep. ZZZzzz…)
05:48:52*bjz joined #nim
05:53:58*zepolen joined #nim
06:04:48*gunn quit (Quit: My Mac has gone to sleep. ZZZzzz…)
06:36:09*desophos quit (Read error: Connection reset by peer)
06:41:29*gunn joined #nim
06:53:46*pregressive joined #nim
07:39:05*bjz quit (Quit: My MacBook Pro has gone to sleep. ZZZzzz…)
07:42:04*bjz joined #nim
07:58:23*shodan45 quit (Quit: Konversation terminated!)
08:00:59*pregressive quit (Remote host closed the connection)
09:02:07*gmpreussner|work quit (Read error: Connection reset by peer)
09:06:54*Demon_Fox quit (Quit: Leaving)
09:21:38*yglukhov joined #nim
09:26:18*zepolen quit (Remote host closed the connection)
09:35:31*Arrrr joined #nim
09:41:13*yglukhov quit (Remote host closed the connection)
09:49:05*makoLine quit (Ping timeout: 246 seconds)
09:57:08*Matthias247 joined #nim
09:58:04*girvo_ joined #nim
09:59:25*BlaXpirit quit (Quit: Bye)
10:00:12*BlaXpirit joined #nim
10:16:24*girvo_ quit (Quit: leaving)
10:26:55*zepolen joined #nim
10:31:47*zepolen quit (Ping timeout: 246 seconds)
10:41:50*yglukhov joined #nim
10:46:08*yglukhov quit (Ping timeout: 246 seconds)
10:48:44*joelmo joined #nim
10:51:05*vendethiel joined #nim
10:58:23*bjz quit (Ping timeout: 246 seconds)
11:00:32*bjz joined #nim
11:05:12*bjz quit (Max SendQ exceeded)
11:05:58*bjz joined #nim
11:20:15*BitPuffin|osx quit (Ping timeout: 260 seconds)
11:23:06*jaco60 joined #nim
11:28:07*zepolen joined #nim
11:32:51*zepolen quit (Ping timeout: 260 seconds)
12:08:19*vendethiel quit (Ping timeout: 260 seconds)
12:12:07*yglukhov joined #nim
12:16:20*boopsiesisaway is now known as boopsies
12:17:29*Matthias247 quit (Read error: Connection reset by peer)
12:29:13*zepolen joined #nim
12:33:59*zepolen quit (Ping timeout: 260 seconds)
12:51:43*ephja joined #nim
12:59:44*jakesyl quit (Ping timeout: 245 seconds)
13:08:05*Jesin quit (Quit: Leaving)
13:13:16*jakesyl joined #nim
13:29:56*irrequietus joined #nim
13:30:12*zepolen joined #nim
13:36:02*jaco60 quit (Ping timeout: 260 seconds)
13:41:28*heinrich5991_ joined #nim
13:42:32*FreeDog joined #nim
13:42:54*bigfondue_ joined #nim
13:43:02*someplace quit (Ping timeout: 240 seconds)
13:43:02*huonw quit (Ping timeout: 240 seconds)
13:43:02*M-Quora quit (Ping timeout: 240 seconds)
13:43:03*heinrich5991 quit (Ping timeout: 240 seconds)
13:43:04*r-ku quit (Ping timeout: 240 seconds)
13:43:04*flyx quit (Ping timeout: 240 seconds)
13:43:04*avsej quit (Ping timeout: 240 seconds)
13:43:05*LibreWulf quit (Ping timeout: 240 seconds)
13:43:05*bigfondue quit (Ping timeout: 240 seconds)
13:43:27*heinrich5991_ is now known as heinrich5991
13:45:03*M-Quora joined #nim
13:45:16*vendethiel joined #nim
13:45:20*huonw joined #nim
13:46:00*zepolen quit (Remote host closed the connection)
13:46:16*r-ku joined #nim
13:48:56*jaco60 joined #nim
13:49:22*someplace joined #nim
13:58:26*avsej joined #nim
13:58:27*avsej quit (Changing host)
13:58:27*avsej joined #nim
13:58:38*nicktick joined #nim
14:05:36*lazypenguin quit (Ping timeout: 264 seconds)
14:09:02*lazypenguin joined #nim
14:11:58*DecoPerson quit (Ping timeout: 260 seconds)
14:12:06*yglukhov quit (Remote host closed the connection)
14:12:11*huonw quit (Ping timeout: 264 seconds)
14:13:12*yglukhov joined #nim
14:13:44*joelmo quit (Quit: Connection closed for inactivity)
14:14:24*DecoPerson joined #nim
14:15:42*jaco60 quit (Ping timeout: 260 seconds)
14:17:32*yglukhov quit (Ping timeout: 246 seconds)
14:18:38*huonw joined #nim
14:22:09*Jesin joined #nim
14:23:24*vendethiel quit (Read error: Connection reset by peer)
14:24:38*vendethiel joined #nim
14:26:36*clone1018 quit (Ping timeout: 264 seconds)
14:27:04*clone1018 joined #nim
14:30:15nicktickhow to convert string into number?
14:32:16*jaco60 joined #nim
14:34:41cryzednicktick, http://nim-lang.org/docs/strutils.html#parseInt,string
14:36:08*flyx joined #nim
14:36:38cryzedhttps://gist.github.com/cryzed/1728d8a1396e710f7f21 Is it possible to do this somehow, without getting "redefinition of children"ß
14:37:09cryzedI don't get why it's redefined, the nkRootNode and nkParagraphNode cases should never exist at the same time, and I don't want to make children the default for all of them
14:47:03*boopsies is now known as boopsiesisaway
14:57:05Arrrryou have no choice other than use different names, like rnChildren, pnChildren
14:58:00ArrrrIt is the way is implemented, who knows if maybe in they future it is changed
14:58:53ArrrrI suppose it is to avoid conflicts. What if the first children is defined as a different kind of seq
14:59:29cryzedArrrr, in the documentation it says one is simply not allowed to change identifier if I leads to a branch change
14:59:36cryzedso that shouldnt be an issue
14:59:45ArrrrThe point of case objects is that they are fast and needs little runtime checking. Otherwise you can use inheritance
15:00:00cryzedI suppose that's a good idea
15:00:23cryzedone more Question. I can do "echo node.kind" to get a string representation of my enum value
15:00:31cryzedI am trying to do this manually with $(node.kind)
15:00:37cryzedbut it returns Node instead of the string
15:00:53cryzeddo you have an idea on how to get this string representation manually?
15:01:07*kulelu88 joined #nim
15:01:08*kulelu88 quit (Changing host)
15:01:08*kulelu88 joined #nim
15:01:33Arrrrwhat do you mean exactly, what does it return and what do you expect to retur
15:02:03cryzedArrrr, echo nkTextNode prints "nkTextNode"
15:02:19cryzedI want to store this string representation in a string variable
15:02:33cryzedlet a: string = $(myNode) does not work
15:03:01cryzedArrrr, https://gist.github.com/cryzed/63d95a09a32f5a18988a currently doing this
15:04:21ArrrrStill i dont dont see what the problem is, maybe a little snippet with your problem would help
15:04:41ArrrrError? returns a different string?
15:04:48cryzedone second
15:06:00cryzederror: http://i.imgur.com/6CE7eZX.png for https://gist.github.com/cryzed/63d95a09a32f5a18988a
15:06:32cryzedah
15:06:35cryzedI was missing a parenthesis
15:06:41cryzedecho(($(root.kind)).indent(currentIndentation, " "))
15:06:41cryzed works
15:06:50Arrrrheh
15:07:07cryzed:)
15:21:58cryzedhttp://i.imgur.com/ns5HhQE.png
15:22:01cryzedlooks good :)
15:23:27*yglukhov joined #nim
15:23:35*theduke quit (Ping timeout: 264 seconds)
15:24:41ArrrrWhat is it for
15:25:47Arrrr?
15:27:10*boopsiesisaway is now known as boopsies
15:27:53*yglukhov quit (Ping timeout: 246 seconds)
15:30:24*CARAM__ quit (Read error: Connection reset by peer)
15:30:52*CARAM__ joined #nim
15:34:32*zepolen joined #nim
15:35:41*theduke joined #nim
15:39:50cryzedArrrr, sorry
15:39:56cryzedIt's my attempt at a markdown parser
15:40:07cryzedI want to first tokenzie the document, then lex it into an AST
15:40:17cryzedAnd then create writer procs that work on the AST to output customized formats
15:40:20cryzedsuch as HTML primarily
15:40:39cryzedJust to get more familiar with Nim, ASTs etc. which I've never really used before
15:44:58ArrrrGood idea
15:47:42cryzed:), well let's see if my approach is too naive
16:02:22*yglukhov joined #nim
16:15:32*gmpreussner|work joined #nim
16:42:10*pregressive joined #nim
16:45:13*pregressive quit (Remote host closed the connection)
16:49:14*vendethiel quit (Ping timeout: 260 seconds)
16:50:27*sepisoad joined #nim
16:51:12*pregressive joined #nim
16:59:51cryzedhttps://gist.github.com/cryzed/48f8049eb1b317f83e28 part of my lexer looks like this
17:00:11cryzeddo I really always need to manually "cast" interpret my Node subclass as the specific subclass to access subclass-specific attributes?
17:04:52*pregressive quit (Remote host closed the connection)
17:13:51*vendethiel joined #nim
17:15:35ArrrrFrom Node to SubNode? Yes, but you should use methods
17:15:56Arrrrmethod add(n: Node) {.base.} = discard
17:16:11Arrrrmethod add(n: ParagraphNode) = n.children add whatever
17:16:30cryzedah
17:16:31Arrrrin this case method add(n: Node, child: Node)
17:16:44cryzedthat would be much easier, yes. Like pattern matching in haskell -- or well, whatever it was called
17:17:53federico3the socket module is deprecated. Should httpserver be ported to Net?
17:17:59dom96I would personally use a variant object.
17:18:09dom96federico3: httpserver should be deprecated if it isn't already
17:18:17federico3why? :(
17:18:34dom96because it sucks :P
17:18:47*jakesyl quit (Remote host closed the connection)
17:19:14*ephja quit (Quit: WeeChat 1.3)
17:19:50cryzeddom96, that's what I had, but not all object variants really have need for a children attribute
17:19:53cryzedshould I just not care about that?
17:20:54dom96what do you mean?
17:21:20dom96You can just create a 'children' field under the variant kinds you want.
17:23:39federico3well, while it's still around - https://github.com/nim-lang/Nim/pull/3624
17:24:53cryzeddom96, if I do it tells me that I can't redefine the children field
17:25:06cryzed<cryzed> https://gist.github.com/cryzed/1728d8a1396e710f7f21 Is it possible to do this somehow, without getting "redefinition of children"ß
17:25:06cryzed<cryzed> I don't get why it's redefined, the nkRootNode and nkParagraphNode cases should never exist at the same time, and I don't want to make children the default for all of them
17:26:20dom96ahh, yeah. That should really be fixed in the language to allow it. In this case the only solution is to name the second 'children', 'children2' or something.
17:26:33ArrrrYou can use different names, i told you to use as an example rnChildren and pnChildren
17:27:20cryzedyes, but that would completely destroy the "API" of the object
17:27:36dom96federico3: Developing sockets or httpserver further is pointless.
17:27:55dom96cryzed: You can define a custom `children` accessor and setter
17:28:06federico3it's a first step to implement SO_REUSEPORT in the other modules as well
17:28:18federico3also httpserver is not officially deprecated yet
17:28:22cryzeddom96, so for each variant type have a custom children proc that gets/sets the value?
17:28:33dom96proc children(n: Node): seq[Node] = if n.kind == nkRootNode: n.rnChildren else: ...
17:28:47dom96better yet, use a case statement there too
17:28:56cryzedyep, ok
17:29:27dom96federico3: 'sockets' is though. Please implement it in 'net'/'asyncnet'
17:29:52Arrrri think inheritance is better suited for the task. There is a clearer distinction between api and implementation
17:30:08federico3but httpserver still uses sockets so I started from it. I'm looking at porting it to net and asynchttpserver as well
17:30:15ArrrrBut case objects are good too
17:32:03dom96I disagree. Variant objects are perfectly suited for a Node type.
17:35:57*Trustable joined #nim
17:36:01cryzeddom96, what exception would be the most appropriate to raise if the children accessor is called on a type that doesn't have the attribute?
17:37:36dom96InvalidValue
17:38:15cryzedthanks
17:38:41*makoLine joined #nim
17:42:11*lokulin quit (Ping timeout: 264 seconds)
17:43:50*gsingh93 quit (Ping timeout: 260 seconds)
17:47:31*makoLine quit (Read error: Connection reset by peer)
17:48:20cryzeddom96, how are procs prioritized? When I use node.children instead of children(node) it attempts to use the field accessor declared in the type I think
17:50:02dom96I'm not sure what the priority is, I would think that the compiler would give an ambiguity error in that case.
17:50:13dom96You should rename the field in any case
17:50:35*BitPuffin|osx joined #nim
17:50:58*gsingh93 joined #nim
17:52:45*lokulin joined #nim
17:53:25cryzeddom96, <dom96> You should rename the field in any case
17:53:27cryzedoops
17:53:33cryzeddom96, https://gist.github.com/cryzed/4c0862147810bc76cb13 I ended up doing this
17:53:50*sepisoad quit (Ping timeout: 246 seconds)
17:53:58cryzedcalled it internalChildren since _ isnt valid for identifiers (strange decision)
17:55:02dom96good. :)
17:55:09*nicktick quit (Quit: Leaving.)
17:55:57cryzeddom96, why isn't compiler in the stdlib? It bit me several times in the ass and I had to pass --path manually
17:56:24dom96it's a nimble package
17:56:49cryzedbut it's also distributed with nim?
17:57:24dom96is it distributed in the Windows installer?
17:57:31cryzedit is
17:57:59dom96I suppose we could make it a part of the stdlib
17:58:10dom96Create an issue please :)
17:58:15cryzedI will
18:04:23*makoLine joined #nim
18:04:39*desophos joined #nim
18:05:37cryzeddom96, https://github.com/nim-lang/Nim/issues/3625
18:05:38cryzedgood?
18:06:26dom96yeah, thanks
18:06:35cryzedNo problem
18:13:20*darkf quit (Quit: Leaving)
18:22:52cryzedDo I also create an issue for theduke case kind: NodeKind "redefine" problem?
18:22:56cryzed*the
18:30:44cryzedWhen I don't want to run my accessor for children twice, i.e. store the result somewhere -- how do I go about just storing the reference. I noticed when doing var myChildren = node.children that it stores a copy of the children apparently (since when modifying that instance it doesn't modify the tree)
18:32:28Araqreturn 'var T' or make the accessor a template
18:33:56cryzedmy children accessor returns var seq[Node]
18:34:13cryzedoh wit
18:34:15cryzedwait
18:35:18cryzednope it does, one second: https://gist.github.com/cryzed/4c0862147810bc76cb13 See: https://gist.github.com/cryzed/4c0862147810bc76cb13 and https://gist.github.com/cryzed/4c0862147810bc76cb13
18:35:31cryzedwhen I do this the tree doesn't get modified. When I do currentNode.children.delete(currentNode.children.high) it works
18:35:39*exebook quit (Ping timeout: 260 seconds)
18:38:26cryzedah damn
18:38:29cryzedIt didnt link the lines
18:38:40cryzedSee: https://gist.github.com/cryzed/4c0862147810bc76cb13#file-nim-nim-L106
18:38:46cryzedand https://gist.github.com/cryzed/4c0862147810bc76cb13#file-nim-nim-L145
18:40:20Araqwell var x = foo() creates a copy anyway as 'var T' is not a first class citizen in the language
18:40:38Araqeven if foo returns a 'var T'.
18:41:01Araqusually it means you should have started with a 'ref T' or return a 'ptr T'
18:42:45cryzedSo, make my internalChildren ref types?
18:44:56ArrrrIn my opinion, you dont actually want to give access to the internal children
18:45:15Arrrrmaybe provide an interator if you really need it
18:46:07cryzedI need to delete a child out of the tree after adding it
18:46:17cryzedhow would I do that without access to it?
18:46:52Arrrrwut, you delete it after you add it?
18:47:51Arrrranyway, i dont see what's the problem there
18:48:34cryzedArrrr, that I can't store a reference to the children in the tree, without calling the children accessor twice -- computational "overhead". I know it hardly matters with something as fast as Nim, but its not nitce
18:48:36cryzed*nice
18:49:04Arrrrif you do something like 'var s = node.seq' you will create a copy of that seq, so any operation should be done on node.seq. For example, 'delete node.seq, 0'
18:49:43cryzedYes. So to get the last index of my children I would have to do
18:49:58cryzed let lastIndex = node.children.high (called children once)
18:50:04cryzed node.children.delete high
18:50:08cryzedcalled children twice
18:50:09cryzedinstead of
18:50:13cryzedvar children = node.children
18:50:17cryzedchildren.delete(children.high)
18:50:42onionhammerls
18:50:42Arrrryou want to delete the last children? use pop(node.children)
18:50:56Arrrrhttp://nim-lang.org/docs/system.html#pop,seq[T]
18:51:04Arrrr*last child
18:51:21cryzedneat
18:51:28cryzedI suspect I will still run into problems with this in the future
18:51:30cryzedbut thank you Arrrr
18:52:43cryzedArrrr, https://gist.github.com/cryzed/4c0862147810bc76cb13#file-nim-nim-L143 and yeah, this is why I need to remove it after inserting it
18:52:46cryzedin a special case
18:53:13cryzedBasically in markdown one empty line is a linebreak <br/>, but 2 empty lines is a new paragraph without a lineBreak beforehand
18:53:20cryzedI probably am not constructing this tree in a very smart way
18:53:57ArrrrIt is an interesting project, i see
18:54:35cryzedProbably too interesting for me ;D
18:55:34ArrrrYou have done a lot. I see you finally used 'internalChildren' and 'internalChildren2' as names, eventually you will get confused.
18:56:41ArrrrAlso, if you are going to use only the ref version of node, you can directly declare it as 'Node = ref object'
18:56:42cryzedArrrr, that's why I'm planning to create a custom constructor for each nodetype that takes that complexity from my hands
18:56:59cryzed*off my hands
18:57:08cryzednoted
18:59:02Araqone thing to keep in mind: you have pattern matching on strings (that's called a regex), you don't have pattern matching on trees, so it might be wiser to deal with the complexity in the lexer rather than transforming the AST later on
18:59:49cryzedYou mean tokenizer?
18:59:55cryzedOr maybe I am confusing the terms
19:00:40cryzedBut I see your point, I'll have to consider doing that. But with Markdown it's only possible in a limited fashion I think
19:01:54Araqtokenizer == lexer
19:02:28AraqI don't think markdown is harder than RST
19:02:50Araqand how to parse RST well ... you can cheat and look at how Nim does it.
19:05:11cryzedcheating :O
19:05:17cryzed;)
19:22:55onionhammerhas someone written a nim parser/generator yet?
19:22:59onionhammerniml and nimy? :)
19:24:09*yglukhov quit (Remote host closed the connection)
19:24:43*yglukhov joined #nim
19:29:02*yglukhov quit (Ping timeout: 246 seconds)
19:29:33*juanfra quit (Quit: juanfra)
19:29:45*juanfra joined #nim
19:35:56Araqonionhammer: my lexim is a lexer generator
19:36:03Araqbut nimy is definitely missing
19:39:41*pilne joined #nim
19:40:21*aziz joined #nim
19:49:41*sepisoad joined #nim
19:50:43*Matthias247 joined #nim
19:52:22*sepisoad quit (Remote host closed the connection)
19:59:48*sepisoad joined #nim
20:00:17*sepisoad quit (Remote host closed the connection)
20:01:05*zepolen quit (Read error: Connection reset by peer)
20:02:16*Demon_Fox joined #nim
20:02:51*zepolen joined #nim
20:05:07*sepisoad joined #nim
20:07:02cryzedOk this bothers me though. Is there some writeup in the manual on how exactly nim works with variable passing? I understand that when defining methods with parameters prefixed by var or result prefixed by var it returns/gets references, that means no copying of datastructures when being called. When I declare a type as a ref object, I automatically get back a reference to the object instance when instantiating it. So when I have a method that
20:07:02cryzedreturns a reference to a data structure, which I explicitly tell with a var-return type, then there _must_ be a matching way to store that reference return type in a variable. It can't just be transient -- usable not storeable, that doesn't make sense
20:14:29*pilne quit (Quit: Quit!)
20:14:46*pilne joined #nim
20:14:52*sepisoad2 joined #nim
20:15:29ArrrrI dont understand your problem, but i admit it takes some time until you get it. Mostly because string/seqs doesnt work the way people are used in other languages
20:16:33*sepisoad quit (Remote host closed the connection)
20:23:38*kulelu88 quit (Ping timeout: 246 seconds)
20:26:50*elrood joined #nim
20:28:55cryzedArrrr, imagine you have a proc that collects various attributes from 10000 objects and creates a sequence that is 100mb in RAM
20:29:00cryzedJust for an extreme example
20:29:06cryzedNow you want to store it once, and have a reference to it
20:29:13cryzedinstead of copying 100mb RAM
20:29:15cryzedhow do I do that
20:29:28cryzedI return a reference to it, but as soon as I store it it gets copied
20:29:42cryzedI don't want to recompute it by accessing the proc again because that takes time
20:30:22Arrrraccessing a seq element with '[]' is also using a proc
20:30:34cryzedyes, I know
20:30:40cryzedthat doesn't really help me
20:30:46cryzedhow do i solve the described problem
20:30:58ArrrrDont copy the seq, use node.seq
20:31:17cryzedthat would require my code to collect the objects agian which takes 5 seconds
20:32:04ArrrrWhy do you have to collect the objects again
20:32:51cryzedit's a theoretical scenario. The same reason I don't want to call my children proc on my Node more than necessary: Once should be enough. I want to get access to the children and be able to modify them, so when I return a reference to a sequence I want to be able to modify the sequence
20:33:08cryzednot a copy of it
20:34:12ArrrrYou can use ref seq
20:34:42cryzedwhere do I put that? Into my object definition?
20:35:19Arrrrinstead of children: seq[Node], use children: ref seq[Node]
20:35:43cryzedtrying that, thank you
20:37:55cryzedArrrr, now in my children proc I get a type mismatch, : http://i.imgur.com/vF4Sn8I.png -- Do I have to dereference the reference somehow before returning it? The code: http://i.imgur.com/Kted3v7.png
20:38:44cryzedIt complains when returning it hm
20:39:46*BitPuffin|osx quit (Ping timeout: 260 seconds)
20:40:06*kulelu88 joined #nim
20:40:35cryzedOk When I try to instantiate a new Node object now:
20:40:35cryzed let root = Node(kind: nkRootNode, internalChildren: (ref @[]))
20:40:38cryzedI am trying to do something like this
20:40:57cryzedbut I get a type mismatch: got (typedesc[ref], Array constructor[...-1], empty])
20:42:10cryzedArrrr, any idea how I instantiate such a type with ref types properly then?
20:42:42federico3dom96: I'm trying to add SO_REUSEPORT in nativesockets.nim right next to SO_REUSEADDR and I'm getting a "cannot export" error without further messages
20:43:08dom96that's odd
20:43:13dom96search for the 'export' keyword
20:43:19*zepolen quit (Remote host closed the connection)
20:43:38federico3I assume the symbol comes from posix (where I added it earlier)
20:43:50dom96cryzed: I believe a 'seq' is already a 'ref' type.
20:44:17federico3could it be that the compiler is using posix.nim from the wrong path?
20:44:33cryzeddom96, https://gist.github.com/cryzed/4f40030a1388da7c063d
20:44:48cryzedline 116 is the instantiation
20:44:49*zepolen joined #nim
20:45:04cryzedif I don't cast it explicitly it complains about "got seq[empty]"
20:45:12dom96cryzed: s/ref seq[T]/set[T]/
20:45:18cryzedset?
20:45:23dom96typo
20:45:24dom96seq
20:45:27cryzedok
20:45:56cryzed>let root = Node(kind: nkRootNode, internalChildren: ref seq[Node](@[])) -> Error: type expected
20:46:10dom96federico3: can you gist your diff and the error output?
20:46:42federico3apparently if the symbol is not found in any imported module it triggers a "cannot export"
20:46:50Araq" It can't just be transient -- usable not storeable, that doesn't make sense"
20:46:52cryzedlet root = Node(kind: nkRootNode, internalChildren: ref seq[Node]) -> Error: type mismatch: got (typedesc[ref seq[Node]]) but expected ref seq[Node]
20:47:01Araqyet that is exactly how the language is defined.
20:47:12cryzedAraq, but what about the scenario I described earlier
20:47:15Araqand it does make lots of sense when you think about memory safety.
20:47:25cryzedis it just not a use-case in Nim?
20:47:33Araqthat scenario just pretends 'ptr' doesn't exist in the language, but it does exist.
20:47:43*BitPuffin|osx joined #nim
20:47:48Arrrrcryzed: http://ideone.com/dmwbVf
20:48:11Araqyou want a first class pointer? so use a first class pointer. (and live with the unsafety resulting from that model :P )
20:48:40cryzedIt's not like I'm being unreasonable
20:48:49federico3dom96: http://paste.debian.net/341746/ line 44, together with the previous changes in #3624
20:49:06dom96Araq: I think cryzed wants to reduce copies as much as possible, maybe you could help him do that?
20:49:36cryzedcopying parts of the whole AST just to check for an attribute here and there is insane
20:50:38*pilne quit (Quit: Quit!)
20:50:44dom96cryzed: Your Node is a 'ref', I think that means it won't be copied on assignment.
20:51:11cryzeddom96, so far I have problem even instantiating my Node class with the ref changes
20:51:14dom96federico3: Did you export it in posix.nim?
20:51:30cryzedI can't initialize Node with the internalChildren attribute
20:51:38*pilne joined #nim
20:51:43dom96You're passing in a type when you should be passing a value
20:51:46cryzedI need it to get a "ref seq[Node]" but I don't know how
20:51:53Arrrrcryzed: http://ideone.com/dmwbVf
20:51:54cryzedSo I need to create one with new?
20:51:59federico3dom96: https://github.com/nim-lang/Nim/pull/3624/files#diff-880812f441788508a84adff2c2ead03dR1569
20:52:00dom96You need to change the type to 'seq[Node]'
20:52:03cryzedArrrr, I saw that -- trying to figure out how to fit it into my code
20:52:05cryzedthank you
20:52:07dom96and then use: let root = Node(kind: nkRootNode, internalChildren: @[])
20:52:14cryzeddom96, then I have the same problem
20:52:15Araqdom96: I did help him :P
20:52:23dom96cryzed: what problem?
20:52:27cryzeddom96, one second
20:52:38Araqcryzed: yeah it is pretty unreasonable giving that 'var T' tries to preserve memory safety
20:52:41dom96Araq: You're telling him to use a ptr?
20:52:45Araqyes.
20:53:04cryzedI feel like you guys dont want me to do that
20:53:07dom96That's ridiculous.
20:53:08Araqyou can also just use an index
20:53:23federico3dom96: here's the diff of both changes together http://paste.debian.net/341748/
20:53:32dom96You shouldn't need to use unsafe features of the language to implement a markdown parser.
20:53:42Araqthat is a different topic, dom96
20:53:44dom96The unsafe features should only be necessary for C FFI.
20:54:05Araqhis use case was "la la la huge object la la la RAm la la la, think of the children!"
20:54:24Araq;-)
20:54:59Araqdom96: the unsafe features also greatly enhance the expressivity of the language.
20:54:59dom96federico3: try putting the SO_REUSEPORT in the 'export' on line 28
20:55:12Araqwhich is what we're arguing about. kind of.
20:55:39cryzednow I broke it completely
20:55:56Araqthe original problem is of course solved as for instance rstast.nim does it. but cryzed knows that cause I told him.
20:56:17federico3already tried
20:56:36cryzedAraq, of course I know that you implemented a rest parser -- I didn't and I'd like to gain experience doing it
20:56:57Araqwell it shows everything. how you can implement an AST.
20:57:10Araqhow you can parse a complex beast of a language such as RST
20:57:11dom96The JSON parser may be easier to follow
20:57:15cryzedYour code will be 180° different from mine, possibly sharing 1-2 classes
20:57:16Araqhow to transform it to HTML
20:57:31cryzedSo I don't think I can find a solution for my strange problem in your code
20:57:42cryzedbecause you know the internals of the language and will do completely different things
20:57:51Araqall of which don't use unsafe code and are pretty performant.
20:57:56federico3can I list what is being exported by posix? Yet, the code in sockets.nim works
20:57:57dom96cryzed: Can you create a small example of what the problem actually is? I didn't read all of the logs.
20:57:58cryzedas evidenced by our difference in opinion
20:58:15cryzeddom96, I will -- give me a second, as soon as I have it restored to the scenario I had in the beginning
20:58:43dom96federico3: please gist the full compiler output
20:59:22*irrequietus quit (Ping timeout: 260 seconds)
20:59:42federico3http://paste.debian.net/341751/
20:59:46ArrrrAraq will you support this? http://stackoverflow.com/questions/34119841/define-switch-for-key-value
21:00:11cryzeddom96, https://gist.github.com/cryzed/4c0862147810bc76cb13#file-nim-nim-L148
21:00:43dom96federico3: That is such a poor error, bug report! :P
21:01:01cryzedat this point I know that I can just call .pop -- but I'm sure I'll run into misunderstandings with the workings again soon
21:01:07federico3yep, at least "cannot export" should tell why
21:01:09cryzedso I might as well worry about it now
21:02:14ArrrrFrom what i understand, he doesnt want to use delete(currentNode.children)
21:02:53ArrrrWell, delete(currentNode.children, high(currentNode.children))
21:03:02cryzedArrrr, I do. I want to do children.delete(children.high) NOT currentNode.children (call proc once).delete(currentNode.children (call proc twice).high)
21:03:07cryzedyes
21:03:37Arrrrbut you have no other choice because seq semantics work as int, bool, etc
21:03:44cryzedProblem is when I do what I want I lose the reference to the seq returned by children proc
21:04:07cryzedhrm :/
21:04:23Arrrrif you declare a return proc as 'var bool', as soon as you put the return value in a var, it makes a copy
21:04:27Arrrrthe same happens with seqs
21:04:42cryzedif I don't return it as var, It immediately returns a copy?
21:05:07cryzed*declare
21:05:49ArrrrThis kind of situations are better with a running code example
21:06:40dom96In such a situation I would simply do it all on a single line.
21:06:49cryzednim c --run nim.nim test.md with contents: https://gist.github.com/cryzed/e244f1337be06d04ea2a
21:06:55dom96currentNode.children.delete(...)
21:07:01cryzeddom96, so call proc twice
21:07:19cryzedI suppose I can, but it will create a copy of some subtree of the AST
21:07:26cryzedwhen that is huge it might be an expensive operation to do it twice
21:07:34Arrrrhttp://ideone.com/kZT4XE
21:07:37dom96oh, because 'children' is not a field
21:07:40dom96It's a proc accessor
21:08:02cryzedyep
21:08:04*lokulin quit (Ping timeout: 245 seconds)
21:08:09cryzedBecause I can't use the field accessors, because of that strange bug
21:08:25*bjz quit (Quit: My MacBook Pro has gone to sleep. ZZZzzz…)
21:08:30cryzedwell I can, but I would have to use a different one for each variant
21:08:41dom96Araq: So what do you suggest cryzed do?
21:08:55dom96You still think cryzed should use a ptr?
21:09:53*Jesin quit (Quit: Leaving)
21:10:49dom96cryzed: What you could do is make 'children' a template.
21:11:02cryzeddom96, wouldn't that suffer from the same problem?
21:11:15cryzedI mean from what I understand a template replaces the AST, or modifies it
21:11:36dom96with a template there will be no proc call
21:11:36cryzedoh wait
21:11:44cryzedit would just decide to access between children or children2
21:11:52cryzednot actually return it
21:12:14dom96yes
21:12:17cryzedyes, Araq had suggested that -- but I thought it wouldn't work either at that point
21:12:25cryzedSo I'll read up on templates I suppose
21:12:37dom96You should be able to just s/proc/template/
21:12:39dom96maybe
21:12:46cryzeddom96, is my problem really that unreasonable though? I mean imagine if calling the accessor was really an expensive operation -- 500ms runtime or something
21:12:51dom96This feels hackish to me though
21:12:58cryzedit wouldn't be feasible to do it twice just for fun
21:13:24ArrrrDefine a proc called removeLast(n: Node)
21:13:31Arrrrand do that inside
21:13:41dom96cryzed: I think your problem is reasonable actually
21:13:46dom96I have code in which I do:
21:14:12cryzedArrrr, yep let me figure out the template thing first
21:14:17dom96template cs() = myNode.internalChildren2; cs.delete(...)
21:14:20dom96Basically
21:14:26dom96Just suited to my code
21:14:35dom96It's kind of a hacky "alias"
21:14:48cryzedit's all rooted in the object variation not working correctly
21:14:56cryzed*variants
21:15:06dom96indeed.
21:15:08cryzedthat's why you need a custom accessor
21:15:20dom96I complained about that for a while, I may just need to fix it myself :P
21:15:54dom96cryzed: If you have time then please create an issue for each of these things.
21:16:07cryzedI will
21:16:17dom96The object variant and the copying issues.
21:16:20cryzeddom96, just replacing it with template didn't work unfortunately, it's probably something obvious
21:16:27dom96what's the error?
21:16:34cryzedmarkdown.nim(132, 15) template/generic instantiation from here
21:16:34cryzedmarkdown.nim(110, 18) Error: type mismatch: got (seq[Node]) but expected 'Node'
21:16:37cryzedline 132 being
21:16:45cryzedroot.children.add currentNode
21:17:26cryzedI attempted to remove the var keyword from the return type, since that's moot now
21:17:29cryzedbut there's no change
21:17:36cryzedI might have to read up more on templates
21:19:05cryzedhttps://gist.github.com/cryzed/24a33da7de19fcc5e49f here's the current code again, with a sample md file: https://gist.githubusercontent.com/cryzed/e244f1337be06d04ea2a/raw/4fe49ec9f3eff4b1e537fe1ad73345ee3a477dd1/test.md
21:19:16cryzedrunnable with nim c --run newCode.nim test.md
21:19:28dom96hrm
21:19:42dom96yeah, it's because the 'return ...' ends up inside the body of your proc
21:19:54dom96Your procs return type is 'Node'
21:19:59dom96so maybe templates can't work :\
21:20:19cryzedSo maybe do what Arrrr suggested
21:20:30cryzedand write a template for that without a return type
21:20:37cryzedi.e. removeLast(n: Node)
21:20:46cryzedbut it's not "cool" :D
21:20:48cryzedoh well
21:20:58Arrrryou cannot delete from seq, you need var seq. And, as i told you, the moment you do var s = node.seq you are doing a copy
21:20:58cryzedI'll create an issue for the object variants
21:21:29cryzedArrrr, that's why I would use a template that simply accesses the correct field name depending on object variant
21:21:54Arrrrit doesnt matter if you use template, proc, or directly node.internalChildren. It makes a copy
21:22:34Arrrrthink of seq as if it were an int
21:22:57cryzedbut I am deleting from the sequence and have been when doing node.children.delete(...) -- even when I had the type definitions as they are currently, shouldn't that have _not_ worked then?
21:23:33Araqyou can create issues all you want, but I will close most of them because there is no issue here.
21:23:57Arrrrwithout the var mod?
21:24:02cryzedyes
21:24:10cryzedAraq, so not being able to define two fields with the same for object variants is a feature?
21:24:15cryzed*name
21:24:18cryzedas in
21:24:20Araqof course it is.
21:24:36cryzedcase kind: SomeKind: of FIRSTCASE: children: string, of SECONDCASE: children: string
21:24:48*bjz joined #nim
21:24:49cryzedbecause one branch is never executed while the other is
21:24:55Araqthere is not a single language out there that supports what you're asking for.
21:25:08cryzedAraq, I am not using other languages, I'm using Nim
21:25:11cryzedand that features is nearly included
21:25:28*lokulin joined #nim
21:25:34Araqyeah, but maybe there is some deep underlying issue of why no language does that?
21:25:44Araqmaybe, just maybe, it's not all Nim's fault?
21:25:54cryzedmaybe -- I didn't develop it. Is there for that specific issue?
21:26:19cryzedthere's no need to get defensive either -- I'm not attacking you or Nim, I just honestly believed it to be a bug
21:26:21*irrequietus joined #nim
21:26:22cryzedand I'm not the only one
21:26:30ArrrrYou mean you did this? http://ideone.com/77g9Ub
21:27:05Araqwell what does 'obj.children' mean when you've got two of them?
21:27:16ArrrrI suppose it is not supported because, in compile time, it doesnt know if node is of one kind or another
21:27:33Araqshould we disambiguate via type resolution rules?
21:27:44Araqshould we inject some code to make it polymorphic?
21:27:52AraqI mean runtime polymorphism.
21:28:22Araqcompile-time disambiguation buys you nothing, since you might as well use two different field names then.
21:28:47Araqruntime disambiguation doesn't fit Nim's design at all.
21:28:49cryzedArrrr, no I mean: https://gist.github.com/cryzed/bfae54903e73fa06f3c4
21:28:57Araqpick your poision. ;-)
21:29:38ArrrrYou said you did a delete from a seq returned by a proc
21:29:44ArrrrTHat's what i understand
21:29:59Araqcryzed: for your example move the 'children: string' field out of the 'case'. ta-da. problem solved.
21:30:16cryzedAraq, now all variants have the children attribute
21:30:19cryzedeven types that don't need it
21:30:33cryzedfor examples nodes that cant contain children
21:30:46Araqso?
21:30:58cryzedand the field accessor would be chosen depending on the kind, that's why the case-statement is there right?
21:31:11Araqtypes are *always* a static *approximation* of what is actually valid at runtime.
21:31:32dom96so why use the case statement inside the object definition at all?
21:31:40cryzed^
21:31:53cryzedI could just define all variables then and just use those I need
21:31:55Araqdom96: to get a better approximation and to save some memory.
21:32:21cryzedso now it's a half-way thing? Is there really an underlying language development issue that prevents this from working as expected?
21:32:33cryzedI have no clue -- that's why Im asking
21:32:35cryzednot to be a little shit
21:35:01*bjz quit (Read error: Connection reset by peer)
21:35:02dom96As for no other language doing it, isn't this Rust doing it? http://is.gd/N4WeJC
21:35:31Araqnot what I'm talking about.
21:36:01dom96to be fair, I guess in Rust you need to repeat your fields
21:36:15Araqtry to access 'x' without a guard check in Rust.
21:38:56Araqand just fyi, "so why use XXX at all then?" is always a shitty pseudo argument.
21:39:23Araq"so why use a toilet when my hands can get dirty anyway?"
21:39:24dom96Hrm, you're right. Rust requires pattern matching.
21:39:50cryzedAraq, that's not the same at all. There was honest confusion about what the case-staement does in the variant definitions then
21:40:05Araq"so why use a car when I can go faster by plane?"
21:40:16dom96Why not make it better then?
21:40:35dom96I would expect node.children to expand into an if statement
21:40:47dom96and give me the correct children field in the background
21:40:53cryzeddepending on the kind
21:40:54dom96Nim is meant to be expressive damn it
21:44:13ArrrrWhat went wrong
21:44:29Arrrrmaybe we were too young and naive
21:46:31Araqdom96: the people who want that feature in general want the compiler to compute offsets so that the different 'children' fields are mapped to the same offset
21:46:50Araqand to not make it generate a hidden 'if' statement
21:47:24dom96Araq: What if I said that I don't care for that?
21:48:00dom96I assume that what you just described that other people want is significantly more difficult to implement than a simple hidden if statement
21:48:43Araqno, actually my suggestion is way easier to implement
21:48:52Araqbut that's besides the point.
21:49:34*zepolen quit (Remote host closed the connection)
21:49:41Araqthe point is that I thought cryzed is asking for 'children: string' in one branch and 'children: seq[T]' in another
21:49:55cryzedNo not at all
21:50:03cryzedI just want some nodes to have children and some not
21:50:05cryzedof the same type
21:50:10Araqwhen they are of the same type, things are quite different
21:50:24Araqbut then the implementation moves the field out of the 'case'
21:50:47cryzedSo every object variant automatically has the children field?
21:50:58Araqno, I mean, ugh.
21:51:05cryzedSorry, I'm being dumb probably
21:51:23Araqif Nim supported what you ask for, it would move the 'children' out of the 'case'.
21:51:29dom96That's still not flexible enough in my opinion.
21:51:46Araqwhich you can do today, albeit losing some static checking and code documentation
21:52:05Araqdom96: that's why I'm not answering you anymore.
21:52:23dom96Take the JsonNode type as an example https://github.com/nim-lang/Nim/blob/devel/lib/pure/json.nim#L557
21:52:53dom96A JInt and a JFloat could both have 'num' accessors.
21:53:21Araqdom96: for this my original answer applies.
21:53:26Araq;-)
21:54:12Araqand now I'd rather work on Nim bugs rather than arguing about how the language could be even more convenient and complex.
21:54:20cryzedWell I'm off to exercise
21:54:24cryzedo/
22:27:08*Jesin joined #nim
22:39:11kulelu88how do I get a @nim-lang email address? <3
22:43:59*theduke quit (Ping timeout: 264 seconds)
22:48:17Arrrrcan i send drawings?
22:56:09*theduke joined #nim
23:01:16Araqkulelu88: these are hard to come by
23:01:37Araqtheduke: what is the most annoying Nim bug for you?
23:02:04kulelu88:D
23:02:06Araqkulelu88: I think you can buy one from dom96 :-)
23:02:38kulelu88dom96 ... so young and already getting into the Silicon Valley startup scene of selling email addresses :D
23:03:06dom96$5 million and you can get any @nim-lang.org email you want :P
23:03:44*elrood quit (Quit: Leaving)
23:04:05kulelu88you didn't specify what type of dollar :) 5 million zim dollars won't be hard to come by
23:04:50Araqah spoken like a true programmer ;-)
23:17:40*pilne quit (Remote host closed the connection)
23:20:04*pilne joined #nim
23:20:58*boopsies is now known as boopsiesisaway
23:29:35*Matthias247 quit (Read error: Connection reset by peer)
23:32:19dom96kulelu88: sure, I like obscure currencies. :D
23:32:48*aziz quit (Remote host closed the connection)
23:33:20kulelu88I bet you and Araq got your own personal blockchain currency :D
23:34:58cryzedUsed solely to keep track of work to be done
23:35:16cryzedwhoever has accredited more coins needs to do less work, the other party being paid after the bugtracker count shrinks
23:37:32*vendethiel quit (Ping timeout: 246 seconds)
23:43:24*irrequietus quit ()
23:45:25ArrrrGood night
23:45:27*Arrrr quit (Quit: WeeChat 1.2)
23:52:14*girvo_ joined #nim
23:52:21*girvo_ quit (Client Quit)
23:52:26girvoHi all :D
23:52:34*kulelu88 left #nim ("Leaving")
23:52:55cryzedhello
23:52:57girvoI finally sat down and had a proper play with Nim's macro system, and god-damn am I impressed
23:53:30girvoI'm a lisper at heart, who uses procedural languages at work because I have to; so having a procedural language with hygenic metaprogramming is a massive boon :D
23:54:39girvoConverting a 40 line C++ template specialisation set into a 4 line Nim macro totally made my weekend, heh
23:55:06cryzedthat's very cool to hear :)
23:55:06girvoDoes anyone have any documentation on how memory management should be dealt with when dealing with an external C library btw?
23:55:35cryzedYou probably want to ping dom96 or Araq
23:55:44girvoyeah I might email them
23:56:07cryzedWhy, just idle a bit
23:56:14girvoMy little project is finally getting big enough that I should probably work out how to deal with all the memory i'm leaking
23:56:20dom96No need, I am here
23:56:23girvoI'll be doing that too
23:56:27girvoOh hey! hah
23:56:49dom96hello girvo
23:56:57dom96Cool to hear that you love Nim's macros
23:57:03girvodom96: hey dom :)
23:57:12dom96They are certainly one of Nim's awesomest features :D
23:57:19girvoThat they are!
23:57:36girvoAnd how they play with the type system? just glorious, it worked exactly how I thought it would!
23:57:58girvoanyway, wheres the best place to look for pointers (hehehe) on how to deal with memory management when using an external C library?
23:58:00dom96as far as memory management when dealing with external C libraries: just do it as you would in C.
23:58:02girvoSpecifically the SDL2 one
23:58:07girvoOkay awesome, I thought that was the case
23:58:25cryzedgirvo, can I be nosy and ask what you are doing with SDL2?
23:58:29dom96Best thing to do is to create a module on top of the C wrapper
23:58:29girvoDo I have to worry about the GC accidentally freeing something it shouldn't when in a nim context?
23:58:32girvoI assume I wouldn't
23:58:34dom96which exposes a safe Nim interface
23:58:46girvodom96: awesome, yep thats the direction I'm heading in
23:58:59dom96The Nim GC only frees things it allocates
23:59:20girvodom96: cool, what about ints that are allocated but passed in as casted cints?
23:59:22dom96You need to be careful if you are passing a Nim object into a C function
23:59:31girvo(for example)
23:59:38dom96allocated how?
23:59:51dom96in most cases ints won't be allocated on the heap
23:59:53girvoallocated is the wrong word, I'm not using alloc or anything lol :P
23:59:57girvojust regular `var` or `let`