<< 29-06-2018 >>

00:01:18FromGitter<skilchen> @Quelklef do you mean "typesafe heterogeneous containter"?
00:02:52FromGitter<Quelklef> Sounds about right
00:03:01FromGitter<Quelklef> but particularly one with very little syntactic or conceptual overhead
00:03:31FromGitter<Quelklef> Google tells me that people want them in Java, and I'm sure that exists, but I can't imagine tersely...
00:05:52FromGitter<Quelklef> I wonder how close you could get with Nim...
00:26:18*dddddd quit (Remote host closed the connection)
00:28:21*icebattle quit (Quit: leaving)
00:35:54*CodeVance__ joined #nim
00:37:45*CodeVance_ quit (Ping timeout: 260 seconds)
00:41:48*find0x90 quit (Quit: find0x90)
00:55:08*nasusiro quit (Quit: Quitting for now...)
01:07:58FromGitter<Varriount> @Quelklef Well, term rewriting macros and converters could do the wrapping and unwrapping, however there's no way to generate the types behind the scenes.
01:08:24FromGitter<Varriount> (without a compiler plugin or using a macro to generate the types)
01:10:34FromGitter<kaushalmodi> @honewatson Thanks :) I'm just trying to unbreak that module on Nim devel.
01:12:17FromGitter<kayabaNerve> @Varriount Question if you're still on
01:12:47FromGitter<Varriount> @kayabaNerve Sure, what is it?
01:13:02FromGitter<kayabaNerve> Can I simplify `ptr cuchar (addr string[0])`
01:13:12FromGitter<kayabaNerve> *cast
01:13:28FromGitter<kayabaNerve> Mobile Gitter has this weird bug if you send from the middle of a message...
01:13:38FromGitter<kayabaNerve> Is it just addr string?
01:14:00FromGitter<kayabaNerve> Or does the Nim string have some... Padding?
01:17:11FromGitter<Varriount> @kayabaNerve *Don't* do `addr stringVar`. A Nim string has a header before the character data.
01:17:23FromGitter<Varriount> I would seriously just use a `cstring` conversion.
01:21:05*francisl joined #nim
01:22:13*CodeVance joined #nim
01:23:27*CodeVance__ quit (Ping timeout: 240 seconds)
01:26:58FromGitter<kayabaNerve> Via .cstring or cstring(var) ?
01:27:37FromGitter<kayabaNerve> And that's why I did [0]. ;P
01:37:05*btbytes quit (Quit: My MacBook has gone to sleep. ZZZzzz…)
01:37:35*btbytes joined #nim
01:38:20*skrylar joined #nim
01:40:44FromGitter<Varriount> If you really want, you can put the cast into a template.
01:41:17FromGitter<Varriount> Or create a converter that automatically converts a string to a `ptr cuchar`
01:42:19*btbytes quit (Ping timeout: 265 seconds)
01:57:36*CodeVance quit (Quit: Leaving)
02:03:29FromGitter<kayabaNerve> I don't think I use it that often
02:04:19FromGitter<kayabaNerve> Question though. How does cstring() work? Isn't that a binary cast which would fail with padding/ aheader?
02:04:31FromGitter<kayabaNerve> Is there an override of sorts?
02:04:40FromGitter<kayabaNerve> Tbh I really don't understand how Nim strings work
02:12:16TangerkayabaMerve: Nim strings are a length and a pointer to a char array. When you cast a nim string to cstring, it just returns the pointer to the content of that string. Hence if you try read a nim string by pointer, you'll get the header data
02:13:25FromGitter<Varriount> @kayabaNerve Nim strings are defined here: https://github.com/nim-lang/Nim/blob/master/lib/system.nim#L420
02:13:59FromGitter<Quelklef> @Varriount That's kinda disappointing. Although (in theory) couldn't you have a `heterogenous_macro` macro that's used with a block i.e. `heterogenous_macro: \n code` so you wrap it around all of the code and it inserts types that way
02:14:13FromGitter<Quelklef> Like, it'd be used at the very very top-level of the file
02:14:55FromGitter<kayabaNerve> So my question is how does the cast just return the pointer?
02:16:04FromGitter<Varriount> @Quelklef You could do that too
02:16:08FromGitter<kayabaNerve> Also, after I use alloc, all I have to do is use dealloc, right? The manual is trippy. "This procedure is dangerous! If one forgets to free the memory a leak occurs;" Shouldn't it be forgetting to use dealloc is dangerous?
02:16:37FromGitter<Varriount> @kayabaNerve `cstring` is a kind of magic conversion that does `addr stringVar[0]` for you.
02:16:45FromGitter<kayabaNerve> No comment on whether I'm looking into this because I have a memory leak because I forgot to do dealloc...
02:17:07FromGitter<kayabaNerve> K. Magic. At this point, I'll take it. I was looking for an override in the compiler or a pragma, maybe a macro, but I'll take magic.
02:17:10FromGitter<kayabaNerve> If it works...
02:17:33FromGitter<Varriount> @kayabaNerve What do you mean? The pointer still points to the original string. `cstring(stringVar)` returns a pointer to `stringVar`'s data
02:17:50FromGitter<kayabaNerve> But how does cstring skip past the length?
02:18:18FromGitter<Varriount> It doesn't. A cstring has an implicit length of the null terminator.
02:18:55FromGitter<kayabaNerve> Wouldn't a binary cast, which is cstring IIRC, treat that length, which is before the char[], as a character?
02:19:06FromGitter<Varriount> No.
02:19:42FromGitter<kayabaNerve> I'm asking how it, in the cast, only handles a single element. Is the length after the null terminator?
02:19:48FromGitter<kayabaNerve> *single member
02:21:59FromGitter<Varriount> @kayabaNerve https://nim-lang.org/docs/system.html#[],openArray[T],BackwardsIndex_2
02:22:34FromGitter<Varriount> `addr` accepts a `var T`
02:25:55FromGitter<kayabaNerve> I'm asking how the string cast only affects the char. You said it's an implicit [0]. I'm asking how. Is that in the compiler, a macro in system.nim, or what. ⏎ ⏎ At this point, I'm fine with not knowing though.
02:26:26FromGitter<kayabaNerve> I still have the question about dealloc. I only have to use dealloc, right? The manual is trippy. "This procedure is dangerous! If one forgets to free the memory a leak occurs;" Shouldn't it be forgetting to use dealloc/using malloc is dangerous?
02:26:42FromGitter<kayabaNerve> *only have to use dealloc in order to clear malloc'd memory
02:27:12FromGitter<Varriount> @kayabaNerve Are you allocating anything with the generic memory allocation functions?
02:27:26FromGitter<kayabaNerve> alloc0
02:28:20FromGitter<Varriount> Yes, then you need to deallocate the memory.
02:28:31FromGitter<Varriount> What are you using alloc0 for?
02:29:48FromGitter<kayabaNerve> Pointers
02:30:34FromGitter<kayabaNerve> Seriously though, libsecp256k1, a C library, uses pointers over return values (returns a status code).
02:30:41FromGitter<kayabaNerve> I'm using pointers for compatibility with it.
02:30:56FromGitter<kayabaNerve> And I'm not asking if I need to use dealloc. I'm asking if I only have to use it.
02:31:29FromGitter<Varriount> Only if you're using alloc0
02:31:36FromGitter<Varriount> What function are you calling?
02:31:52FromGitter<kayabaNerve> Because the manual says the proc to dealloc memory is dangerous, and not to forget to free the memory, making it seem like I must call free() or something, but that's not a function, and it sounds like forgetting to use dealloc is dangerous...
02:32:10FromGitter<Varriount> If you call alloc/alloc0, you must call dealloc
02:32:26FromGitter<Varriount> What function from that C library are you calling?
02:32:38FromGitter<kayabaNerve> https://github.com/kayabaNerve/Currency/blob/master/src/lib/SECP256K1Wrapper.nim
02:33:36FromGitter<kayabaNerve> That's my wrapper around the Status-im Nim wrapper. ⏎ ⏎ And I know I must call dealloc. I was checking there isn't a third function because the manual's phrasing is trippy. I'm all caught up now.
02:34:03FromGitter<kayabaNerve> secp256k1_ec_pubkey_create ⏎ secp256k1_ecdsa_sign ⏎ secp256k1_ecdsa_verify
02:34:49FromGitter<Varriount> Why not use GC-tracked memory? You can still get pointers from GC-tracked memory, as long as the C code isn't holding onto it after the function call.
02:36:52FromGitter<kayabaNerve> Because I'm comfortable with this? That shouldn't be the case though, and it sounds like a better solution.
02:37:37FromGitter<kayabaNerve> Do you just mean using ref?
02:39:07*gangstacat quit (Read error: Connection reset by peer)
02:42:16FromGitter<Varriount> Well, addr works on any variable, including variables that are tracked by the GC
02:44:11FromGitter<kayabaNerve> I just have no idea what you're talking about. Using ref instead of ptr or some functions or...
02:44:21FromGitter<Varriount> @kayabaNerve If you can wait a couple of hours, I can give an example.
02:44:35FromGitter<kayabaNerve> Or do you mean not using ptr and just using regular vars with addr before them 24/7
02:45:30FromGitter<Varriount> Something like that
02:46:14FromGitter<kayabaNerve> Got it
02:59:36skrylarsomehow manymuffins sounds like a dumb name for a multi-serialization kit
03:33:01*leorize quit (Ping timeout: 260 seconds)
03:33:42*leorize joined #nim
03:36:15FromGitter<Varriount> @kayabaNerve https://gist.github.com/Varriount/026c85b8f6bb99e1c280466b09a22edc
03:37:04FromGitter<Varriount> For C functions that return a pointer to memory they allocate, you can use a ref containing the opaque pointer, and use `new` to attach a finalizer to the pointer.
03:39:03FromGitter<Varriount> You can also do this in a similar way using objects and destructors, however that would give the context and scratch types object-like semantics (namely, they would be destroyed when the objects exit scope, so you would need to override the assignment operator to clone the context/scratch).
03:43:53*endragor joined #nim
03:50:59*smt` quit (Read error: Connection reset by peer)
03:51:05*smt joined #nim
03:55:42*skrylar quit (Remote host closed the connection)
04:07:29*data-man quit (Ping timeout: 248 seconds)
04:11:57*mitai42 quit (Ping timeout: 240 seconds)
04:12:05*cspar__ joined #nim
04:13:53*francisl quit (Ping timeout: 248 seconds)
04:25:01*NamPNQ joined #nim
04:38:30*fjvallarino quit (Remote host closed the connection)
04:38:58*fjvallarino joined #nim
04:43:47*fjvallarino quit (Ping timeout: 256 seconds)
04:57:10*miran joined #nim
04:57:24*cspar_ joined #nim
05:01:02*cspar__ quit (Ping timeout: 276 seconds)
05:03:41*xkapastel quit (Quit: Connection closed for inactivity)
05:11:31*fjvallarino joined #nim
05:12:49*Cthalupa joined #nim
05:16:38*lompik joined #nim
05:24:11*nsf joined #nim
05:48:35*zahary joined #nim
05:56:52*skrylar joined #nim
06:00:29*cspar_ quit (Ping timeout: 260 seconds)
06:03:59*cspar_ joined #nim
06:08:10*zahary quit (Quit: Leaving.)
06:10:08*gangstacat joined #nim
06:18:52*miran quit (Ping timeout: 260 seconds)
06:19:35*zahary joined #nim
06:27:19*skrylar quit (Remote host closed the connection)
06:31:42*leorize quit (Ping timeout: 260 seconds)
06:32:19*leorize joined #nim
06:42:19*smt` joined #nim
06:46:05*smt quit (Ping timeout: 240 seconds)
06:51:38*Cthalupa quit (Read error: Connection reset by peer)
06:51:42*Cthalupa- joined #nim
07:10:57*zahary quit (Quit: Leaving.)
07:13:57*gangstacat quit (Quit: Ĝis!)
07:16:06*cspar_ quit (Ping timeout: 260 seconds)
07:16:46*Vladar joined #nim
07:17:56*Zevv left #nim (#nim)
08:04:24FromGitter<kindlychung> Is there a nimble command for compile-on-change?
08:04:42FromGitter<kindlychung> Something like `sbt ~compile` in the scala world.
08:18:29FromGitter<kindlychung> Is there an `arcsinh` proc in nim's std lib?
08:38:01leorizekindlychung: nimble build?
08:38:47FromGitter<kindlychung> That doesn't watch the project folder for change, though.
08:39:36leorizeyou mean recompile whenever changes occur? shouldn't your editor be in charge of that?
08:40:45FromGitter<kindlychung> ok,that's also fine. how do you do that in vscode?
08:41:47leorizeand `arcsinh` was recently added to git devel, not available on any release yet
08:41:54leorizehttps://github.com/nim-lang/Nim/pull/7893
08:42:19leorizekindlychung: https://github.com/pragmagic/vscode-nim
08:43:51leorizeI don't use vscode myself, but hopefully that does the trick
08:45:40*crem quit (Ping timeout: 245 seconds)
08:46:10FromGitter<kindlychung> @leorize yes, that works.
08:48:01*crem joined #nim
08:51:49FromGitter<kindlychung> Glad to see arcsinh in devel. Hopefully we will also get the likes of log1p, expm1.
08:52:11*Trustable joined #nim
09:01:21*dddddd joined #nim
09:01:24*rauss quit (Read error: Connection reset by peer)
09:01:30*crem quit (Read error: Connection reset by peer)
09:03:24*rauss joined #nim
09:03:41*crem joined #nim
10:09:33FromGitter<gogolxdong> How to make a closure in a template?
10:12:03FromGitter<kindlychung> @gogolxdong What are you trying to achieve?
10:16:56FromGitter<gogolxdong> make closure in template.
10:22:50*krux02 joined #nim
10:36:42cremwow, dicts in python are now ordered.
10:42:55*mal``` quit (Quit: Leaving)
10:43:41leorizegogolxdong: do it the same way as a function would
10:44:37krux02crem, does that mean linear insertion time?
10:47:05cremOf course not, it's O(1) amortized.
10:53:37*nasusiro joined #nim
10:54:03krux02crem: but an orderd set needs linear insertion time
10:55:30*NamPNQ quit (Remote host closed the connection)
10:55:55*mal`` joined #nim
10:56:15*elrood joined #nim
10:56:16cremWhy? Depends on data structure.
10:56:23*gangstacat joined #nim
10:59:31FromGitter<gogolxdong> @leorize couldn't ,I have a macro with bindSym, want to call it in a template, but the value is runtime determinstic.
10:59:59FromGitter<gogolxdong> ``````
11:00:04FromGitter<gogolxdong> ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5b361134d2abe466889469d3]
11:00:49FromGitter<gogolxdong> ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5b361160ad21887018e8b2c7]
11:08:34*noonien joined #nim
11:51:27FromGitter<kaushalmodi> Is it possible to pack all the libraries (system, etc.) in the nim binary itself? That will allow me (and many) to spread the use of Nim "scripts".
11:52:26FromGitter<kaushalmodi> I can place just that single binary in a central project location.
11:52:26*aziz joined #nim
11:52:30YardanicoI don't really think this is possible...
11:52:34Yardanicobut maybe someone knows more
11:53:20FromGitter<kindlychung> How do you get the smallest float64 value?
11:53:21FromGitter<kaushalmodi> Think how easy it would be ti get someone hooked to Nim..
11:53:57FromGitter<kindlychung> Like golang, :-)
11:54:01*aziz quit (Client Quit)
11:54:39FromGitter<kaushalmodi> "how do I run this Nim code?" "Just run this binary"
11:54:58FromGitter<kindlychung> I am looking for something like this: https://en.cppreference.com/w/cpp/types/numeric_limits/min
11:55:12Yardanicothere are some tools (at least for windows) which will allow you to pack a C compiler and all nim files into one binary
11:55:14Yardanicoidk about linux
11:55:27FromGitter<ephja> folders are so ubiquitous though. it's already very convenient if there's no need to manually install third party libraries. I'm sure it could be made to work, but then what if you need to read files and/or add new ones that will be used by the application?
11:55:43FromGitter<kaushalmodi> Yeah.. I'm on Linux
11:55:58FromGitter<kaushalmodi> It doesn't have to ve distributed officially..
11:56:31FromGitter<kaushalmodi> If someone can provide a recipe, i can at least start doing that at my work.
11:56:34Yardanicobut this would be very hacky
11:56:43Yardanicowhy would you ever need one binary? this is not unix-way :DD
11:56:48FromGitter<ephja> I suppose you could first check some imaginary filesystem in the executable before checking the real filesystem when reading/writing :p
11:57:22Yardanico@kaushalmodi you can probably try to search for a tool which allows to pack directories/binaries into one binary
11:58:11Yardanico!eval low(float64)
11:58:11NimBotCompile failed: <no output>
11:58:17Yardanico!eval echo low(float64)
11:58:19NimBot-inf
11:58:21Yardanico@kindlychung ^
11:58:23Yardanico:D
11:58:29FromGitter<kaushalmodi> Yardanico: I use Emacs. Function > Unix philosophy ;)
11:58:42Yardanico@kaushalmodi but I don't really think this would be useful, why?
11:59:11Yardanicowhat's the difference with having a directory or having one binary (of the same size)?
11:59:25Yardanicoif it's a directory you can easily modify files in it
11:59:35FromGitter<ephja> do these mechanism increase the chances of triggering false positives in antiviruses?
11:59:49FromGitter<ephja> *mechanisms
11:59:59Yardanicosometimes they do, not always. and you can always report a false-positive to AV vendor
12:00:37FromGitter<ephja> yeah I'm not sure how useful it is, but an interesting approach nevertheless
12:00:58Yardanicothere's enigma virtual box for windows which does exactly this
12:00:59FromGitter<survivorm> !eval echo (low(float64) + 1.0)
12:01:01NimBot-inf
12:01:07FromGitter<kaushalmodi> Yardanico: Committing a single binary file would create a lot less noise in the project
12:01:17Yardanico@kaushalmodi you want to commit a binary?!
12:01:19FromGitter<kindlychung> @Yardanico -inf is not so helpful, thought.
12:01:27Yardanico(and enigma virtual box is freeware)
12:02:23FromGitter<survivorm> @Yardanico !eval echo (low(float64) + 1.0) reminds me of the old joke with the highest number...
12:02:39Yardanico@kindlychung you can use https://nim-lang.org/docs/fenv.html
12:02:52Yardanicoto get some max/min values for floats
12:03:06FromGitter<kaushalmodi> Yeah, I start with that. Once a tool becomes widely adopted, I can request the central CAD team to install something company wide.
12:03:24Yardanico@kaushalmodi why not just compile it?
12:03:26Yardanicoyour tool
12:04:02FromGitter<kaushalmodi> That won't help propagate Nim
12:04:13Yardanicobut your way is hacky
12:04:19FromGitter<kaushalmodi> People using the tool are coders
12:04:49Yardanicoyou can also make a thread on the forum to discuss it :)
12:04:59FromGitter<kaushalmodi> They know bash, pythom, Perl, etc
12:05:06FromGitter<kaushalmodi> Ok
12:05:30Yardanico@kaushalmodi but it's bad to present a compiled language like a scripting one :)
12:05:43Yardanicobecause they're different and people may get confused with compilation/etc
12:05:56Yardanicobut it's just my IMO
12:06:43FromGitter<kindlychung> @Yardanico there is a minimumPositiveValue, but not minimumValue.
12:06:48*gangstacat quit (Ping timeout: 256 seconds)
12:07:21FromGitter<kindlychung> Grabbed some test binary and did this: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5b3620f9a288503b3de9afd7]
12:07:50Yardanicowhat test binary?
12:07:51FromGitter<ephja> one problem with choosing some large value that isn't inf is that if the second operand of an arithmetic operation is close enough to zero then the value might not change at all
12:08:17FromGitter<kindlychung> @Yardanico from one of my toy projects.
12:08:31Yardanico@kindlychung nim loads some libs at runtime
12:09:05FromGitter<kindlychung> And that requires nim being installed on the target machine?
12:09:06FromGitter<ephja> but inf/-inf might still be useful when performing comparisons
12:09:52FromGitter<ephja> Yardanico: again, in-executable file systems, but then you need exotic loading mechanisms :p
12:10:08Yardanico@ephja we only need to find something like "enigma virtual box" for linux :)
12:12:15FromGitter<kindlychung> @Yardanico On linux you don't need such a thing, you have docker, which is probably way more powerful than enigma.
12:12:17Yardanicowell, maybe something like flatpak
12:12:29Yardanico@kindlychung but @kaushalmodi wants to pack it into one binary
12:13:01FromGitter<kindlychung> Yeah, then you have snap, appimage, flatpak, etc.
12:13:08FromGitter<kindlychung> :-)
12:13:21FromGitter<kaushalmodi> Yardanico: Go is a compiled language too. But it's so convenient for anyone to download the binary and get going. I want to start doing that at least at my team/group level.
12:13:33Yardanico@kaushalmodi download what binary?
12:13:44FromGitter<kaushalmodi> Nim binary
12:14:00YardanicoI mean for Go
12:14:52FromGitter<kaushalmodi> Hmm, you're right.. it's a tar.gz
12:15:09FromGitter<kindlychung> @Yardanico golang compiles everything into a statically linked binary, and you can just deploy that one single file.
12:15:17Yardanico@kindlychung we're not talking about deploying :)
12:15:38FromGitter<kaushalmodi> @kindlychung Yes, not talking about deploying
12:16:02FromGitter<kaushalmodi> OK, later today, let me try the tar.gz approach
12:16:32FromGitter<kaushalmodi> Thanks :)
12:19:23FromGitter<kindlychung> Ah, that. I don't feel it's too much trouble to `curl https://nim-lang.org/choosenim/init.sh -sSf | sh`
12:19:51FromGitter<kindlychung> Actually, it looks awesome.
12:20:42FromGitter<kaushalmodi> @kindlychung yeah.. I discussed that few times before, my OS RHEL 6.6 (rather the glibc) is too old for that.
12:22:38FromGitter<kindlychung> i see.
12:23:09FromGitter<ephja> it would be nice to have the ability to pass var literals. I'm not sure you can avoid declaring a local var first with a template. then there's the situation when you might want to provide a default var argument
12:26:25FromGitter<ephja> I dunno, maybe there's a proposed feature that will simplify this pattern
12:35:29FromGitter<ephja> I'm just trying to create the equivalent of seq[T] for manually managed memory. arrays have a length, but the length is specified at compile time. has anyone gone down this road?
12:38:59*data-man joined #nim
13:04:27*cspar_ joined #nim
13:07:53*francisl joined #nim
13:10:00*gangstacat joined #nim
13:11:48nasusirotime to think out loud: so...Nim's let is for instance C++'s const whereas Nim's const is C++'s constexp?
13:14:06Yardanicowell, probably. I also think that Nim's logic for var/let/const is one of the best (not like in JS for instance)
13:14:24Yardanicovar - runtime/mutable, let - runtime/immutable, const - compile-time/immutable
13:14:28nasusiroYardanico: yeah, for sure. this is something I have noticed
13:14:45Yardanico(of course let variables can be actually modified with unsafe features, but that's up to the programmer)
13:14:47nasusirothe use of var is makes perfectly sense; var as of "variable"
13:15:48*gangstacat quit (Ping timeout: 256 seconds)
13:15:55FromGitter<ephja> I guess write tracking covers some of the limitations associated with the immutability model
13:16:02*awal is now known as afk
13:16:10*afk is now known as awal
13:16:10*gangstacat joined #nim
13:17:40nasusiroso far, Nim has impressed me a lot!
13:23:27nasusiroquestion: I'm here https://nim-lang.org/docs/nep1.html and there is no way to go to https://nim-lang.org/documentation.html
13:23:30nasusirois this behavior normal?
13:24:26Yardanicothere's no way to get back to https://nim-lang.org/documentation.html from any doc page
13:24:29Yardanicoafaik
13:24:45*gangstacat quit (Ping timeout: 256 seconds)
13:25:05*gangstacat joined #nim
13:28:22*fjvallarino quit (Remote host closed the connection)
13:28:29*fjvallarino joined #nim
13:32:52*cspar_ quit (Ping timeout: 260 seconds)
13:33:23*endragor quit (Remote host closed the connection)
13:33:52*endragor joined #nim
13:35:44federico3that should be fixed
13:38:28FromGitter<kaushalmodi> I think that the doc home page and TheIndex should be linked from every page.
13:38:40*endragor quit (Ping timeout: 268 seconds)
13:40:30FromGitter<kaushalmodi> On a related note, the JavaScript? based search.. the search box in left doesn't work on locally built web docs (koch web). Is that right?
13:41:27*fvs left #nim ("ERC (IRC client for Emacs 25.3.1)")
13:41:47FromGitter<Vindaar> @kaushalmodi yeah, that search doesn't work for me locally either
13:47:10FromGitter<kaushalmodi> Question/suggestion about nim module documentation.. How do people edit the documentation in the Nim comments?
13:47:18Yardaniconim comments?
13:47:20FromGitter<kaushalmodi> Look at the extensive documentation in https://github.com/kaushalmodi/strfmt/blob/master/strfmt.nim
13:47:31Yardanicowell, you just write it in .nim file
13:47:43FromGitter<kaushalmodi> but I lose all the syntax highlighting for rst
13:47:55FromGitter<Araq> you can also use .. include:: details.rst
13:48:07FromGitter<kaushalmodi> ah, yes.. that's what I was looking for
13:48:09FromGitter<Araq> the pegs module does that, kind of, take a look
13:48:13FromGitter<kaushalmodi> Thanks
13:48:41FromGitter<Araq> but RST was designed to not need syntax highlighting :-)
13:48:44FromGitter<kaushalmodi> While I am brushing up that strfmt module, I am trying to come up with some convenience documentation guidelines
13:48:59FromGitter<kaushalmodi> Well, Emacs shows if I did the markup correctly
13:49:15FromGitter<kaushalmodi> and all the other major mode commands
13:49:37FromGitter<kaushalmodi> I am thinking of having the module documentation source in Org mode
13:49:45FromGitter<Araq> in fact, Nim comments are always in RST, so a better highlighter can just go head and look at the comments
13:49:48FromGitter<kaushalmodi> then have a nimble task to run pandoc to convert that to rst
13:49:54FromGitter<kaushalmodi> and then include that rst in the module header
13:50:38FromGitter<Araq> I don't like "pandoc" or any external tool fwiw, IMO Nim's documentation generator should just be improved to support whatever feature you need
13:51:03FromGitter<kaushalmodi> It's going to be difficult to support Org mode
13:51:24FromGitter<Araq> well or use the json output and proceed from there
13:51:52FromGitter<kaushalmodi> I didn't follow
13:52:10FromGitter<kaushalmodi> I am not talking of parsing the .nim file
13:52:50Yardanico@Araq - @kaushalmodi wants to write documentation in Org mode, which is some special emacs syntax
13:53:12FromGitter<kaushalmodi> Instead have the "main documentation" (not doc strings) for a module live in Org format in a separate file, then "somehow" (pandoc) convert that to rst so that that can be included in the .nim header for `nim doc`.
13:53:50FromGitter<kaushalmodi> Not special Emacs syntax.. but Emacs support Org mode document edit *really* convenient
13:54:24FromGitter<kaushalmodi> The Org docs are plain text.. can be editted in any editor like Markdown or rst
13:54:54Yardanicorst is plain text too :P
13:55:08FromGitter<kaushalmodi> that's what I said
13:56:08*cspar_ joined #nim
13:59:05*nuknown quit (Ping timeout: 240 seconds)
13:59:38FromGitter<kaushalmodi> Just curious.. why do the peg docs in rst format have a .txt extension?
14:00:17FromGitter<kaushalmodi> turns out all docs in doc/ have .txt extension
14:00:20FromGitter<kaushalmodi> ?
14:01:58FromGitter<Araq> because originally the point of RST was to be a spec for how to write .txt files
14:02:18FromGitter<Araq> and then programmers took over and invented .rst, missing the point, as usual.
14:02:34FromGitter<Araq> :P
14:06:23FromGitter<kaushalmodi> That at least fails auto-detection of major mode in Emacs.. not a big deal. I was curious if the .txt extension was special for nim doc
14:13:07FromGitter<kaushalmodi> Is there a nice trick to grab a nimble package's version from its .nimble file when generating docs?
14:13:43FromGitter<kaushalmodi> A the moment, I see that the version has to be manually updated in the .nimble and the rst docs comments
14:14:05FromGitter<krux02> I would like to have an official name to reference symbols in documentation string
14:14:12nasusiro-_- I have been trying for whole 5 minutes to stop my Vim from behaving weirdly...what was the catch? a file named .vim instead of .nim
14:14:16nasusiroargh
14:14:48FromGitter<krux02> I like in in emacs lisp that I can reference functions in the documentation string and they become hyper links in the help text.
14:15:43FromGitter<kaushalmodi> @krux02 Oh yeah.. miss that. I got a bit close to that with devdocs integration
14:16:05FromGitter<krux02> did you do devdocs integration?
14:16:12FromGitter<kaushalmodi> https://scripter.co/accessing-devdocs-from-emacs/
14:16:19FromGitter<krux02> the problem is that function symbols are not unique by name
14:16:33FromGitter<krux02> at least no in nim
14:16:45FromGitter<kaushalmodi> well, devdocs will work only for the stable releases and only for the std libs
14:18:00FromGitter<kaushalmodi> I have a binding "??".. when I do that on code with "strutils", it gives me this
14:18:07FromGitter<kaushalmodi> (https://files.gitter.im/nim-lang/Nim/iNEE/image.png)
14:18:28FromGitter<kaushalmodi> then I can further filter down that list, hit enter, and the docs for that pop up in browser
14:19:32FromGitter<krux02> @kaushalmodi that certainly looks cool
14:19:36FromGitter<krux02> I am interested
14:19:48FromGitter<krux02> I am constantly looking up documentation
14:19:57FromGitter<kaushalmodi> (https://files.gitter.im/nim-lang/Nim/s6UL/image.png)
14:20:34FromGitter<krux02> what is the completion engine?
14:20:50FromGitter<kaushalmodi> ivy/counsel
14:21:08FromGitter<krux02> I use help
14:21:09FromGitter<krux02> helm
14:21:15FromGitter<kaushalmodi> that should work too
14:21:29FromGitter<krux02> ok
14:21:31FromGitter<kaushalmodi> I remembered that I have a GIF of this in action
14:21:36FromGitter<ephja> how do I get a backtrace following a segfault in a callback executed in a foreign thread?
14:21:42FromGitter<kaushalmodi> scroll to the bottom of that blogpost I linked above
14:23:51FromGitter<ephja> I'm trying to catch Exception in various places
14:31:54FromGitter<krux02> @ephja have you tried using a debugger?
14:35:55*miran joined #nim
14:37:53FromGitter<kaushalmodi> I see `` `foo` `` being used everywhere in doc strings to produce italics, but the rst spec doesn't use that markup.. it uses `*foo*` instead, like markdown.
14:38:02FromGitter<kaushalmodi> http://docutils.sourceforge.net/docs/user/rst/quickstart.html
14:38:39FromGitter<kaushalmodi> .. so pandoc fails at italicizing the `` `foo` ``.. where is this docstring markup spec?
14:38:46FromGitter<krux02> well I use `sym` always to reference symbols
14:39:06FromGitter<kaushalmodi> can you provide a quick link
14:39:08FromGitter<krux02> `` `sym` ``
14:39:22FromGitter<krux02> well, I have to search for it
14:39:25FromGitter<kaushalmodi> yeah.. they actually get italicized by `nim doc`
14:39:38FromGitter<kaushalmodi> for syms, it is actually ``` ``sym`` ```
14:39:52FromGitter<kaushalmodi> See this: https://lyro.bitbucket.io/strfmt/
14:40:16FromGitter<kaushalmodi> See how the *format* gets italicized.. ``1. the `format` functions to render a single value as a string,``
14:40:20FromGitter<krux02> https://github.com/nim-lang/Nim/blob/master/lib/pure/algorithm.nim#L460
14:40:39FromGitter<krux02> you are right it is ``sym``
14:40:43FromGitter<kaushalmodi> hehe
14:40:43FromGitter<krux02> gitter
14:40:56FromGitter<kaushalmodi> you need to do ```` ``` ``sym`` ``` ````
14:41:03FromGitter<kaushalmodi> it's plain markdown
14:41:10FromGitter<krux02> ``` ``sym`` ```
14:41:13FromGitter<krux02> yay
14:41:16FromGitter<kaushalmodi> if you want to print `` ` ``, wrap it with n+1 quotes
14:41:31FromGitter<krux02> ```````` ```````sym``````` ````````
14:41:40FromGitter<krux02> hmm, yea
14:41:53FromGitter<kaushalmodi> need to separate the beginning/ending backticks with space
14:42:18FromGitter<krux02> I know I used 8 backticks for that one
14:42:24FromGitter<kaushalmodi> So to print https://gitter.im/nim-lang/Nim?at=5b3644f86ceffe4eba3e022b, I did ````` ```` ``` ``sym`` ``` ```` ````` :P
14:42:43FromGitter<kaushalmodi> guess what I did to print above ^ :P
14:43:05*cryptocat1094 joined #nim
14:43:06FromGitter<ephja> @krux02 I have. I call system.alloc (manual memory allocation), and then it ends up in gc.nim followed by alloc.nim and then it crashes here "removeChunkFromMatrix2_NyesLqu7hqkgfLqcLrQpjw (a=0x7fffee6c4350, b=0x7ffff7e5b000, fl=12, sl=13) at /home/e/abs/nim-git/src/Nim/lib/system/alloc.nim:209". I have no idea why it takes this path
14:43:17FromGitter<krux02> `````` ````` ```` ``` ``sym`` ``` ```` ````` ``````
14:47:49FromGitter<krux02> @ephja what line does it crash there and what are the values of the local variables
14:47:53FromGitter<Araq> @ephja well allocation removes a chunk and would return it to you
14:48:00FromGitter<Araq> and fails.
14:51:05FromGitter<krux02> sorry you did provide the local variables
14:51:37*natrys joined #nim
14:52:15*mitai42 joined #nim
14:57:14FromGitter<ephja> https://gist.github.com/ephja/07e7255941a15b971194818ec2471680 the requested size seems about right and it's not large
14:57:41FromGitter<ephja> all that's missing is the relevant code
15:01:38FromGitter<Araq> you are calling alloc from the wrong thread
15:01:44FromGitter<Araq> a thread not under Nim's control.
15:01:45*endragor joined #nim
15:01:52FromGitter<Araq> try allocShared() etc
15:02:10FromGitter<Araq> alloc() is as thread-local as new() is.
15:03:55*zama quit (Ping timeout: 256 seconds)
15:04:53*zama joined #nim
15:05:18FromGitter<enormandeau> Hi. New to Nim. I'm trying to solve TSP. I expect many "learning opportunities" since I haven't done anything but very basic stuff in Nim following 2-3 tutorials.
15:05:42FromGitter<enormandeau> I'd like to allocate a sequence of size two arrays. Here is what I do :
15:05:51FromGitter<enormandeau> ```var random_points: seq[array[float, float]] = @[]```
15:06:13FromGitter<enormandeau> I get a `Error: ordinal type expected` and I don't know what to change
15:07:55FromGitter<Araq> array[2, float]
15:07:57FromGitter<enormandeau> BTW, is it better to ask here or on the forum? I saw that there were more messages here...
15:08:14FromGitter<Araq> offtopic, but interesting for everybody: https://techxplore.com/news/2018-06-breakthrough-algorithm-exponentially-faster-previous.html
15:08:39FromGitter<ephja> I changed it and now I see alloc.allocShared in the stacktrace but it still crashes in the same location
15:09:52FromGitter<Araq> @enormandeau it's fine either way. you'll get feedback much faster here.
15:11:56FromGitter<ephja> #0 removeChunkFromMatrix2_NyesLqu7hqkgfLqcLrQpjw (a=0x555555788420 <sharedHeap_R3bhvQCN0d6AYpkvxfT9aGw>, b=0x7ffff7ec8000, fl=12, sl=22) at /home/e/abs/nim-git/src/Nim/lib/system/alloc.nim:209 🤔
15:12:36FromGitter<enormandeau> thanks @Araq
15:17:46FromGitter<ephja> I'll step through everything later
15:18:16FromGitter<Araq> fl=12, sl=22 looks like a pretty big block
15:18:50FromGitter<enormandeau> I'd like to update two sequences, one empty and one with elements, such as the first 3 elements go from the non-empty one to the empty one. The non-empty one then has 3 less elements. I was thinking about something similar as `lst.pop()` in Python. Is there something similar or do I have to do 2 operations (copy then remove)?
15:19:40FromGitter<ephja> oh ok. I just looked at the obvious length parameters
15:20:53FromGitter<enormandeau> Right now, I'm doing : ⏎ ⏎ `````` [https://gitter.im/nim-lang/Nim?at=5b364e55be98b1422413fa65]
15:20:59FromGitter<enormandeau> ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5b364e5bad21887018e96895]
15:21:22FromGitter<narimiran> @enormandeau well, there is https://nim-lang.org/docs/system.html#pop,seq[T] for popping the last element
15:22:30FromGitter<enormandeau> I would like : ⏎ ⏎ ```var solution: seq[array[2 float]] = random_points.pop(0..2)``` [https://gitter.im/nim-lang/Nim?at=5b364eb672b31d3691fe8ae5]
15:23:23FromGitter<narimiran> can you change the order of `random_points` so the wanted elements are the last three?
15:23:48FromGitter<enormandeau> In this case, yes, I could easily
15:23:56FromGitter<ephja> "castptr UncheckedArray[T (allocShared(T.sizeof * len))" -> "allocShared_sVm4rDImKK2ZDdylByayiA_4 (size=171188)"
15:24:04FromGitter<enormandeau> Since these are random, the order doesn't matter.
15:24:31FromGitter<narimiran> @enormandeau then you can loop `pop`three times and that's it, no?
15:24:33FromGitter<ephja> not that I have much of a need for UncheckedArray. the buffer is encapsulated in a type
15:25:05FromGitter<enormandeau> @narimiran Yes, but I don't feel like that solves the problem neatly. For the rest of the algo, I will use this though.
15:27:43*endragor quit (Remote host closed the connection)
15:27:50FromGitter<enormandeau> Is there something more idiomatic then : ⏎ ⏎ ```while some_sequence.len > 0: ⏎ value = some_sequence.pop() ⏎ # do something``` [https://gitter.im/nim-lang/Nim?at=5b364ff66ceffe4eba3e21c9]
15:29:33FromGitter<narimiran> if i understood you intentions correctly, my first thought was this: http://ix.io/1foB
15:30:59FromGitter<Quelklef> Just write your own `proc popT (s: seq[T], r: range[int]): void` proc
15:32:43*floppydh quit (Remote host closed the connection)
15:32:59FromGitter<Quelklef> ```code paste, see link``` ⏎ ⏎ should work, I think [https://gitter.im/nim-lang/Nim?at=5b36512baeb8fa0c074d5f7d]
15:33:37*floppydh joined #nim
15:34:26FromGitter<Quelklef> by the way, anyone, any chance that a `times` template will make it into the stdlib? For e.g. `10.times: echo("!")`
15:34:48FromGitter<Quelklef> It's trivial to write myself, but feels like it should be default
15:35:30FromGitter<ephja> no I think I do want UncheckedArray. I think it should be used in bindings when the pointee is a buffer rather than a single value. "ptr array[size, T]" is sometimes applicable, but if "size" is big enough then it won't be accepted by GCC
15:36:51FromGitter<enormandeau> @Quelklef How do you pass a `range`? I tried to call with `pop(my_seq, 0..2)` and got `Error: range expected`
15:37:59FromGitter<ephja> I dunno if the backend can generate large enough C array types even if they are not allocated on the stack
15:38:10FromGitter<enormandeau> Actualy, it is the proc declaration that trips the compiler
15:40:42FromGitter<Quelklef> @enormandeau Ah, `..` is an iterator, not a proc, so it doesn't make a range.
15:40:45FromGitter<Araq> r: Slice[int] # confusing, I know
15:41:01FromGitter<Quelklef> ah, shook. Thanks Araq
15:47:30*francisl quit (Quit: francisl)
16:00:31*dada78641 quit (Ping timeout: 255 seconds)
16:01:45*Entropic quit (Ping timeout: 260 seconds)
16:02:32*floppydh quit (Ping timeout: 256 seconds)
16:05:32*Entropic joined #nim
16:07:20*dada78641 joined #nim
16:09:45*Calinou quit (*.net *.split)
16:09:54*xomachine[m] quit (*.net *.split)
16:09:54*gh0st[m] quit (*.net *.split)
16:09:54*yglukhov quit (*.net *.split)
16:09:54*federico3[m] quit (*.net *.split)
16:12:42*floppydh joined #nim
16:12:57*nif quit (Ping timeout: 240 seconds)
16:14:08*Calinou joined #nim
16:14:08*xomachine[m] joined #nim
16:14:08*yglukhov joined #nim
16:14:08*gh0st[m] joined #nim
16:14:08*federico3[m] joined #nim
16:14:58*nif joined #nim
16:17:44*nkaramolegos[m] quit (Ping timeout: 245 seconds)
16:17:44*hitchhooker[m] quit (Ping timeout: 245 seconds)
16:17:44*pqflx3[m] quit (Ping timeout: 245 seconds)
16:17:45*Jipok[m] quit (Ping timeout: 245 seconds)
16:17:45*zielmicha[m] quit (Ping timeout: 245 seconds)
16:17:45*solitudesf quit (Ping timeout: 245 seconds)
16:17:47*tyrion[m] quit (Ping timeout: 245 seconds)
16:17:47*notdekka[m] quit (Ping timeout: 245 seconds)
16:17:47*libman[m] quit (Ping timeout: 245 seconds)
16:17:49*planetis[m] quit (Ping timeout: 240 seconds)
16:17:49*endes[m] quit (Ping timeout: 240 seconds)
16:17:51*hohlerde quit (Ping timeout: 240 seconds)
16:17:51*macsek1911[m] quit (Ping timeout: 240 seconds)
16:17:53*dyce[m] quit (Ping timeout: 240 seconds)
16:17:53*xomachine[m] quit (Ping timeout: 240 seconds)
16:17:53*gh0st[m] quit (Ping timeout: 240 seconds)
16:17:53*yglukhov quit (Ping timeout: 240 seconds)
16:17:53*federico3[m] quit (Ping timeout: 240 seconds)
16:17:57*byteflame quit (Ping timeout: 260 seconds)
16:18:00*sendell[m] quit (Ping timeout: 255 seconds)
16:18:01*Demos[m] quit (Ping timeout: 255 seconds)
16:18:01*Abnegation quit (Ping timeout: 255 seconds)
16:18:09*narimiran[m] quit (Ping timeout: 247 seconds)
16:18:09*marszym[m] quit (Ping timeout: 247 seconds)
16:18:09*Miguelngel[m] quit (Ping timeout: 247 seconds)
16:18:10*unclechu quit (Ping timeout: 281 seconds)
16:18:10*petersjt014[m] quit (Ping timeout: 256 seconds)
16:18:10*TheManiac quit (Ping timeout: 256 seconds)
16:18:10*carterza[m] quit (Ping timeout: 256 seconds)
16:18:10*sg-james[m] quit (Ping timeout: 256 seconds)
16:18:50*sroecker[m] quit (Ping timeout: 256 seconds)
16:20:25*pigmej quit (Ping timeout: 260 seconds)
16:22:25*pigmej joined #nim
16:27:25Yardanicomatrix bridge down YET again, yay!
16:30:23*ashleyk quit (Ping timeout: 250 seconds)
16:40:07*ashleyk joined #nim
16:43:09*NimBot joined #nim
16:51:48*floppydh quit (Quit: WeeChat 2.1)
16:54:54*brainproxy joined #nim
17:01:37*pqflx3[m] joined #nim
17:17:01*hitchhooker[m] joined #nim
17:17:01*federico3[m] joined #nim
17:17:02*Miguelngel[m] joined #nim
17:17:02*nkaramolegos[m] joined #nim
17:17:03*dyce[m] joined #nim
17:17:03*Abnegation joined #nim
17:17:03*yglukhov joined #nim
17:17:03*unclechu joined #nim
17:17:03*Demos[m] joined #nim
17:17:04*solitudesf joined #nim
17:17:05*gh0st[m] joined #nim
17:17:08*carterza[m] joined #nim
17:17:08*narimiran[m] joined #nim
17:17:08*sg-james[m] joined #nim
17:17:08*marszym[m] joined #nim
17:17:09*Jipok[m] joined #nim
17:17:09*TheManiac joined #nim
17:17:09*sendell[m] joined #nim
17:17:09*planetis[m] joined #nim
17:17:09*byteflame joined #nim
17:17:09*libman[m] joined #nim
17:17:09*petersjt014[m] joined #nim
17:17:10*macsek1911[m] joined #nim
17:17:10*zielmicha[m] joined #nim
17:17:10*notdekka[m] joined #nim
17:17:10*endes[m] joined #nim
17:17:10*xomachine[m] joined #nim
17:17:10*hohlerde joined #nim
17:17:11*sroecker[m] joined #nim
17:17:11*tyrion[m] joined #nim
17:19:27FromGitter<ephja> share allocations sure involves a lot of operations
17:19:36*krux02 quit (Quit: Leaving)
17:34:17FromGitter<kaushalmodi> Araq: Can you please add gird-style RST table parsing in nim doc? The only thing I think that's blocking the Org -> RST -> HTML flow :)
17:36:07FromGitter<kaushalmodi> Here's (https://gist.githubusercontent.com/kaushalmodi/a1914f97833c9c6e2a45910a94ec8968/raw/22ae16e19d67ed9d37c2d70a521968e0678845cd/strfmt.rst) the auto-generated RST doc from this Org file (https://raw.githubusercontent.com/kaushalmodi/strfmt/master/docs/strfmt.org).
17:41:48shodan45dom96: iirc you're on lobste.rs, right?
17:41:57shodan45dom96: because https://lobste.rs/s/smuu8y/tag_suggestion_nim
17:42:35shodan45I don't have an account, otherwise I'd upvote/post
17:47:26shashlickinteresting site
18:08:35mirandom96: quoting doesn't work on forum?
18:10:05bozaloshtshbest way to convert an array of ordinals to set?
18:10:31FromGitter<Quelklef> `toSet`
18:10:32FromGitter<Quelklef> ?
18:10:36FromGitter<Quelklef> https://nim-lang.org/docs/sets.html#toSet,openArray%5BA%5D
18:10:38miranbozaloshtsh: https://nim-lang.org/docs/sets.html#toSet,openArray[A]
18:11:03bozaloshtshmiran, Quelklef: ahh, tried toSet but didn't realize I had to import sets
18:11:05miran@Quelklef was faster.... :)
18:11:05bozaloshtshthanks
18:11:59bozaloshtshhrm, that converts to HashSet; I want a simple set
18:13:22miranthen a simple loop maybe?
18:13:34bozaloshtshmiran: yeah seems like that's the way to go
18:13:53miranbtw, "simple sets" are quite limited/picky about what they can contain
18:14:08bozaloshtshI know, but I only have (and will only ever have) ordinals
18:14:23bozaloshtshthere's no need for hashing when everything I want to put in the set is <32 bits
18:16:06mirandom96: also, here is some hidden comment: https://forum.nim-lang.org/t/3994
18:37:03*noonien quit (Quit: Connection closed for inactivity)
18:41:45*lompik quit (Ping timeout: 264 seconds)
18:49:41*Vladar quit (Quit: Leaving)
18:50:58nasusiroquestion: when Nim 1.0 will get released, will we get "The Nim Programming Language", much like "Nim in Action"?
18:56:03*dvn joined #nim
19:01:39FromGitter<mvlootman> hello, how can I may a negative assert? e.g. ⏎ var numbers = toSet([1, 2, 3, 4, 5]) ⏎ assert not numbers.contains(2)
19:01:54FromGitter<mvlootman> where 2 should be a number not in the set ofcourse...
19:06:07FromGitter<kaushalmodi> I finally have a nice "nimble docs" flow to generate Nimble module docs from Org mode source.
19:06:48FromGitter<kaushalmodi> The only problem is that tables still need to be written in RST in Org mode (yes, that's possible) as Pandoc generated RST tables are not supported by `nim doc`.
19:07:27Yardanico@mvlootman can you try assert(not numbers.contains(2))
19:07:30FromGitter<kaushalmodi> If someone is interested, have a look at https://github.com/kaushalmodi/strfmt/blob/master/strfmt.nimble
19:07:54Yardanico!eval var numbers = toSet([1, 3, 4, 5]); assert(not numbers.contains(2))
19:07:55NimBotCompile failed: in.nim(1, 15) Error: undeclared identifier: 'toSet'
19:08:01Yardanico!eval import sets; var numbers = toSet([1, 3, 4, 5]); assert(not numbers.contains(2))
19:08:04NimBot<no output>
19:08:47FromGitter<ephja> you need the parentheses in order to change the precedence. also, see https://nim-lang.org/docs/system.html#in.t,untyped,untyped and `notin` defined below
19:08:50FromGitter<mvlootman> @Yardanico yes that works! I tried without the enclosing parentheses which made it fail
19:09:45FromGitter<mvlootman> i see, thanks!
19:18:46shashlickso streams cannot be used in the VM? cannot use parsecfg 😞
19:28:40*Organism joined #nim
19:35:57*arecaceae quit (Remote host closed the connection)
19:36:22*arecaceae joined #nim
20:00:44*cryptocat1094 quit (Quit: WeeChat 1.6)
20:01:52FromGitter<ephja> can you even use alloc/allocShared in foreign threads?
20:04:42*miran quit (Ping timeout: 260 seconds)
20:04:46*miran_ joined #nim
20:05:57*mitai42 quit (Ping timeout: 240 seconds)
20:17:23FromGitter<quinzor_gitlab> Hi, im new to nim and want to translate this js func to nim with performance in mind. I want a better understanding how to write real nimcode. ⏎ Anyone so kind and could help? My attempt looks so wrong with all these ints and floats and indeed does not work. This can't be right :D ⏎ `````` [https://gitter.im/nim-lang/Nim?at=5b3693d3be98b1422414ad7b]
20:17:49FromGitter<dom96> nasusiro: plan is to keep Nim 1.0 compatible with Nim in action.
20:18:09nasusirodom96: that would be great.
20:19:14nasusiroI did a silly mistake before and now I'm pulling my hairs off lol. I opened a website or forum in incognito mode in Chromium and now that I need it to ask a question here I cannot find it O.o
20:20:02nasusirothe example code was something like proc validation(x: int, valid: (x: int) -> bool) =
20:20:23nasusiromy question is: how do I run this validation procedure, that is how do I execute it?
20:20:36nasusirovalidation(10, ???)
20:21:03Yardanicovalid is a proc which accepts int and returns a bool
20:21:16nasusiroyes, I presume is a lambda function
20:21:23nasusiroerr...anonymous procedure?
20:21:28Yardaniconasusiro, not really
20:21:31nasusirois this how it's called in Nim?
20:21:39Yardaniconasusiro, well, there are anonymous procs in nim, yes
20:21:58nasusirobad habits die hard Yardanico
20:23:43*krux02 joined #nim
20:24:30Yardaniconasusiro, .
20:24:31nasusiroso Yardanico, can you provide an actual example of how to execute this piece of code?
20:24:36Yardaniconasusiro, https://gist.github.com/Yardanico/13d3f3939a951737513563b65abc9398
20:24:48Yardanicobut I changed "validation" proc a bit - it returns a bool too
20:25:23nasusirolol, that's what I was wondering, whether should I pass an existing proc in it or not
20:25:31Yardaniconasusiro, well, you can also do it like this:
20:25:32nasusiroman...I burnt my braincells so bad today
20:25:35Yardanicoreplace line 12 with "echo validate(5, (x) => x in 1..10)"
20:25:55Yardanicoit will work the same :)
20:25:59nasusironice, like a Python's list comprehension
20:30:02FromGitter<kaushalmodi> How do I do something like this in .nimble?: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5b3696caad21887018ea3506]
20:31:11FromGitter<kaushalmodi> This is an arbitrary example.. I also want to mv, cp, etc. in the nimble tasks, but I believe that if import os is possible, those operations can work in any OS.
20:31:57FromGitter<Yardanico> @kaushalmodi there's some procs you can use - https://nim-lang.org/docs/nimscript.html
20:32:22FromGitter<Yardanico> it's implicitly imported
20:32:39FromGitter<kaushalmodi> thanks.. so `rmDir` it is
20:33:16FromGitter<kaushalmodi> @Yardanico Thanks! That worked.
20:35:36nasusiroYardanico: the example you kindly shared (thank you very much for your assistance, I appreciate it!) is using a range of 1 to 10. I was wondering: does Nim has something like isnum() we have in C?
20:35:46Yardanicowhat is isnum() ?
20:36:16nasusiroit validates a value as of numeric type
20:36:57nasusiroapologies, I meant isdigit()
20:37:09nasusiroI confused it with isalnum
20:37:46Yardanicowell, there's isDigit but it's only for numbers (chars from 0 to 9)
20:38:27Yardanicomaybe you want to use parseFloat from parseutils
20:39:50nasusirocool, I will try that. Many thanks Yardanico :)
20:40:48Yardaniconasusiro, hmm, but it won't work for strings like "135sometext"
20:40:57Yardanico(because parseFloat will just parse 135)
20:41:15nasusiroisDigit() is just fine
20:41:21nasusiroit can accept string as well
20:41:36Yardaniconasusiro, ah, if you only need to check for numbers, isDigit() is fine
20:41:41nasusiroso, I can validate large numbers such as 1234
20:41:56Yardanico!eval import strutils; echo isDigit("1233123123124891249812748892149889124924818912489")
20:41:59NimBottrue
20:42:11krux02nasusiro, worst case you can always fall back to the C standard library from Nim
20:42:42nasusirokrux02: indeed, if I need to reach that "low level", I might go for it.
20:42:46krux02just declare the function with some importc declaration and header and use it.
20:42:58nasusirocool
20:43:39Yardanicook guys, good night, bye (i'm always online in the IRC because I use a bnc/znc service) :)
20:43:47krux02there are many importc declarations in the compiler so you can look there on how to use it
20:47:16*fjvallarino quit (Remote host closed the connection)
20:47:43*fjvallarino joined #nim
20:52:48*fjvallarino quit (Ping timeout: 268 seconds)
20:58:52FromGitter<kaushalmodi> In Nimscript, how would you use an OS-agnostic path.. like `mvFile("./path/file1", "./path2/file2")`?
20:59:13FromGitter<kaushalmodi> In `os` module, you have the `/` operator.. but I cannot import os in .nimble
20:59:37krux02slashes also work on windos
20:59:55FromGitter<kaushalmodi> I thought windows need `\`.
21:00:02krux02the problem is more the 'c:' on windows where on linux ':' is a path separater
21:00:09krux02nope it doesn't need it
21:00:27*cspar_ quit (Ping timeout: 240 seconds)
21:00:29FromGitter<kaushalmodi> OK cool! then I need not worry about `./docs/index.html` and such
21:00:37krux02the slash operator just helps you not not repeat the '/' in the final path string
21:00:53FromGitter<kaushalmodi> hmm, got it
21:00:57krux02but even that is even handled by the os, at least on linux
21:01:05dom96You can import ospaths in .nimble AFAIK
21:01:26FromGitter<kaushalmodi> dom96: Where would you put that?
21:01:34krux02yea and I think the / operator should also work on nimscript
21:01:39dom96put what?
21:01:43FromGitter<kaushalmodi> the import
21:01:46FromGitter<kayabaNerve> ```code paste, see link``` ⏎ ⏎ I have that Nim code to iterate through an array and get the Hex representation. Everytime my program, which generates 100 in a for loop, runs, the 5th time I use it, when i is 11, I get a segfault. The traceback is: ⏎ ⏎ ` ... [https://gitter.im/nim-lang/Nim?at=5b369e3a81816669a4236dfd]
21:02:22FromGitter<kayabaNerve> Sorry if that's spammy. I can always just put this on a paste service.
21:02:49FromGitter<kaushalmodi> dom96: If I put `import` inside `task`, I get: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5b369e7970efc60660a05837]
21:03:11FromGitter<kayabaNerve> @Varriount We were talking about this yesterday but I don't think this is necessarily because of my manual mem management, to be honest.
21:03:23dom96put it at the top level then
21:03:52FromGitter<kaushalmodi> dom96: Hmm.. I cannot `import os`.. but I can `import ospaths`
21:03:53FromGitter<kaushalmodi> thanks
21:04:28FromGitter<kaushalmodi> `import os` in nimble gives this error: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5b369edc3c5abf52b62f59a1]
21:13:03FromGitter<skilchen> @Quin you are very close... Try this one:
21:13:36FromGitter<skilchen> ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5b36a100bd92d8078286ba3a]
21:15:40*Trustable quit (Remote host closed the connection)
21:21:06*fjvallarino joined #nim
21:29:24FromGitter<kaushalmodi> krux02: I forgot to reply. Yes, the `/` operator does work in . nimble too, after importing `ospaths`. Thanks.
21:29:49krux02no problem
21:30:23*mitai42 joined #nim
21:32:09FromGitter<kaushalmodi> krux02: Do you use Org mode? I'm pretty thrilled to get the Nim module docs generation working with doc source in Org :D
21:33:37krux02I actually use org mode.
21:33:42krux02not too much though.
21:33:48krux02I am not too excited about it.
21:34:11krux02It has weird syntax here and there and does thing too automatic for my personal taste
21:34:44krux02I like the idea that I can use it for source/text hybrid documents and I have syntax highlighting and everything for the source snippents
21:36:14krux02but I am a bit confused on the strict distinction between source that I just want to use to generate some graphs in the output. source that I want to visualize in the output document. And sourcecode that I need to emit in form of glue so that latex/html is going to work.
21:36:43krux02or better said the lack of the clear distinction. it als all <s magic
21:36:53krux02And I never really know what happens
21:39:27*miran_ quit (Ping timeout: 256 seconds)
21:40:11FromGitter<ephja> @kayabaNerve you should get an exception if the allocation fails
21:43:55FromGitter<kayabaNerve> But it didn't
21:43:58FromGitter<kayabaNerve> Just when I used it
21:44:03FromGitter<kayabaNerve> Even though the pointer wasn't null
21:44:22FromGitter<kayabaNerve> And it's always on the 5th item with the 11th array index
21:45:51FromGitter<kayabaNerve> And the array in the item I have a pointer to is declared as an array, not as a pointer
21:45:56FromGitter<kayabaNerve> And I do allocate enough memory.
21:53:12FromGitter<kayabaNerve> OK. So I made it a const, instead of always calling sizeof(). Now it works 8 times and still fails on 11
21:53:20*fjvallarino quit (Remote host closed the connection)
21:53:27*fjvallarino joined #nim
21:53:46FromGitter<kayabaNerve> And the addresses do change on each run. It's not an RNG issue.
21:56:41FromGitter<kayabaNerve> echo $i & " " & $key.data[i] <- works ⏎ result = result & key.data[i].toHex() <- doesn't work
21:56:54FromGitter<kayabaNerve> So it's either strutils or result & "ff"
21:57:52FromGitter<kayabaNerve> proc `$`*(key: PublicKey): string = ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ It's the last line. [https://gitter.im/nim-lang/Nim?at=5b36ab5f216ee2623e8f80dc]
21:58:11FromGitter<kayabaNerve> Why the hell would result & string cause this?
22:00:57FromGitter<kayabaNerve> https://pastebin.com/0iNuEgQQ
22:01:48FromGitter<kayabaNerve> TL;DR If I print the string before result & str, it works. If I don't echo it, it doesn't. It occurs on the 8th loop with the 11th str.
22:04:31FromGitter<kayabaNerve> Oh. The discard in there is also needed.
22:15:58FromGitter<kaushalmodi> > And I never really know what happens
22:16:46FromGitter<kaushalmodi> @krux02 Feel free to ping me offline this thread if that's too offtopic. I'd like to help you out with the Org magic if you want.
22:17:32krux02yea I would be interested, but not today.
22:18:14FromGitter<kaushalmodi> Sure, any time.
22:21:05krux02kaushalmodi: just a question how do you debug a Nim program if you encounter a bug
22:22:28FromGitter<kaushalmodi> krux02: I haven't written too serious nim programs.. for debug, the backtrace helps, and if the compiler crashes, I file a bug report
22:23:17FromGitter<kaushalmodi> I believe this is the most complex thing (https://github.com/kaushalmodi/noxhugo/blob/master/src/noxhugo.nim) I have written from scratch.
22:24:35FromGitter<kaushalmodi> .. and this (https://github.com/kaushalmodi/nim-emacs-module/blob/master/emacs_module/wrappers.nim).
22:33:02*Lord_Nightmare quit (Quit: ZNC - http://znc.in)
22:33:55nasusiroI feel so sad that I'm complete broke, because if I had a successful job I would have funded this project like crazy. I have been experimenting for how long now and feels like...home!
22:34:01*Lord_Nightmare joined #nim
22:38:29krux02nasusiro, write something in Nim and sell it. Then put some money you make and invest it into Nim.
22:39:03nasusiroI'm not the most confident person that would do such thing. Low self-esteem for the win :/
22:40:01krux02well I have to go for today. See you
22:40:11nasusirocheers
22:41:39*krux02 quit (Quit: Leaving)
22:46:35*nsf quit (Quit: WeeChat 2.1)
22:48:00*natrys quit (Quit: natrys)
22:49:22*fjvallarino quit (Remote host closed the connection)
22:49:49*fjvallarino joined #nim
22:54:45*fjvallarino quit (Ping timeout: 260 seconds)
22:59:00FromGitter<kayabaNerve> nasusiro Join a Nim project and sell it
22:59:25nasusirokayabaNerve: any suggestions?
23:13:55*elrood quit (Quit: Leaving)
23:30:03*nasusiro left #nim ("Leaving the channel.")
23:36:30*data-man quit (Ping timeout: 265 seconds)
23:36:43*fjvallarino joined #nim
23:40:02*fjvallarino quit (Remote host closed the connection)
23:40:10*fjvallarino joined #nim