<< 17-01-2015 >>

00:01:11def-hm, something is wrong with the compiler's nimcache. Doesn't invalidate correctly sometimes, but can't reproduce
00:02:00Araqdef-: can only happen for .compile files
00:02:12dtscodefowlmouth, there is no function though
00:02:15fowlmouthtry --forcerebuild
00:02:28def-fowlmouth: yeah, i can just remove the nimcache directory, but it's strange
00:04:07fowlmouthdtscode, try putting it on loop() and run()
00:04:44dtscodeok
00:05:12dom96You really shouldn't be using asyncio.
00:05:19fowlmouthdtscode, actually it should be on the handleRead function
00:05:29dtscodeok
00:05:45dtscodedom96, im trying to get it to compile before i start cleaning it up
00:05:55dtscodei still havent ruled out starting from scratch
00:06:32*brson quit (Ping timeout: 244 seconds)
00:07:11fowlmouthdtscode, proc handleRead(serv: PServer): (proc(s: PAsyncSocket){.closure, gcsafe.}) =
00:07:26flaviuhttps://github.com/Araq/Nim/pull/1975
00:07:35*brson joined #nim
00:07:38dtscodeyeah
00:08:51Araqflaviu: nice!!!
00:09:01fowlmouthcool flaviu that was quick too
00:09:27EXetoCweee
00:10:28flaviuunittest is a macro, and I'm pretty familiar with macros.
00:11:51fowlmouthoh i thought this was a compiler patch
00:12:16fowlmouth<_<
00:13:34dom96dtscode: I'd say rewrite is a good idea.
00:15:30dtscodeis there a basic ircd out there that i can use for reference?
00:15:43flaviudtscode: nice import formatting :P
00:16:00dtscodeflaviu, not my code :}
00:17:15fowlmouthof "MODE": if false: nil -- i wonder what the point of this was lol
00:17:45def-fowlmouth: workaround for not knowing "discard"?
00:19:09fowlmouththeres a discard right below it though >_>
00:21:18dtscodedom96, would i just need asyncnet or asyncdispatch as well?
00:22:46EXetoCso there are no major issues related to implementing the async stuff in userland?
00:23:08*irrequietus quit ()
00:25:25*rpag quit (Quit: Leaving)
00:30:14*BitPuffin quit (Ping timeout: 245 seconds)
00:45:44*gmpreussner_ joined #nim
00:45:48*gmpreussner quit (Ping timeout: 244 seconds)
00:51:30*sillesta quit (Read error: Connection reset by peer)
01:04:47*sampwing quit (Ping timeout: 252 seconds)
01:14:59*Sergio96_ joined #nim
01:17:47*[dee] quit (Read error: Connection reset by peer)
01:19:52akiradeveloperWhat is the convention to express failure? Does Nim have a type option<T> like in some other langs?
01:19:54*gmpreussner_ quit (Ping timeout: 244 seconds)
01:20:13*gmpreussner_ joined #nim
01:22:01EXetoCwhat about exceptions?
01:24:25*Trustable quit (Quit: Leaving)
01:27:27*brson quit (Quit: leaving)
01:33:02akiradeveloperexception is slow
01:34:04akiradeveloperexception is usually used as expressing failure in Nim?
01:34:28EXetoCis it?
01:35:18def-Depends on the situation
01:35:25def-for exceptional errors exceptions are used
01:35:34akiradeveloperIn some language like OCaml, exception is apparently slower than returning error
01:35:36def-otherwise invalid values like -1 or nil
01:35:39*sillesta joined #nim
01:35:44akiradeveloperok. -1 or nil
01:36:03def-you can define your own option<T> type if you want to write your code in that style
01:36:38akiradeveloperbut Nim doesn't have pattern matching so that style doesn't fit I think
01:37:32akiradeveloperno convention to return (error, obj) pair like golang?
01:38:32def-no, haven't seen that
01:39:53akiradeveloperok thanks.
01:41:12akiradeveloperis there no path class?
01:42:25def-Path stuff is in the OS module: http://nim-lang.org/os.html
01:43:04ldleworkyou can return a tuple
01:43:33akiradeveloperdef-: thanks. we don't wrap string in a path type
01:43:36ldleworkI guess that's not the same :)
01:44:38akiradeveloperNim has a convention in error handling similar to C (linux kernel etc.)
01:45:18def-akiradeveloper: with the advantage that you can't just implicitly throw the error away, you have to actually handle it or explicitly discard it
01:47:33fowlmouthakiradeveloper, you can return a tuple and unpack it to use it like go's tuples
01:48:29ldleworkfowlmouth: oh okay so I'm not crazy
01:48:52akiradevelopervarious kind of advances thanks but I am confused
01:49:03ldleworkfowlmouth: you'd have to return a ref type as the error right?
01:49:13ldleworkso you could optionally return nil?
01:51:55fowlmouthldlework, string can be nil
01:52:00fowlmouthis nil by default
01:53:17ldleworkakiradeveloper: make sense?
01:59:16EXetoCOption[T] and a converter maybe
02:01:16EXetoCfowlmouth: right, your TMaybe has a converter
02:04:23fowlmouthoption[t] is different
02:04:42akiradeveloperIdlework: I am confused yet
02:04:45fowlmouthgo's convention is more like either[string, T]
02:04:54akiradeveloperTMaybe?
02:04:56flaviuI wrote https://github.com/flaviut/optional_t and think it's awesome, but I'd like criticism.
02:05:20EXetoCfowlmouth: ok.. is that not unconventional?
02:05:46fowlmouthEXetoC, is what unconventional?
02:06:43EXetoCfowlmouth: go's 'option'
02:06:58fowlmouthits not the same thing
02:07:24fowlmouthoption<t> means t or nothing, go's is an error string or a value
02:07:49EXetoCthat's what I mean by unconventional. oh well
02:07:50flaviuEXetoC: fowl is talking about Either[T, string], which is a superset of Option[T] (Option[T] == Either[T, Unit])
02:08:04EXetoCI got that
02:08:27flaviuEither is not unconventional, it's very common in functional programming.
02:08:29flaviuhttp://www.scala-lang.org/api/current/index.html#scala.util.Either
02:08:54fowlmouthbut its not really clear what the error string actually is
02:08:59EXetoCbut he's saying that it's like 'either', even though it's called 'optional', right?
02:09:32fowlmouthis it some kind of error code that can be prepared so a good message can be output to the user or is it a message that is OK to be shown to the user
02:10:17flaviuEXetoC: It's a convention more than a concrete type. It returns `value, error`, and I assume if error exists, then value is null.
02:11:59*keyle joined #nim
02:12:05EXetoCI don't know why I thought TMaybe was inconvenient, but the interface has grown, so I'll make sure to try it though
02:12:14keylehi
02:12:21EXetoClet's turn it into its own package and mention it on the forum, because it's neat
02:13:10fowlmouthEXetoC, i had a cool idea to optimize it but its not working
02:16:22*yonson joined #nim
02:16:34*7YUAAFJOH quit (Read error: Connection reset by peer)
02:16:34*Etheco quit (Read error: Connection reset by peer)
02:17:27fowlmouthhttps://gist.github.com/fowlmouth/e5492771933e90835c51
02:18:11*JinShil quit (Quit: Konversation terminated!)
02:19:14*JinShil joined #nim
02:20:06*sillesta quit (Remote host closed the connection)
02:20:09EXetoCthat's what's not working?
02:22:05fowlmouthyea the `when` branch in the type is always true
02:23:04EXetoCuse 'compile' for now? let's see what statement to use
02:23:36EXetoC*compiles
02:25:29*jefus_ joined #nim
02:26:31EXetoCcompiles((let x: T; T.isNil == true)) ?
02:27:13flaviuhttps://gist.github.com/038804143b26ddf6fafa also doesn't work
02:27:15fowlmouthyes please try to make that work :)
02:28:12flaviuAre the when statements executed upon expansion, or once at the beginning?
02:28:24flaviuMy logging says both :/
02:28:29renesacugh, I'm in the skyfex branch and I still get: Error: type mismatch: got (int literal(0), uint32)
02:28:33renesac:/
02:28:33flaviuTfalse; ref inttrue; ref inttrue
02:29:08*jefus quit (Ping timeout: 245 seconds)
02:32:32renesacand trying to correct I get "Error: ambiguous call; both system.xor(x: int64, y: int64): int64 and unsigned.xor(x: int64, y: uint64): int64 match for: (int64, int)"
02:32:48renesacnot quite the same old $ error, but close
02:35:15*sampwing joined #nim
02:41:35*sampwing quit (Ping timeout: 252 seconds)
02:42:03renesac[20:56] <Araq> 5 already has the type 'int literal(5)' and is compatible with uint8, 300 is not
02:43:22ldleworkrenesac: I think it only works for literals
02:43:24renesac<-- acording to my experience, even now on skyfex branch, that 'int literal(5)' isn't compatible with uint8
02:43:47renesacunsigned.<(x: T, y: T): bool
02:43:49renesacops
02:43:51*Sergio96_ quit (Ping timeout: 264 seconds)
02:44:08renesacerr, one line don't want to get printed on irc
02:44:10ldleworkrenesac: oh its ambiguous in that there are two functions named exactly the same
02:44:15ldleworkwith the same signature
02:44:20ldleworkso you have to fully qualify?
02:44:27ldleworksystem.xor or unsigned.xor
02:44:35renesac./tmp/aporia/a5.nim(4, 6) Error: type mismatch: got (int literal(5), uint8)
02:44:38renesacforgot about the /
02:44:56renesacbut expected one of: system.<(x: TEnum, y: TEnum): bool system.<(x: string, y: string): bool
02:45:01renesacetc
02:45:15renesacldlework: that is overload
02:45:23ldleworkhmm?
02:45:38renesacthe comparison operator is overloaded for all types
02:45:47renesacwell, all that makes sense
02:45:47ldleworkI was talking about xor above
02:46:00renesacso?
02:46:08renesacthey have different types for their arguments
02:46:28ldleworkoh I didn't notice
02:46:35ldleworkthey read the same to me, sorry
02:46:36renesacuint64 != int
02:47:43renesacif the compiler did what araq said it should be doing, I would be happy now
02:55:05Varriountblorg blorg
02:58:07*Demos joined #nim
02:58:35*sillesta joined #nim
03:04:52akiradeveloperHow can I get the internal point of array or seq?
03:05:04def-what's an "internal point"?
03:05:13sillesta+er?
03:05:21akiradeveloperpointer
03:05:27flaviuakiradeveloper: addr mySeq[0]
03:05:29def-addr mySeq[0]
03:06:01flaviuhaha, exactly the same code at the same time
03:07:33*reactormonk joined #nim
03:08:12sillestaare there any games that have been made with nim?
03:08:13akiradeveloperlet a = @[1,2,3] echo addr(a[0])
03:08:19sillestaall i've found are a few game libs
03:08:26akiradeveloperError: expression has no address
03:09:02fowlmouthakiradeveloper, you wont get the address because you said you want it to be immutable when you used let, so declare it VARiable instead
03:10:34*kapil__ joined #nim
03:10:37akiradevelopervar a = @[1,2,3] echo addr(a[0]) Error: type mismatch
03:11:06def-yes, `$` is not specified for addr
03:11:09EXetoCcast to uint
03:11:17fowlmouthuse repr() to get a nice string for a pointer
03:11:21EXetoCdef-: ptr, but yeah
03:11:27def-oops
03:11:28EXetoCor pointer or ref
03:11:55EXetoCI actually meant what fowl said
03:12:05def-.eval var a = @[1,2,3]; echo repr(addr a[0])
03:12:08Mimbusdef-: ref 0x7f32bfa48060 --> 1
03:12:18akiradeveloperGreat
03:12:19EXetoClater. code well
03:12:22akiradeveloperit works
03:12:32akiradeveloperthanks guys
03:17:25*ARCADIVS joined #nim
03:20:56*sillesta quit (Read error: Connection reset by peer)
03:21:12*darkf joined #nim
03:21:26akiradeveloperdo you guys think string can be equivalent to a void *buffer in C? I am looking for a data structure that is best fit for buffer in fuse protocol
03:21:56def-akiradeveloper: make a fixed size array?
03:22:13akiradeveloperor sequence of u8?
03:22:33def-if you need variable sized buffers, yes
03:22:41akiradeveloperyes. it is fixed size that's determined at initializing (or mouting)
03:23:04akiradeveloperarray[size, u8] or string is my choice?
03:23:11def-for Nim's arrays it would have to be known at compiletime
03:23:46fowlmouthakiradeveloper, youre wrapping fuse??
03:24:00fowlmouthjust use cstring btw -- its char*
03:24:45akiradevelopernot just wrapping fuse. I am implementing nim-fuse
03:24:54akiradeveloperwhich is a nim binding for fuse
03:25:03def-nice
03:25:17fowlmouthcool i was thinking about doing that the other day
03:25:53akiradeveloperJust started but it is only but a Nim issue (I am Nim newbie) I completely understand fuse protocol
03:26:38fowlmouthakiradeveloper, do you need to index into the data buffer? if yes use cstring (it is char*) if no use pointer
03:26:41akiradeveloperI think I should start from buffer class defined to hide the internal structure
03:27:41akiradeveloperyes. indexing (read) and store (like memcpy)
03:28:48akiradeveloperok I see. thanks
03:28:52EXetoCa binding is a direct interface
03:33:59*EXetoC quit (Ping timeout: 245 seconds)
03:36:02akiradeveloperI need to use libc read. Do I have to make a binding by FFI? or is there some binding module?
03:41:39reactormonkakiradeveloper, importc
03:42:11reactormonkakiradeveloper, ssize_t read(int fildes, void *buf, size_t nbyte); <- this one?
03:42:29akiradeveloperyes
03:42:47reactormonkhttp://nim-lang.org/posix.html <- you want this module
03:43:27reactormonkor not
03:43:58reactormonknot sure if you have ssize_t already, otherwise import it via type ssize_t {.importc: "ssize_t" }
03:44:17def-Why not just something around here?: http://nim-lang.org/system.html#readBuffer,File,pointer,int
03:44:49reactormonkfor the proc: proc read(fildes: TFile, buffer: array[ ... ], nbyte: int): ssize_T {.importc: "read".}
03:45:10reactormonkpoint for def-.
03:45:58akiradeveloperI have a file descriptor. I need to communicate with it. TFile is too abstract
03:46:32akiradeveloperIt looks what's in posix module should work
04:05:34*nimnoob joined #nim
04:05:45*VinceAddons quit (Read error: Connection reset by peer)
04:23:08*nimnoob quit (Remote host closed the connection)
04:24:49def-Araq: Hm, I'm having trouble with tcc-repl again. When I have two lines "var x = 1" and "echo x", how do I get x to be of the right type in the second one?
04:58:57reactormonkakiradeveloper, huh? Which special requirements do you have?
05:04:20*Demon_Fox joined #nim
05:08:10*brson joined #nim
05:11:46*dyu joined #nim
05:21:36*kapil__ quit (Quit: Connection closed for inactivity)
05:40:44gmpreussner_ugh... so much hate for unsigned :)
05:45:43*Demos quit (Read error: Connection reset by peer)
05:52:36reactormonkgmpreussner_, sure, unsigned is evil >:)
05:53:00gmpreussner_i agree, but it's a pain in the neck when wrapping C libraries
05:53:16gmpreussner_i wonder if i should eliminate unsigned types in the wrapper as well
05:53:46gmpreussner_reactormonk: what is the general consent on this? do people wrap everything as signed?
06:11:21*akiradeveloper_ joined #nim
06:12:29akiradeveloper_When a program is terminated, a object in the heap are called its destructor?
06:13:27akiradeveloper_I want to free file descriptor (OS resource) when user kill the program. How can I do this?
06:17:19*gmpreussner__ joined #nim
06:17:30*gmpreussner_ quit (Ping timeout: 244 seconds)
06:19:28*johnsoft quit (Ping timeout: 255 seconds)
06:20:16*johnsoft joined #nim
06:30:10reactormonkgmpreussner__, just don't use unsigned numbers except you get them passed
06:30:30reactormonkakiradeveloper_, IIRC destructors are a flimsy business
06:31:48*akiradeveloper left #nim (#nim)
06:33:16*dyu quit (Remote host closed the connection)
06:49:46*gmpreussner___ joined #nim
06:50:34*gmpreussner__ quit (Ping timeout: 244 seconds)
06:52:23Triplefoxlooking for a good way to do this(any alternative welcome) https://gist.github.com/triplefox/59a54a1697ebca769cbf
06:55:46*zahary joined #nim
07:07:40*kapil__ joined #nim
07:08:03*gour joined #nim
07:08:17*gour left #nim (#nim)
07:21:53*BlaXpirit joined #nim
07:53:05*gmpreussner___ quit (Ping timeout: 244 seconds)
07:53:11*gmpreussner___ joined #nim
07:53:29*nande quit (Remote host closed the connection)
08:04:23*brson quit (Quit: leaving)
08:10:51*BlaXpirit_ joined #nim
08:11:03BlaXpirit_so i was porting docopt to nim
08:11:08BlaXpirit_left_ = left[:pos] + left[pos + 1:]
08:11:20BlaXpirit_translated to: var left2 = left[0 .. <pos] & left[pos+1 .. left.high]
08:11:47BlaXpirit_took me somewhere between 1 and 2 hours to find the bug caused by this line
08:20:10Triplefoxwhat is the bug
08:21:41Triplefoxis it because pos + 1 can go past left.high?
08:25:34BlaXpirit_that same problem i recently described
08:25:53BlaXpirit_pos == 0, then left[0 .. <pos] == left
08:26:17BlaXpirit_can't believe i fell for it the very same day!
08:31:33Triplefoxah, right
08:34:06Triplefoxyeah, hmm...i couldn't see it, you couldn't see it either...
08:36:03*Varriount quit (Ping timeout: 264 seconds)
08:36:51Triplefoxwith substr it's not an issue though, right
08:37:11BlaXpirit_if you remember to use the actual substr function instead of slice
08:39:20Triplefoxyeah, we established before that slice was okay if you were only using the original length...
08:48:20BlaXpirit_finally wrote an issue about this https://github.com/Araq/Nim/issues/1979
08:49:42*gmpreussner joined #nim
08:50:15*BlaXpirit_ quit (Quit: Quit Konversation)
08:50:26*gmpreussner___ quit (Ping timeout: 244 seconds)
08:56:07*gmpreussner quit (Ping timeout: 244 seconds)
08:56:07*gmpreussner_ joined #nim
09:03:33*rkj-b joined #nim
09:05:12rkj-bGood morning
09:05:19BlaXpirithi
09:08:47rkj-bI learned Pascal in school, read a book on C, have dabbled in 2nd order logic. Really lost in the woods! Maybe I could do a journal about how a n00b learns Nim on my blog?
09:10:00BlaXpiritmaybe
09:17:05*UberLambda joined #nim
09:21:28rkj-bFirst I will have to clean up yhr mess in my computer. I started trying to install OCaml, but it seems like thr French own it. No pointers either, and awful multiprocessor workaround attempts. Rust looks very steep -- maybe not worth the climb. Is Nim not insanely hard to learn? I am also looking at Kitten, but the "Concatenative channel is desolate!
09:35:59*dtscode quit (Quit: ZNC - http://znc.in)
09:40:00*dtscode joined #nim
09:40:17Demon_FoxIf you want easy, you can give python a go
09:40:24Demon_Foxnim is similar
09:40:34Demon_Foxbut typed, and faster
09:41:47*dtscode quit (Client Quit)
09:42:04*dtscode joined #nim
09:43:22Demon_FoxSo you are aware, the garbage collector in python is crap.
09:45:18UberLambdaAnd it hinders real multithreading
09:47:57Demon_FoxThat to
09:49:36Demon_Foxbut concept wise, it might be useful
09:50:22*gmpreussner_ quit (Ping timeout: 244 seconds)
09:50:33*gmpreussner_ joined #nim
09:50:41*ARCADIVS quit (Quit: ARCADIVS)
09:52:02rkj-bFunny thing about "untyped" languages: when people try to create typed versions, they get pretty far, and then it all goes south. I believe interpreters and virtual machines (a la Java) are on the way out. The criminal hackers are getting so much better, and the interpreters have to be patched like Windows, and still will get owned. Pointers might be needed some time. And maybe some...
09:52:04rkj-b...functional programming would speed up some chores (if it's robust enough). I wonder about concatenated languages like Factor and the new Kitten (which is typed). They look elegant.
09:53:49vegaiFactor is quite dynamically typed too
09:54:07vegaihaven't heard of Kitten before though
09:54:44Demon_Foxrkj-b, python is more of a scripting language with programming features attached
09:56:40dtscodehow do you do dictionaries in nim again?
09:58:54BlaXpirittables?
09:58:57BlaXpiritdtscode,
10:00:29dtscodeuhhh maybe
10:00:36dtscodeits the python equivalent to {}
10:07:16rkj-bRegarding the Kitten language, see: ( http://kittenlang.org/ ) and ( http://evincarofautumn.blogspot.com/2013/07/static-typing-in-concatenative-language.html ). This is my first encounter with IRC. (I retired from electronics, analog computers with Op-Amps even.)
10:08:35dtscodeomfg theres a kitten language?
10:09:31Demon_FoxYeah :{
10:09:48dtscodezomg
10:11:16BlaXpiritand doge language
10:11:42BlaXpiritmore than one, it seems
10:12:14dtscodei knew about that one
10:12:28Demon_Fox(ツ)
10:12:58dtscode¯(°_o)/¯
10:14:44Demon_Fox¯\_(ツ)_/¯
10:15:05dtscode(╯°Д°)╯︵ /(.□ . \)
10:16:41Demon_Fox
10:17:19dtscodeಠ_ಠ
10:17:44UberLambdahttp://en.wikipedia.org/wiki/LOLCODE
10:18:04BlaXpirit"GRINNING CAT FACE WITH SMILING EYES" is pretty specific
10:18:05dtscodelolscript is better
10:18:32UberLambdaLol
10:18:33Demon_Fox
10:20:59*gsingh93 quit (Quit: Connection closed for inactivity)
10:21:54rkj-bI heard that Nim can maybe 10 times faster to learn than Rust. The developer of NEW Kitten calls a lot of this "artificial expertise." I want maximum "essential" expertise. Does Nim provide that?
10:23:09skyfexWhat is artificial/essential expertise?
10:25:11BlaXpiritrkj-b, nim has best parts of different languages
10:25:22BlaXpiritit is a serious language
10:25:25skyfexI would say Nim is easier to get into, especially if you have experience with the languages it's inspired by - Python, Pascal, C ... And you don't need to learn the crazy memory management in Rust (which might be intuitive if you've used smart pointers etc. in C++). But there's still things in Nim that are quite hard - in particular the macro system and maybe the experimental
10:25:25skyfextypeclasses (those are buggy too)
10:25:53BlaXpirityou say macros are hard, but other languages don't even have anything like that
10:26:02BlaXpiritso you could say you don't need to learn them at all
10:26:07skyfexTrue
10:27:03UberLambdaHow can I tell the nim compiler where to output the nimcache folder and the executables?
10:27:06skyfexThat should be stressed - you don't need to learn them, but they're very powefuly if you do
10:27:08BlaXpiritand I have a 1-line macro for a quick dirty thing to avoid code repetition parse_stmt("method class(self: $1): string = \"$1\"" % $typ)
10:27:49BlaXpirityes, "method class" xDS
10:27:50rkj-bArtificial expertise = You make up a game, say baseball, or legal codes, and play by "artificial " (made up) rules. Essential expertise = You learn natural laws, say of chemistry, and then build stuff based on those realities.
10:28:20BlaXpiritrkj-b, nim tries to be useful, not pure
10:28:55*novist quit (Ping timeout: 244 seconds)
10:28:58BlaXpiritit is a pretty normal language, if you don't consider how awesome it is
10:29:22rkj-bSounds like some of my former girlfriends. I miss them so.
10:29:53*novist joined #nim
10:30:58skyfexrkj-b: I find that distinction a bit funny in programming languages, it's all abstractions on abstractions on abstractions.. and the rules are made up all along the way down to the hardware ;)
10:31:30skyfexAlthough I guess you could argue that certain algorithms are "essential"
10:35:32Demon_Foxnim is like French compared Latin if you were to compare it to C.
10:38:09skyfexI guess many programmers consider the common hardware architecture (von neumann or harvard style, RISC, register based) the "natural" laws.. and abstracting upon that (Garbage Collection etc) is making up artificial rules.. but as a hardware engineer I see the hardware as artificial rules too. There are others.. they're just not popular
10:38:30rkj-bI want the language to be more like math; less like a chess game.
10:38:50BlaXpiritthat's, like, pure functional programming
10:39:04BlaXpiritif you bring up math
10:39:13skyfexAh, ok, then I misunderstood what was considered natural
10:39:13BlaXpiriti think your analogy is just not good
10:39:18skyfexSo you want Haskell :P
10:40:09Demon_FoxI know that perl is modeled after language itself
10:40:18*VinceAddons joined #nim
10:40:20BlaXpiritwat
10:40:22Demon_FoxA linguist designed much of it
10:40:35BlaXpiritbut you can't even read perl, what are u talking about
10:40:51Demon_FoxWell, think of it like a different language entirely
10:41:09BlaXpirita cipher?
10:41:16Demon_FoxTHink of it like:
10:41:25Demon_FoxIf you only knew English and tried to learn Japanese
10:41:42BlaXpiritno, but it's something even natives can't read
10:41:45Demon_FoxYou think Japanese is weird and unreadable
10:41:45BlaXpiritthis is offtopic anyway
10:41:53Demon_FoxI know, my bad
10:42:09skyfexI think Nim is quite "mathy" for a imperative language.. both in terminology (using the name "procedures" instead of "functions") and in implementation (not allowing operations that discard information)
10:43:33skyfexBut it doesn't define integers down to their root definition, so it's not that "hardcore"
10:45:19rkj-bI studied linguistics in school, and then as an amateur for ten years. My conclusion is it has nothing whatsoever to do with either math nor programming. I don't want a computer language to be either much like math or human language; just "close to conceptual essential concepts.
10:47:11BlaXpiritwhat can we say about Nim in its channel
10:47:14BlaXpiritexcept for "is good"
10:47:45BlaXpiritlibraries are lacking, sure, but that's a matter of time
10:48:05rkj-bIt can be learned in less than ten years???
10:48:34BlaXpiritit hasn't existed for ten years -_-
10:48:48BlaXpiritand yet, there are people who know it
10:48:52BlaXpiritso there is your answer :p
10:49:29Demon_FoxSome could argue that you can't learn truly C in 10 years
10:49:51*NimBot joined #nim
10:50:33vegaiobligatory http://norvig.com/21-days.html
10:54:03BlaXpiritdocopt has been ported to nim!!!
10:54:10BlaXpiritmark this amazing moment in history
10:55:07BlaXpiritnow, for testing and formalities
10:55:24BlaXpirithttp://docopt.org/ btw
10:59:16*akiradeveloper_ quit (Ping timeout: 246 seconds)
11:06:11*Trustable joined #nim
11:13:19*renesac quit (Quit: Page closed)
11:20:26skyfexBlaXpirit: I didn't know about that project, that looks great ^_^
11:20:53BlaXpirittesting might be a bit more difficult than i expected. https://github.com/docopt/docopt/blob/master/testcases.docopt
11:21:24BlaXpiritunless, of course, i write the testing program in python
11:24:42skyfexWhy would it be harder in Nim?
11:24:58BlaXpiritskyfex, because I don't know my way around it
11:25:00BlaXpirit:3
11:25:06BlaXpiritand because JSON parsing is a huge pain
11:26:06BlaXpiritare there any nontrivial examples of json parsing?
11:26:58BlaXpiritbah i guess it's not so bad; my biggest problems are these arbitrary field names "fnum" "bval"
11:43:45Demon_FoxI thought that nim would have a library for it by now
11:45:03BlaXpiritlapp exists
11:45:13BlaXpiritbut it seemed strange to me
12:19:06gokrBlaXpirit: Good work man!
12:19:10BlaXpiritthx
12:19:25gokrI just took Lapp since it was the one existing that did it like that.
12:22:17wanBlaXpirit: didn't someone else write a docopt for nim long ago? https://github.com/acolley/docopt.nim (haven't tested it)
12:22:31BlaXpiritthere are a lot of "todo" in it. it's unfinished and abandoned
12:23:03BlaXpiritalthough maybe it was almost done and i shouldve looked at it :p
12:23:56flaviuBlaXpirit: not enough comments, and nim tends to be very dense.
12:57:02*rkj-b quit (Quit: ChatZilla 0.9.91.1 [Firefox 34.0.5/20141126041045])
13:00:09*Jesin quit (Quit: Leaving)
13:12:07*EXetoC joined #nim
13:24:38dom96BlaXpirit: Does it work at compile-time? :P
13:24:44BlaXpiritdom96, it might
13:24:50BlaXpiritdom96, no
13:24:51BlaXpiritwait
13:24:53BlaXpiritno T_T
13:24:56dom96It should.
13:24:58BlaXpiritre
13:25:15dom96whyyyy
13:25:26dom96write a parser using parseutils
13:25:30BlaXpiritnnnnope
13:25:41BlaXpiriti have no idea how docopt works
13:25:57BlaXpiriti worked as py2nim
13:26:06BlaXpiritget it
13:26:42dom96Perhaps it would be better to write a DSL in which you specify the args.
13:27:03BlaXpiritperhaps not??
13:27:27dom96Why?
13:27:42BlaXpiritexactly, why?
13:28:31dom96Because depending on re sucks.
13:28:53BlaXpiritwell rewriting that to nim sucked in the first place
13:29:06dom96it did? Why?
13:29:31BlaXpiritbecause it is possible to use C++ implementation lol
13:29:48BlaXpiritdom96, tell you what
13:29:59BlaXpiritbetter rewrite re in nim than complain about its use
13:31:02dom96i'm not sure what you mean.
13:31:06dom96C++ implementation?
13:31:12BlaXpiritc++ implementation of docopt
13:31:13*gmpreussner__ joined #nim
13:31:24BlaXpiritmay be possible to wrap it and whatnot
13:31:30*gmpreussner_ quit (Ping timeout: 244 seconds)
13:31:38BlaXpiritbut no, i went the hard way
13:33:55BlaXpiritbut i don't think there is any implementation that doesn't use regex
13:41:16*johnsoft quit (Ping timeout: 265 seconds)
13:42:19*johnsoft joined #nim
13:43:56*matkuki joined #nim
13:44:45matkukiflaviu: A question about your OOP macro?
13:44:54flaviumatkuki: sure
13:45:03flaviuI was away when you first asked
13:45:10matkukino problem
13:45:58matkukiIs there a way for the procs/methods not to have to be declared sequentially?
13:46:37matkukiFor example, you cannot call a proc/method that is declared later in the class in a preceding proc.
13:46:46*alelos joined #nim
13:48:19matkukiOther than that, the macro work beautifully!
13:48:29matkukisorry, works.
13:48:58*BitPuffin joined #nim
13:50:02flaviumatkuki: sure, I guess you could iterate over all the methods and procs and create forward declarations.
13:52:23flaviugenerate the ast for the body as in `for node in body.children:`, but place it in a temporary variable before adding it to the result. So you then iterate over the different procs and methods and creates forward declarations.
13:53:17flaviudoes that make sense? I'm not sure I phrased things well.
13:53:58matkukiYes makes perfect sense, will try it thanks.
13:54:55matkukiIf I get stuck I'll ask you for help. I'm still only a beginner in macros.
13:55:22*Trustable quit (Remote host closed the connection)
13:59:14*akiradeveloper joined #nim
13:59:34*akiradeveloper quit (Client Quit)
13:59:57*akiradeveloper joined #nim
14:00:27akiradeveloperHi
14:01:12akiradeveloperI want to read out a part of sequence of some type T as in the following code https://gist.github.com/akiradeveloper/7cd6b4cea289759e6364
14:01:32akiradeveloperdo you explain why this fails complation?
14:02:51BlaXpiritdo not use cast
14:02:52BlaXpiritgee
14:03:03BlaXpiritwhat is this anyway?
14:03:46BlaXpiritmaybe u wanted cast[uint](p)[]
14:03:52BlaXpiritno..
14:03:59BlaXpiritnvm
14:04:08akiradeveloperA request from fuse client has a sequence of data that starts from a header. I want to read out the data as the header type
14:04:51*gunn quit (Ping timeout: 264 seconds)
14:06:23BlaXpiritakiradeveloper,
14:06:25BlaXpiritlet v = getT[uint64](mySeq) # ok
14:06:34*gunn joined #nim
14:07:14*sillesta joined #nim
14:08:51akiradeveloperit is ok... why? why mySeq.getT(uint64)() still fails
14:09:14BlaXpiritdot is weird, that's all i can say. all kinds of bugs related to it.
14:09:53akiradeveloperBlaXpirit, much thanks. I was all lost.
14:10:58*akiradeveloper quit ()
14:13:53EXetoCit does make complex expressions more readable imo, and most people don't seem to have a problem with it
14:14:57BlaXpiritEXetoC, dot is great, it is also easily abusable, but i am not talking about this
14:15:11BlaXpiritjust saying it is buggy
14:16:51EXetoCI know it doesn't really work with templates, that's all
14:17:39BlaXpiritalso generics...
14:18:04BlaXpiritas seen in this very example
14:18:34EXetoCsame underlying issue then maybe
14:19:33*gmpreussner__ quit (Ping timeout: 244 seconds)
14:20:18*gmpreussner__ joined #nim
14:25:32*jefus__ joined #nim
14:27:42*gmpreussner___ joined #nim
14:27:49*gmpreussner__ quit (Ping timeout: 244 seconds)
14:29:27*jefus_ quit (Ping timeout: 272 seconds)
14:42:35*Demon_Fox quit (Quit: Leaving)
14:42:48*gmpreussner___ quit (Ping timeout: 244 seconds)
14:43:05*gmpreussner___ joined #nim
15:02:35*jefus__ is now known as jefus
15:10:38*keyle quit (Quit: Morbo: Chitchat achieved!)
15:20:36*gmpreussner joined #nim
15:21:02*gmpreussner___ quit (Ping timeout: 244 seconds)
15:21:36*skyfex quit (Quit: (null))
15:24:29*MattAitc_ joined #nim
15:29:03*MattAitc_ quit (Remote host closed the connection)
15:30:33matkukiflaviu: A little help please. I added this code (https://bpaste.net/show/1f39ee1413fd) before the existing "for node in body.children:" line.
15:30:45matkuki I get the error "Error: illformed AST: proc MyProc*{this :MyClass} =" !
15:32:10EXetoChave you stringified the nodes in order to see why it happens?
15:34:10flaviumatkuki: Instead of p.body = newStmtList(), try p[6] = newEmptyNode()
15:34:34flaviugeneral workflow is to use dumpTree to figure out what AST you want to target, and then write the code to get that AST.
15:35:28matkukiflaviu: let me try it ...
15:36:01BlaXpiritwhat is the conventional name for a function that converts something to int?
15:36:26EXetoCtoInt?
15:36:29BlaXpiritwell actually... in my case it's not really conversion
15:36:58BlaXpirit"get int value"
15:37:04BlaXpirittoInt may be best, yeah...
15:39:57EXetoCwhat are you converting?
15:40:34BlaXpiritEXetoC, a variant type
15:40:38BlaXpiritmuch like json value
15:40:55BlaXpiritJsonNode
15:41:36*kapil__ quit (Quit: Connection closed for inactivity)
15:41:46BlaXpiriti want this stuff to be more convenient than checking for kind and getting member intV or something
15:41:50*booly-yam-2084 joined #nim
15:44:26EXetoCgetInt?
15:45:23EXetoCthat seems more appropriate. what will it do if the field is inaccessible?
15:45:42BlaXpiritEXetoC, the user is supposed to know the type of the field beforehand
15:45:51BlaXpiritso in case it's not int, exception will be thrown
15:46:25BlaXpiriti could avoid variant type and just generate variables with macros instead,
15:46:32BlaXpiritbut sadly, "re" is not available at compile time
15:46:52EXetoCan exception will be raised anyway
15:47:09EXetoCyou want to use some other exception type?
15:47:34BlaXpiritnah
15:47:38matkukiflaviu: p[6] = newEmptyNode() removes the "=" from the error message. Looking at the dumpTree of the "forward_declarations" statement list variable, it seems that the bodies of the procs are still there. Why?
15:47:44BlaXpiriti was thinking of making converters...
15:47:55EXetoCok well in that case
15:49:34EXetoC'toInt' would be better then
15:49:42*booly-yam-2084 quit (Remote host closed the connection)
15:49:56BlaXpiritok thanks
15:50:25flaviumatkuki: Sorry, can't help you right now. I'll be back later
15:50:52matkukino problem
15:52:51*yonson quit (Ping timeout: 264 seconds)
16:01:03*matkuki quit (Quit: ChatZilla 0.9.91.1 [Firefox 35.0/20150108202552])
16:09:30*saml_ joined #nim
16:11:41*darkf quit (Quit: Leaving)
16:15:39*gunn quit (Quit: My MacBook Pro has gone to sleep. ZZZzzz…)
16:24:40BlaXpirithttps://github.com/BlaXpirit/docopt.nim
16:25:32EXetoCnot man enough to not use re? ;)
16:25:46EXetoCthat's great. I've wanted an equivalent of docopt
16:26:23BlaXpiriti do not understand how docopt works
16:26:27BlaXpiritit is a direct rewrite
16:26:43BlaXpiritdocopt.py uses re, i use re
16:27:06EXetoCj/k ofc
16:28:17*sdw joined #nim
16:29:02EXetoCcan descriptions and such span multiple lines?
16:29:18BlaXpirituh probably
16:29:33BlaXpiritdocopt has detailed documentation
16:30:51EXetoCyour port that is, but I will try it some time
16:30:54BlaXpiritlooks like they can. i simply tried
16:31:14BlaXpiritEXetoC, my port is supposed to be identical
16:31:42BlaXpiritTests passed: 170/174
16:31:51BlaXpirittoo tired to debug any more
16:32:05BlaXpiritbut these are kinda corner cases
16:32:56*dyu joined #nim
16:33:24BlaXpirithopefully i can add it to docopt organization and boost Nim a bit
16:34:45EXetoCyou could also implement args["foo", bool], with a default type
16:35:13BlaXpiritEXetoC, what do you mean "default type"
16:35:21EXetoCit's just a suggestion. I like to specify the actual type
16:35:31BlaXpiritalso, args is an ordinary Table
16:35:31EXetoCT: typedesc = string
16:35:38EXetoCok
16:36:21dom96"Someday you will be a Nim Legend, like dom96."
16:36:24BlaXpiritlel
16:36:25dom96Looks like I have a fan girl.
16:36:37EXetoCthe instantiation makes it a unique type though, so you can just "extend" it
16:37:05BlaXpiritnice, nice.
16:38:36BlaXpiriti was thinking that there definitely should be a converter to bool, converter $ for string, converter toInt, [] index access
16:39:00dom96BlaXpirit: Converter from what to bool?
16:39:06BlaXpiritfrom variant type
16:39:39dom96oh, when you say converter you don't mean an actual converter.
16:39:46BlaXpiritI do :|
16:39:46*nimnoob joined #nim
16:39:54dom96That wouldn't work.
16:39:57BlaXpirithttps://github.com/BlaXpirit/docopt.nim/blob/4f51d4a4e1ffeea19dbe5bd2fd4f33d7a25c1ba3/src/docopt.nim#L13 - I want convenient access to these
16:40:03dom96You can't have two converters on the same type
16:40:07BlaXpirit:o
16:40:12BlaXpiritno way
16:40:21dom96hrm, or maybe you can.
16:40:27BlaXpiriti was sure you can
16:40:29dom96But that will lead to errors.
16:40:35dom96Runtime errors.
16:40:37dom96It's not a good idea.
16:41:10EXetoCyou could reduce bloat by allowing the table to be generated at compile-time :p
16:41:21BlaXpirityes, yes, that's what i thought right away
16:41:31EXetoCdom96: that's true either way, isn't it?
16:41:38BlaXpiritsearch that source file for "re(r"
16:41:44BlaXpiritto see what i'd have to deal with
16:41:49dom96EXetoC: It is. But converters are implicit.
16:42:31BlaXpiritdom96, the types of these values are the same every single invokation of the program
16:42:55dom96huh?
16:43:04dom96Let's use json as an example.
16:43:09dom96You have converters for each node type.
16:43:12BlaXpiritjson is json
16:43:16BlaXpiritbut i'm talking about my case
16:43:24dom96You pass a Node which is a JFloat to a proc which takes an int.
16:43:38dom96The converter invoked will try to access .num and that will result in a runtime error.
16:43:39sillestacoming from c++ OO (eg. EntityFoo extends Entity) game dev, is there any significant differences in how it would/should be done? does nim offer something different than just ordinary OO?
16:43:45BlaXpiritdom96, yes...
16:43:59*JinShil quit (Quit: Konversation terminated!)
16:44:04BlaXpiritbut consider that the kinds of these doesn't depend on user input
16:44:05dom96I'm assuming you've got fields which are not accessible based on the kind since it is an object variant?
16:44:14BlaXpiritif it breaks once, the programmer will know and fix it
16:44:44BlaXpiritsillesta, generic are nice
16:44:47BlaXpiritgenerics
16:44:59EXetoCcouldn't <x> be anything?
16:45:18BlaXpiriteven if it's 9, it's a string "9"
16:45:33sillestaBlaXpirit: from the little nim i know, i'm guessing dynamic dispatch is similar to marking methods as 'virtual' in c++
16:45:34BlaXpirit"anything" is always a string
16:45:47BlaXpiritsillesta, yes. method is almost exactly like virtual
16:46:04BlaXpiritbut dispatch works differently, no vtables blah blah i don't know this
16:46:20*UberLambda quit (Quit: Leaving the Matrix)
16:47:49*zahary quit (Read error: Connection reset by peer)
16:48:15EXetoCwhen is val(int) invoked?
16:48:18*zahary joined #nim
16:48:38BlaXpiritit's for internal use
16:48:45BlaXpiritoh but you probably mean internally
16:49:00BlaXpiritval(0) val(1)
16:50:08BlaXpirithm can it really never be a different value?
16:50:18EXetoCI thought that type was used in some other way
16:51:02BlaXpirit[:25:42] <BlaXpirit> i do not understand how docopt works
16:51:08EXetoCmaybe range constraints and such can be specified outside the string, but then you need to reference the flags somehow
16:51:57*endou______ quit (Ping timeout: 272 seconds)
16:52:53*CARAM__ quit (Ping timeout: 245 seconds)
16:54:26*BlaXpirit_ joined #nim
16:54:28BlaXpirit_it appears i dropped connection
16:54:55BlaXpirit_EXetoC, int value is for this: prog -p...
16:55:16BlaXpirit_prog -p -ppp args["-p"].int_v == 4
16:55:38BlaXpirit_but how it manages to get to 4 if i only create them with 0 and 1 values - who the heck knows :p
16:56:44BlaXpirit_ah right. int_v += increment.int_v
16:56:58EXetoCwhy do you need a variant for that purpose?
16:57:24BlaXpirit_EXetoC, ...
16:57:26*BlaXpirit quit (Ping timeout: 264 seconds)
16:57:32BlaXpirit_i need a variant to avoid thinking
16:57:43BlaXpirit_in python everything is a variant of everything
16:58:48BlaXpirit_avoiding a variant would require big changes in implementation
16:59:00BlaXpirit_these things are passed around in all kinds of nodes
17:03:35EXetoCI'm only asking
17:04:42BlaXpirit_now that i think about it, int_v is actually count
17:06:54*nimnoob_ joined #nim
17:06:54*nimnoob quit (Read error: Connection reset by peer)
17:11:34*brson joined #nim
17:11:35*nimnoob_ quit (Ping timeout: 256 seconds)
17:25:13*gokr_ joined #nim
17:35:56*nimnoob_ joined #nim
17:38:02*endou______ joined #nim
17:40:23*nimnoob_ quit (Ping timeout: 240 seconds)
17:42:06EXetoCBlaXpirit_: why is it important for docopt.nim to remain identical with docopt?
17:42:34BlaXpirit_EXetoC, because that is everything the project is - a direct copy of docopt
17:42:47BlaXpirit_i intend to add it to docopt organization
17:43:08BlaXpirit_also, i have no clue how to add features to it :3
17:43:57BlaXpirit_EXetoC, i am planning to make ..._v members private
17:45:07BlaXpirit_then "len" would access int (or len of seq), `@` would access seq, converter toBool, `$` string (and anything else)
17:45:32BlaXpirit_seems cool to me, but maybe it's a bit too crazy
17:45:40EXetoClen for int?
17:45:57BlaXpirit_yeah
17:46:16BlaXpirit_[:54:14] <BlaXpirit_> EXetoC, int value is for this: prog -p... [:54:35] <BlaXpirit_> prog -p -ppp args["-p"].int_v == 4
17:46:26BlaXpirit_and i'm pretty sure that's the only thing int value is used for
17:46:29EXetoCjust think about whether or not the trade-off is a net positive. implicit conversions are a source of confusion obviously
17:46:40EXetoCright. I forgot
17:47:08*CARAM__ joined #nim
17:48:19EXetoCyou mean a converter for bool only?
17:50:06BlaXpirit_yes
17:53:34EXetoChow about another repo or branch for the direct port?
17:54:34BlaXpirit_EXetoC, how about a fork for additional functionality
17:54:42BlaXpirit_(which I do not intend to make)
17:54:55ekarlsowhat u guys doing ? ^
17:55:25BlaXpirit_ekarlso, http://docopt.org/ in Nim: https://github.com/BlaXpirit/docopt.nim
17:57:46BlaXpirit_it's not like i'm more fit to make additional functionality than anyone else.
18:02:32EXetoCfork and rename to just 'docopt'?
18:03:47BlaXpirit_this is not just 'docopt', this is a port of docopt to nim
18:04:04BlaXpirit_and that's the naming convention they use in docopt organization
18:04:12BlaXpirit_http://github.com/docopt/
18:04:57BlaXpirit_but yeah, you can probably fork and rename it, i suppose
18:08:06ekarlsoawesome BlaXpirit_ !
18:18:30flaviuBlaXpirit_: I'll see if I can fix the bugs.
18:18:40BlaXpirit_flaviu, u mean docopt?
18:18:43flaviuyep
18:18:45BlaXpirit_ok cool
18:18:46EXetoCBlaXpirit_: I noticed that, and I was referring to the extended lib, which would be the fork
18:19:16BlaXpirit_EXetoC, i still like to have name of the programming language in repos of the things i make
18:19:21BlaXpirit_cuz why not
18:19:37BlaXpirit_and not having them can be harmful if i want to make the same thing in a different language
18:19:42EXetoCsame name? but adding that to nimble instead
18:20:03BlaXpirit_EXetoC, to that I can't agree :s
18:21:05BlaXpirit_it would be something different, which is not docopt anymore
18:21:17flaviuBlaXpirit_: Btw, instead of this mess: re.re(r"\[default: (.*)\]", {reIgnoreCase}), you can do `re"(?i)\[default:\s(.*)\]`
18:21:38BlaXpirit_oh ok
18:21:49BlaXpirit_flaviu, can't remove "re.re" though :p
18:21:57BlaXpirit_some bug prevents direct use
18:22:50EXetoCfine some other name then :p
18:22:57*dyu quit (Quit: Leaving)
18:23:01BlaXpirit_flaviu, does using flags like that cancel out the default flags?
18:23:10BlaXpirit_because i don't need extended
18:23:18BlaXpirit_(it actually caused 1 bug)
18:23:26BlaXpirit_or i suppose i could work around that
18:23:29flaviunope, which is why I used \s instead of space.
18:23:44BlaXpirit_flaviu, should be "\ "
18:23:58EXetoCyou should close the issue then
18:24:02BlaXpirit_kinda lame that you can't cancel out extended though
18:24:18EXetoCoh. nvm
18:24:26BlaXpirit_i was just so quick, EXetoC :p
18:25:28BlaXpirit_EXetoC, you know what i was thinking? it's not so important to have validation be part of doc message, and it can sometimes be too much
18:25:49EXetoCcan we add the docopt fork to the official organization?
18:25:54BlaXpirit_it's quite easy to just walk through options and check their values
18:26:09BlaXpirit_EXetoC, uhh no?
18:26:31BlaXpirit_we can, however, add fork to README of the main one if it's something good
18:26:32EXetoCBlaXpirit_: the official nim organization
18:27:05EXetoCBlaXpirit_: yes, with a good old 'case' block, and possibly some abstractions for the constraint checking
18:27:12BlaXpirit_EXetoC, hmmm why would it be there though? i think the organization is "bloated" :D
18:27:34BlaXpirit_but it's not like i can forbid it
18:27:44BlaXpirit_doesnt really matter to me
18:27:47EXetoCdom96: thoughts? is it bloated?
18:29:23dom96EXetoC: Yes.
18:31:09EXetoCI could move 'mongo' to my user, as well as removing it from nimble until I actually have something that can be used
18:36:47*nimnoob_ joined #nim
18:41:23*flaviu quit (Read error: Connection reset by peer)
18:41:27*nimnoob_ quit (Ping timeout: 264 seconds)
18:41:38*flaviu joined #nim
18:49:53*jefus quit (Ping timeout: 240 seconds)
18:59:35ekarlsohttps://bpaste.net/show/d8cfadab2734 < is there a better way to define that ?
18:59:54*badkins joined #nim
19:00:43fowlmouthekarlso, proc`%`(s: SignatureAlgorithm): JsonNode{.borrow.}
19:00:49ekarlsoborrow ?
19:00:52EXetoC'Type'?
19:01:10EXetoCit is not the same as 'type' now though
19:01:54ekarlsohmm
19:01:59ekarlsocan you do a enum on a string ?
19:02:47EXetoCenumerators can be strings, yes
19:03:06EXetoCtry it :p
19:03:24BlaXpirit_mm i totally forgot this
19:04:12*Jesin joined #nim
19:08:10*rkj-b joined #nim
19:20:26*alexruf joined #nim
19:25:24*yonson joined #nim
19:30:33*Demos joined #nim
19:31:29*benji_ joined #nim
19:31:38*benji_ is now known as benji
19:32:30*matkuki joined #nim
19:34:35matkukiflaviu: Are you here?
19:34:42flaviuyep
19:35:52matkukiHere is my class macro that doesn't work: https://bpaste.net/show/c60303139ac8
19:36:40matkukiThe added stuff starts at line 82
19:37:29benjiHi all! I'm playing with nim and I have run into an issue I can't figure out: I have a program that compiles and works (http://paste.ubuntu.com/9769301/) but when I wrap the bulk of the program in a function (http://paste.ubuntu.com/9769293/) I get a compile error: http://paste.ubuntu.com/9769315/
19:40:36*alexruf quit (Quit: Textual IRC Client: www.textualapp.com)
19:41:03matkukiflaviu: here is my example class and the error message: https://bpaste.net/show/48cf029dd157
19:41:11flaviumatkuki: https://gist.github.com/5fa79727c472882ae21a
19:41:32flaviuSee how instead of copying that code, I instead add the procedures to a list?
19:41:47flaviuI then use that list to create the regular definitions and the forward declarations.
19:42:33matkukiAhh, brilliant!
19:42:36EXetoCmatkuki: are you also inspecting the equivalent code?
19:43:16EXetoCok you are
19:43:35matkukiEXetoC: I'm not sure what you mean by that. I'm not that good at macros
19:43:41dom96benji: Your procedure names shouldn't start with a capital letter.
19:44:02*benji applies ~
19:44:40dom96That's an interesting issue though.
19:45:02dom96oh, I know why.
19:45:12dom96When you put a proc into another procedure you are turning it into a closure.
19:45:27dom96When it's in the global scope it is using global variables
19:45:30dom96so it's not a closure
19:46:08benjitrue... I don't see how that changes it's signature though (which is how I interpret the compiler error)
19:46:40benjiand in this case I still want it to be a closure because it closes over the variable "file"
19:47:47EXetoCmatkuki: some parts of the AST can be assembled with the help of templates: http://nim-lang.org/macros.html#getAst,expr
19:48:06dom96benji: You can't pass a closure to a C function which expects a function pointer.
19:48:19EXetoCwhich will improve the readability of the macro body
19:48:20benjiah! now that makes sens
19:48:26benjie
19:48:41dom96the error definitely needs to be improved though
19:49:30matkukiEXetoC: I used treeRepr and lispRepr up to now. Will try it.
19:49:58EXetoCmatkuki: that's for debugging though
19:52:11EXetoC.eval macro foo: stmt =; template echoStuff = echo "hi"; result = newStmtList(getAst(echoStuff())); foo() # matkuki
19:52:14MimbusEXetoC: hi
19:52:50BlaXpirit_:o
19:53:06EXetoCBlaXpirit_: hi-tech innit
19:53:14BlaXpirit_so templates really are convenience wrappers for macros
19:53:23benjidom96: is there a way to get a pointer to the closure or something similar?
19:54:23dom96Even if there was that wouldn't work. The closure is coupled with its environment which the C code will know nothing about.
19:54:25flaviubenji: Even if you do, where is it going to get it's implicit environment argument?
19:54:43benjimagic!
19:54:44dom96I'm afraid you simply cannot pass closures to C libraries.
19:54:46benji;)
19:54:48EXetoCBlaXpirit_: they were not designed specifically for that
19:55:44benjiI guess it's back to using a few carefully chosen globals then. Thanks for the help!
19:56:50benjidom96: oh, I was curious why procedures shouldn't start with a capital, is that a style thing or is there some semantic that I don't know about yet?
19:57:29dom96benji: It is a style thing. Types are supposed to start with a capital.
19:57:40def-benji: https://github.com/Araq/Nim/wiki/NEP-1-%3A-Style-Guide-for-Nim-Code
19:57:52benjicool, thanks both of you
20:04:50EXetoCBlaXpirit_: call it directly rather than passing to an expr/stmt and the template body will be evaluated at the current scope (templates return stmt by default)
20:04:59*rkj-b quit (Quit: ChatZilla 0.9.91.1 [Firefox 34.0.5/20141126041045])
20:06:20reactormonkCan I execute arbitrary code after the nim compiler compiles to C, before invoking the GCC?
20:06:31matkukiflaviu: Works great! You use a lot of indexes "[x]" on nodes. Is there a nim-by-example for a bit more detailed look into macros?
20:07:14flaviumatkuki: No, but the direct indexes can be seen in the dumpTree output.
20:07:33flaviuI like to place a comment with the tree next to whenever I use indexes.
20:07:41EXetoCthe node formats are fixed. I think there are more descriptive ways to achieve the same thing though
20:07:44matkukiOk, thanks.
20:08:23EXetoCin the form of procs in the macro module. I don't know if something is missing, but that'd then be preferable
20:08:59EXetoCthis for example http://nim-lang.org/macros.html#name=,PNimrodNode,PNimrodNode
20:10:43matkukiEXetoC: Thanks. Yes, if ".body" is used instead of "[6]" it also works. It's more readable to me.
20:12:11matkukiEXetoC: I tried the macro you showed. Can you explain it's purpose? I compiled it and it just echo's "hi"?
20:16:40EXetoCthe purpose is to improve readability. see the output of result.repr
20:17:50matkukiAh, great!
20:19:10EXetoCthis example is simple though. the difference in readability will be more pronounced when the AST is more complex
20:27:45Araqbenji: you can use system.rawEnv and system.rawProc to convert a closure bakc into its ingredients
20:27:53Araqand thus get excellent C interop
20:28:11Araqit's just that it is not widely known here in #nim ... :P
20:28:25benjiAraq: cool, I'll look those up in the docs. Thanks!
20:29:06flaviuAraq: I'm not sure what happens here: https://gist.github.com/flaviut/038804143b26ddf6fafa
20:29:27flaviuIt's not supposed to have a kind field when T is a ref, but the c output still has one.
20:32:03Araqflaviu: I guess the compiler evaluates 'isRef' for the generic T?
20:32:21Araqwhich is false and then it's never checked for the actual instantation
20:35:27*yonson quit (Ping timeout: 264 seconds)
20:36:41Araq(it's a bug of course ...)
20:37:09*jefus joined #nim
20:39:17flaviuAraq: That was my hunch. I'll report it.
20:45:19*rpag joined #nim
20:49:33*BlaXpirit joined #nim
21:00:39*gokr_ quit (Ping timeout: 245 seconds)
21:12:04matkukiIf a type has an enum field that has enumerations that don't start with 0 I get "Error: field not initialized: fieldname" ?
21:12:11matkukiExample: https://bpaste.net/show/98716eadbeb1
21:12:43matkukiIs this a meant to be this way?
21:12:45flaviumatkuki: That sounds like it's as expected.
21:13:06flaviuIt doesn't really make sense to have a 0 for an enum where a 0 has no meaning.
21:14:18flaviumatkuki: Note that `var testobj: MyType` works fine.
21:16:56matkukiflaviu: Sorry, there is a error in the pasted code the last line! It should be "test_object: MyType = MyType ()"
21:17:26flaviumatkuki: I know, I figured it out while running the example
21:18:00flaviuMyType() is an initializer for MyType, so it must not allow invalid values.
21:21:42matkukiflaviu: So it's mandatory to add these kind of enum fields to the initializer?
21:22:10flaviumatkuki: Yes, but if you don't want to, then you can just do `var testobj: MyType`
21:22:33flaviuand initialize the field however you'd like.
21:22:36EXetoCor have a construction proc of course
21:23:57flaviuhttps://github.com/Araq/Nim/issues/1693
21:23:57flaviuHopefully Araq'll agree to it if I'm annoying enough :P
21:26:10matkukiEXetoC: Can you give me an example of an initialization proc?
21:27:45EXetoCmatkuki: initFoo(x: int): Foo = result = Foo(x: x)
21:28:14EXetoCI prefer to assign to result whenever possible, so as to make it easier to extend
21:28:30matkukiThanks!
21:29:14EXetoCmatkuki: and for pointer types: "newFoo(x: int): ref/ptr Foo = result = (ref/ptr Foo)(x: x)"
21:30:30EXetoC"(ptr Foo)()" being sugar for "new result; result[] = Foo(x: x)" ([] dereferences a pointer)
21:30:48matkukiGot it.
21:37:59matkukiEXetoC: I like "init(f :var Foo, x: int) = f = Foo(x: x)", so I can do "foo.init(12)". Is this considered bad Nim style coding?
21:43:29EXetoCmatkuki: no, but the disadvantages are the inability to use 'let', and the fact that an additional statement is needed
21:44:54EXetoCAraq: would the pragma that you talked about before allow 'let' to be used for such an init proc, or would that require another addition?
21:50:05*BlaXpirit quit (Ping timeout: 244 seconds)
21:50:11*shodan45 quit (Quit: Konversation terminated!)
21:50:41*shodan45 joined #nim
21:52:28EXetoChas further reductions of the stdlib size been discussed on the forum?
21:53:53*shodan45 quit (Client Quit)
21:54:33EXetoCdom96: that would be an easy change, but is it possible to create meta packages?
21:55:03dom96what is an easy change?
21:55:54EXetoCdom96: what I said prior to that
21:56:16EXetoCI don't know who other than BlaXpirit_ cares about making it even smaller
21:56:45BlaXpirit_main thing i want is better documentation
21:56:49dom96This still needs to be finished https://github.com/Araq/Nim/issues/623
21:57:17BlaXpirit_i don't often say i want this or that removed from stdlib
21:57:28BlaXpirit_last time i said it, it was about a harmful buggy function
21:57:37EXetoCI'll continue the discussion there
21:57:44*alelos quit (Ping timeout: 245 seconds)
21:58:14BlaXpirit_so graphics was never moved out?
21:58:36EXetoC0.9.6 milestone? you prefer overestimations over underestimations? ;)
22:00:35dom96I think we need confirm some of those with Araq
22:12:13BlaXpirit_EXetoC, https://github.com/keleshev/schema#using-schema-with-docopt
22:12:22BlaXpirit_validation after the fact, no problems
22:13:27EXetoCI was leaning more towards such a solution
22:15:15BlaXpirit_of course, this heavily relies on python's dynamic nature :|
22:16:10EXetoCnim can do it too
22:16:57EXetoCand it only relies on a fixed set of types anyway
22:17:19BlaXpirit_umm have u looked at it?
22:17:25BlaXpirit_it turns a string into a file, etc.
22:19:22EXetoCI don't think it makes a difference
22:19:45benji+1 on docopt. I very much enjoyed using it on a couple of small projects.
22:20:18*alelos joined #nim
22:22:32EXetoCbenji: are you aware of the fact that it has been ported? https://github.com/BlaXpirit/docopt.nim
22:23:05*Trustable joined #nim
22:23:12EXetoCwe're discussing extending it in a fork, but it should be useful as is
22:23:12benjiEXetoC: nope; nice!
22:23:18benjicool
22:27:31BlaXpirit_EXetoC, my point was mainly that you don't need to add validation to docopt itself
22:29:44*alelos quit (Quit: WeeChat 1.1)
22:30:27EXetoCI was just thinking about abstractions for simplifying the validation
22:32:07flaviuBlaXpirit_: looks great! You should announce it on the forums.
22:32:23BlaXpirit_sure
22:32:27BlaXpirit_but i dont even know what to write
22:32:35*benji unlocks Nim achievement: "Code compiles on the first try after a significant edit."
22:32:39BlaXpirit_need some good introduction of what docopt even is
22:32:41BlaXpirit_benji, :D
22:33:10fowlmouthnothing impressive about docopt
22:33:19fowlmouthi only looked at the rust version btw
22:34:16flaviuWhat's the point of a more elaborate readme? http://docopt.org/ is excellent
22:34:44BlaXpirit_people won't immediately understand that it actually parses that message
22:34:56BlaXpirit_i cant see that plainly and visibly written anywhere
22:35:20BlaXpirit_well, actually there is, but it's not like people will carefully read it
22:35:37flaviuBlaXpirit_: Btw, you have it marked as 0.1.0, when the latest version is 0.6.2
22:35:57BlaXpirit_flaviu, first of all it's not even based on 0.6.2
22:36:01BlaXpirit_:s
22:36:10BlaXpirit_master
22:36:20BlaXpirit_doesnt have to be the same version number, really
22:36:41flaviuBlaXpirit_: Yes, but there haven't been changes after the 0.6.2 tag.
22:37:05BlaXpirit_you think so? https://github.com/docopt/docopt/blob/0.6.2/docopt.py vs https://github.com/docopt/docopt/blob/master/docopt.py
22:37:22BlaXpirit_err i should've linked the main page
22:37:32BlaXpirit_381 commits vs 430 commits
22:39:36flaviuI see.
22:41:38onionhammeranyone know the allowed pattern for `blah` idents
22:41:48EXetoCoperators
22:42:38EXetoChttp://nim-lang.org/manual.html#operators
22:43:20fowlmouthonionhammer, the grammar is in the manual
22:44:54fowlmouthkeyword || operator || ident iirc
22:49:19onionhammeryeahah thanks exetoc
22:53:37*tinAndi joined #nim
23:10:26*matkuki quit (Quit: ChatZilla 0.9.91.1 [Firefox 35.0/20150108202552])
23:19:40*ARCADIVS joined #nim
23:34:01gokrsillesta: Did you see my OO articles?
23:34:35sillestashoot me some links!
23:34:52gokrhttp://goran.krampe.se/category/nim
23:38:23EXetoCsugar for defining a getter and/or a setter in such a macro would be nice. it's such a common thing to do after all
23:51:11*gokr_ joined #nim
23:55:37*gokr_ quit (Client Quit)