00:01:33 | FromDiscord | <im__cynical> ight |
00:01:34 | FromDiscord | <im__cynical> ty |
00:11:08 | FromDiscord | <JJ> what is an "out" type? |
00:11:10 | FromDiscord | <Robyn [She/Her]> No worries! |
00:11:23 | FromDiscord | <JJ> the keyword is reserved and it does appear to be, like, a thing but it's not in the manual |
00:11:25 | FromDiscord | <Robyn [She/Her]> In reply to @omentic "what is an "out"": An 'out' type? Never heard that before |
00:11:31 | FromDiscord | <Elegantbeef> It's a thing |
00:11:36 | FromDiscord | <Elegantbeef> Out is definitive assignment `var` |
00:11:44 | FromDiscord | <JJ> definitive assignment? |
00:11:45 | FromDiscord | <Elegantbeef> To be used with `strictdefs` |
00:11:53 | FromDiscord | <Robyn [She/Her]> Still makes no sense to me |
00:11:54 | FromDiscord | <Elegantbeef> Yes you must assign the out parameter |
00:11:57 | FromDiscord | <Elegantbeef> It's C style `out` |
00:12:09 | FromDiscord | <JJ> huh icic |
00:12:11 | FromDiscord | <Elegantbeef> Araq really wants definitive assignment to be the norm |
00:12:18 | FromDiscord | <Robyn [She/Her]> I don't know C either so that's useless to me- |
00:12:34 | FromDiscord | <Elegantbeef> Cool I explained what it was |
00:12:43 | FromDiscord | <Elegantbeef> "you must assign the out parameter" |
00:13:10 | FromDiscord | <JJ> any performance improvements over just returning? |
00:13:24 | FromDiscord | <Elegantbeef> Nope it's just static analysis |
00:13:33 | FromDiscord | <Robyn [She/Her]> sent a code paste, see https://play.nim-lang.org/#pasty=HHTBUpDsbDvI |
00:13:38 | FromDiscord | <Elegantbeef> Yes |
00:13:49 | FromDiscord | <Elegantbeef> I mean it hard codes NVRO so that's a 'plus' |
00:13:57 | FromDiscord | <Robyn [She/Her]> Hm... Why would you ever need that? NVRO? |
00:14:10 | FromDiscord | <Elegantbeef> It's a more descriptive `var` and that's really it |
00:14:26 | FromDiscord | <Robyn [She/Her]> Ah okay that makes some sense to me then |
00:14:27 | FromDiscord | <Elegantbeef> you might have a `proc doStuff(i: out int): T` |
00:14:42 | FromDiscord | <Elegantbeef> Araq does want to use it in nonsensical places so that'll be fun |
00:15:14 | FromDiscord | <Elegantbeef> https://github.com/nim-lang/Nim/pull/23261#discussion_r1469385999 context for that |
00:19:13 | FromDiscord | <Robyn [She/Her]> Ah, oh well |
01:00:02 | * | nazgulsenpai quit (Quit: ZNC 1.8.2 - https://znc.in) |
01:00:26 | FromDiscord | <Robyn [She/Her]> Anyone know the best way to do non-blocking code with std/net (without diving into threads just yet)? |
01:00:45 | FromDiscord | <Elegantbeef> Selectorfs |
01:01:30 | FromDiscord | <Elegantbeef> selectors\ |
01:02:00 | FromDiscord | <Robyn [She/Her]> Thought so, thanks o7 |
01:02:08 | FromDiscord | <Robyn [She/Her]> Trying to help my friend get adjusted to Nim so- |
01:02:18 | FromDiscord | <Robyn [She/Her]> She comes from C- |
01:02:59 | * | nazgulsenpai joined #nim |
01:04:00 | FromDiscord | <odexine> not a lot of people who use c minus |
01:04:03 | FromDiscord | <odexine> :baqua: |
01:04:33 | NimEventer | New thread by ggb-sw1: How does one deal with void pointers between Nim and C?, see https://forum.nim-lang.org/t/11079 |
01:04:46 | arkanoid | so you know how can I sto nim from appending "async traceback" string to all my exception messages? |
01:04:49 | arkanoid | *stop |
01:05:12 | arkanoid | I mean this https://github.com/nim-lang/Nim/blob/37ed8c84801a850b91b86f777ae2a4a2e022cd47/lib/pure/asyncfutures.nim#L348 |
01:05:40 | FromDiscord | <Elegantbeef> define release 😛 |
01:05:53 | FromDiscord | <Robyn [She/Her]> In reply to @odexine "<:baqua:746617285057314928>": :p |
01:07:16 | FromDiscord | <morgan> so i'm using sokol, and trying to figure out why i'm getting errors that come from the c code that's actually doing the heavy lifting. i've tried adding some debugging to the validation code, but no changes seem to be applied, so is nim compiling it once and then caching the result? how can i override that? |
01:08:04 | FromDiscord | <Elegantbeef> `-f` |
01:09:02 | FromDiscord | <morgan> 👍 |
01:09:11 | arkanoid | ElegantBeef, that's sad! |
01:09:26 | arkanoid | I need debug, but also my own exception messages |
01:09:47 | FromDiscord | <Elegantbeef> I mean make a PR for `asyncDebugMessages` or w/e |
01:10:49 | FromDiscord | <morgan> In reply to @Elegantbeef "`-f`": ok yep that worked, and now to figure out why its not getting the size of the data i'm giving it |
01:11:03 | FromDiscord | <Elegantbeef> Likely that you're interop is wrong |
01:11:05 | FromDiscord | <Elegantbeef> your\ |
01:11:34 | FromDiscord | <Elegantbeef> Ensure you're not using the incorrect integer sizes |
01:11:40 | FromDiscord | <Elegantbeef> `int` in Nim != `int` in C |
01:13:49 | FromDiscord | <morgan> well the c code is getting 0 for the size |
01:13:55 | FromDiscord | <morgan> and there's a nim wrapper already |
01:14:03 | FromDiscord | <morgan> which im using |
01:14:27 | FromDiscord | <morgan> its getting passed thru a few functions before there |
01:14:46 | FromDiscord | <morgan> and all the docs are in the code which is.... annoying |
01:21:41 | FromDiscord | <morgan> so in the example i copied from, some functions (from c) modified the buffer after creating it, and i couldn't figure out what it was doing that i wasn't, but after copying code from a different example that creates the buffers in a different way, it works |
01:23:47 | FromDiscord | <morgan> i of course get a new error |
01:23:58 | FromDiscord | <morgan> but the sizes the c code gets are correct, which is nice |
01:59:46 | FromDiscord | <Robyn [She/Her]> When you slice a string in Nim, or you get a character at a certain index, does it copy it? |
02:00:09 | FromDiscord | <Elegantbeef> "get a character" of course that copies a character is a value type |
02:00:14 | FromDiscord | <Elegantbeef> If you do `a[b..c]` yes it copies |
02:00:21 | FromDiscord | <Elegantbeef> but if you do a proper slice and do `a.toOpenArray(b, c)` no |
02:02:23 | FromDiscord | <Robyn [She/Her]> In reply to @Elegantbeef ""get a character" of": Makes sense |
02:10:59 | FromDiscord | <luna4> Is there any is function similar to `strchr` from c in nim? |
02:11:13 | FromDiscord | <Elegantbeef> What it do |
02:13:49 | FromDiscord | <Robyn [She/Her]> `char strchr( char str, int ch );` this is the definition in C++ |
02:13:58 | FromDiscord | <Robyn [She/Her]> > A string in C++ is a type of object that represents a collection (or sequence) of different characters… With the help of the c++ strchr() function, we can check whether a character is present in the string or not. The strchr() function in c++ is present in the <cstring> standard library file. |
02:14:20 | FromDiscord | <Elegantbeef> So just contains 😄 |
02:14:24 | FromDiscord | <Robyn [She/Her]> sent a long message, see https://pasty.ee/VVlQEirggiSg |
02:15:16 | FromDiscord | <Robyn [She/Her]> In reply to @luna4 "Is there any is": Seems like `find` is your direct equivalent |
02:15:35 | FromDiscord | <Robyn [She/Her]> !eval echo("abc".find('c')) |
02:15:41 | NimBot | 2 |
02:16:45 | FromDiscord | <luna4> I see, strchr is very useful because it gives you a pointer to the part of the string it finds the first character |
02:17:04 | FromDiscord | <Robyn [She/Her]> If you don't need the index, as Beef said, `contains` is fine! (Also `'c' in "abc"` is sugar for `"abc".contains('c')`) |
02:17:19 | FromDiscord | <luna4> So you can do a little bit of trickery and \0 it to do a fast substring |
02:17:31 | FromDiscord | <Robyn [She/Her]> Why would you need to add a null byte? |
02:17:42 | FromDiscord | <luna4> To do a substring |
02:18:00 | FromDiscord | <Robyn [She/Her]> In Nim, strings are null terminated when you do `myString.cstring`, but since Nim strings store the length, you don't need a cstring usually :p |
02:18:07 | FromDiscord | <luna4> Oh |
02:18:10 | FromDiscord | <luna4> Nevermind then |
02:18:17 | FromDiscord | <sOkam! 🫐> Was there a way to specify the module a function is coming from when using dot syntax? 🤔↵something like: `thing().module.otherthing()`↵I think I remember seeing it somewhere, but can't recall how |
02:18:21 | FromDiscord | <luna4> I would need the index then yup find is useful |
02:18:22 | FromDiscord | <Robyn [She/Her]> It's pretty neat, right? :) |
02:18:43 | FromDiscord | <Elegantbeef> The module name is always the start of a dotexpr |
02:18:56 | FromDiscord | <luna4> In reply to @chronos.vitaqua "It's pretty neat, right?": It is, it's very similar to std::string and i have broken code because of that |
02:19:04 | FromDiscord | <sOkam! 🫐> In reply to @Elegantbeef "The module name is": so they cannot be nested? |
02:19:09 | FromDiscord | <Elegantbeef> Module names do not work with UFCS |
02:19:16 | FromDiscord | <sOkam! 🫐> kk |
02:19:20 | FromDiscord | <Robyn [She/Her]> In reply to @luna4 "It is, it's very": Fair! |
02:20:35 | FromDiscord | <Elegantbeef> You can always use `cstring` and pretend the year is 1982 if you want |
02:22:56 | FromDiscord | <luna4> I'm very used to c so its always an option |
02:23:44 | FromDiscord | <Elegantbeef> You can always just write Nim instead, wild concept 😄 |
02:24:10 | FromDiscord | <ajusa> In reply to @Elegantbeef "You can always use": Or 1995! |
02:24:22 | FromDiscord | <Robyn [She/Her]> Don't scare away the newcomers, Beef, you always do this :P |
02:24:24 | FromDiscord | <Elegantbeef> Sorry we buffer overflowed we don't know the year anymore |
02:24:59 | FromDiscord | <ajusa> I always forget that cstring isn't "C style string", but instead "compatible string" |
02:25:48 | FromDiscord | <luna4> In reply to @Elegantbeef "You can always just": I kinda need to learn it first |
02:25:57 | FromDiscord | <luna4> I can just go back to c also |
02:26:38 | FromDiscord | <luna4> In reply to @ajusa "I always forget that": In c++ is the same, theres also ctime, that also means compatible time |
02:27:04 | FromDiscord | <Elegantbeef> Well Nim has that pesky JS backend |
02:27:12 | FromDiscord | <Elegantbeef> Which also has sstring |
02:27:15 | FromDiscord | <Elegantbeef> cstring\ |
02:32:56 | FromDiscord | <Elegantbeef> Anyway to be slightly less obnoxious Nim does not deal with pointers as such any api that returns a pointer in C likely is done with an integer or not replicated in Nim without going to "unsafe" APIs |
02:45:39 | * | disso-peach joined #nim |
02:58:28 | arkanoid | is there a reason why xmltree returns nil in case of missing child instead of raising an exception? |
03:01:49 | FromDiscord | <zumi.dxy> In reply to @chronos.vitaqua "In Nim, strings are": some other languages omit the zero terminator and just have a pointer and length right?↵I think either way Nim still has the zero terminator so a string to cstring conversion is just taking the pointer to the data and calling it a day |
03:03:00 | FromDiscord | <Elegantbeef> Other languages that are silly omit it 😄 |
03:03:49 | FromDiscord | <Elegantbeef> If you want C interop you want to have that null terminator there |
03:09:19 | * | disso-peach quit (Quit: Leaving) |
04:16:32 | * | azimut quit (Ping timeout: 255 seconds) |
04:17:19 | FromDiscord | <cineration> Does anybody know how to use the `punchThrough` proc in the `netty` library? I just can't figure out how to actually punch a hole 😂. Once I negotiate the ip/port with the server do I have one of the clients act as a server and do the `punchThrough` from the designated "server" before trying to connect from the designated "client"? |
04:26:17 | FromDiscord | <saint._._.> What is sokol? |
04:27:06 | FromDiscord | <saint._._.> https://github.com/floooh/sokol |
04:27:14 | FromDiscord | <saint._._.> Is it for 3d stuff? |
04:38:24 | FromDiscord | <Elegantbeef> If you set it up |
05:12:41 | FromDiscord | <morgan> In reply to @saint._._. "What is sokol?": it's a medium level abstraction over graphics apis |
05:13:16 | FromDiscord | <morgan> high level being like stuff to draw pixels, draw triangles, draw shapes, draw images, etc, and low level being the graphics apis directly |
05:13:23 | FromDiscord | <morgan> so some abstraction |
05:13:35 | FromDiscord | <morgan> but not focused on the high level stuff |
05:13:42 | FromDiscord | <morgan> so you can do what you want directly |
05:14:51 | FromDiscord | <morgan> like i have textures, mesh data, and shaders, and i switched from opengl (in c++ with juce, im basically completely switching everything) because all the stuff to tell it how to process those things was constantly just rakes laying all over ready for me to step on and smack me in the face |
05:40:05 | FromDiscord | <sOkam! 🫐> `proc thing [T :string]() :T= ...`↵Is there a way to instantiate this type of generic automatically without saying `thing[string]()`? |
05:40:47 | FromDiscord | <sOkam! 🫐> _(I know it only has a single type atm, which makes the generic redundant, but it will have more eventually)_ |
05:41:38 | FromDiscord | <sOkam! 🫐> I think I'm just trying to find a way to make the return type dictate the generic instantiation 🤔 |
05:43:11 | FromDiscord | <Elegantbeef> The return type cannot change the generic parameters |
05:43:39 | FromDiscord | <Elegantbeef> I believe you can do `[T: string = string]` |
05:43:56 | FromDiscord | <sOkam! 🫐> oh to give it a default? that could be handy |
05:44:12 | FromDiscord | <Elegantbeef> It might explode in your face as I don't think it's intended design |
05:44:56 | FromDiscord | <sOkam! 🫐> sadly it doesn't instantiate with that 😦 |
05:45:11 | FromDiscord | <sOkam! 🫐> it works when specifying it, but not when omitted |
05:46:11 | FromDiscord | <Elegantbeef> you can do `proc thing(t: typedesc = string)` |
05:49:26 | FromDiscord | <sOkam! 🫐> `Error: type mismatch: got 'string' for 'string' but expected 'typedesc'` 😔 |
05:49:40 | FromDiscord | <sOkam! 🫐> oh, you mean inside the type |
05:49:49 | FromDiscord | <sOkam! 🫐> (edit) "type" => "args" |
05:51:10 | FromDiscord | <sOkam! 🫐> doesn't solve the return type idea, but I guess it could be a bit cleaner for the default case |
05:51:27 | FromDiscord | <Elegantbeef> "return type idea"? |
05:53:14 | FromDiscord | <sOkam! 🫐> in `echo thing()` the echo call should dictate the type↵because I might be calling for other versions that return a different type |
05:53:30 | FromDiscord | <Elegantbeef> Not in Nim we don't have return type inference |
05:53:47 | FromDiscord | <sOkam! 🫐> yeah i understood, that's why i said "the return type idea is not solved" but its a bit cleaner |
06:05:50 | * | rockcavera quit (Remote host closed the connection) |
06:05:50 | FromDiscord | <saint._._.> In reply to @morganalyssa "like i have textures,": Oh cool, are you writing some vst stuff with nim? I’m super interested in that |
06:07:54 | FromDiscord | <morgan> In reply to @saint._._. "Oh cool, are you": yea i'm working on a plugin, i've wanted to use nim for that for ages and someone recently released a c library for that that im gonna wrap at some point, and opengl giving me tons of trouble was a good kick in the butt to try (worked but i was sending textures every update, and i couldn't get it to work with any of the changes i needed to make to change that) |
06:08:41 | FromDiscord | <saint._._.> Are you using juce? Or iplug2 ? |
06:08:53 | FromDiscord | <saint._._.> There’s no way to hand roll everything in nim is there? |
06:09:17 | FromDiscord | <morgan> i was using juce |
06:09:40 | FromDiscord | <morgan> there's no pure nim options, but i should be able to wrap cplug and use that |
06:09:50 | * | rockcavera joined #nim |
06:10:54 | FromDiscord | <morgan> and then combine that with sokol for graphics, also not pure nim but a decent wrapper made by the dev (tho no docs in the source, while the c header is where all the docs are, so kinda annoying to figure out what stuff does) |
06:11:19 | FromDiscord | <morgan> pure nim would be nice but anything to not use c++ lmao |
06:17:06 | FromDiscord | <morgan> i'm working on graphics first because that was the issue that i was struggling with |
06:17:08 | FromDiscord | <sOkam! 🫐> ugly as hell, but at least it works like I expected (minus the T as an argument, but it is what it is) https://media.discordapp.net/attachments/371759389889003532/1211195153235181648/image.png?ex=65ed5063&is=65dadb63&hm=54269a53be3964421796c274d0b322a5ae7c78f3d374391a3724b28ae247e97c& |
06:18:25 | FromDiscord | <sOkam! 🫐> In reply to @morganalyssa "there's no pure nim": you should be able to wrap that new vst protocol with nim no issues. can't remember the name, but its pure C |
06:18:47 | FromDiscord | <morgan> well yea i could handle various plugin apis myself |
06:18:51 | FromDiscord | <morgan> and i might do that someday |
06:19:18 | FromDiscord | <morgan> but using cplug would move things along a bit faster for now |
06:19:56 | FromDiscord | <sOkam! 🫐> @morgan the one I mean is `clap` |
06:20:20 | FromDiscord | <sOkam! 🫐> I believe, now im not sure anymore |
06:20:50 | FromDiscord | <morgan> yea something that was suggested to me was to use clap along with vst3 and au wrappers |
06:54:01 | * | advesperacit joined #nim |
07:04:36 | FromDiscord | <saint._._.> In reply to @morganalyssa "yea something that was": So there are vst3 wrappers for clap? Interesting |
07:04:56 | FromDiscord | <morgan> yeah i havent looked into the wrappers tho |
07:05:19 | FromDiscord | <saint._._.> I’ll look more into clap could be interesting |
07:16:45 | FromDiscord | <morgan> ugh im having to use lldb to figure out why its crashing :pain: |
07:21:14 | * | advesperacit quit () |
07:22:35 | NimEventer | New thread by termer: What is `-d:nimNetLite`?, see https://forum.nim-lang.org/t/11080 |
07:23:39 | * | advesperacit joined #nim |
07:35:49 | * | junaid_ joined #nim |
07:55:43 | * | ntat joined #nim |
09:35:33 | FromDiscord | <itr_> sent a long message, see https://pasty.ee/zmITtVdTFBNM |
09:37:30 | FromDiscord | <Elegantbeef> How do you intend on storing the original state? |
09:38:10 | FromDiscord | <Elegantbeef> You're sorta describing transactional logic, but that's not done for memory cause you have to store the before state somehow |
09:47:26 | FromDiscord | <Elegantbeef> You can just use defer |
10:13:29 | FromDiscord | <ezquerra> This is probably a pretty basic question, but does casting to the same type (e.g. doing `float(x)` when `x` is already a `float`) have any runtime cost? I assume not? |
10:13:50 | FromDiscord | <nnsee> casts have no runtime cost at all |
10:14:40 | FromDiscord | <nnsee> like most things wrt typing, it's a compile time concept only |
10:20:29 | FromDiscord | <Elegantbeef> Well `type(x)` is type conversion and can have overhead |
10:20:37 | FromDiscord | <ezquerra> Well, I guess that casting might have a cost if it's not the same representation in memory? e.g. casting to float from int? |
10:20:39 | FromDiscord | <Elegantbeef> `cast[type](x)` is a C cast and has no overhead |
10:20:52 | FromDiscord | <nnsee> In reply to @Elegantbeef "Well `type(x)` is type": true |
10:21:00 | FromDiscord | <Elegantbeef> float and int are the same representations 😄 |
10:21:08 | FromDiscord | <ezquerra> Bad example |
10:21:24 | FromDiscord | <Elegantbeef> The compiler sorta prevents bad casts |
10:21:28 | FromDiscord | <Elegantbeef> But cast is just reinterpretation |
10:21:43 | FromDiscord | <Elegantbeef> Stop calling type conversions casts and be merry |
10:22:11 | FromDiscord | <nnsee> oh i didn't even notice that example |
10:22:17 | FromDiscord | <nnsee> it's still way too early for me, sorry |
10:22:30 | FromDiscord | <ezquerra> OK then, let me rephrase my original question: does type converting to the same type have a cost? From your replies I'd say it does not, right? |
10:22:46 | FromDiscord | <Elegantbeef> It does not correct |
10:22:52 | FromDiscord | <ezquerra> Thank you! 🙂 |
10:22:56 | FromDiscord | <Elegantbeef> `float(x)` is redundant but what would the runtime check do |
10:24:00 | FromDiscord | <ezquerra> I have some generic code that needs to convert the input to some specific type (which can be the same type as the input or not), hence my original question 🙂 |
10:24:57 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#pasty=qCIPUzCChDRQ |
10:30:27 | FromDiscord | <ezquerra> I didn't notice any warnings? I had an error when I did not explicitly convert the input to float for some operation down the line. I wanted to avoid having to do that `when X isnot SomeFloat` so I wondered if I could just do always do `float(val)` without any cost... |
10:30:56 | FromDiscord | <Elegantbeef> `float(someFloat)` will produce a warning |
10:31:41 | FromDiscord | <Elegantbeef> Or atleast other types do |
10:32:48 | FromDiscord | <Elegantbeef> Ah it's a hint Hint\: conversion from string to itself is pointless [ConvFromXtoItselfNotNeeded] |
10:37:06 | * | Guest23 joined #nim |
10:45:16 | * | Guest23 quit (Quit: Client closed) |
10:55:26 | * | junaid_ quit (Remote host closed the connection) |
11:09:54 | Amun-Ra | that's the safest conversion one can get |
11:15:16 | * | junaid_ joined #nim |
11:23:20 | * | gooba quit (Remote host closed the connection) |
11:37:40 | * | gooba joined #nim |
12:03:37 | * | jmdaemon quit (Ping timeout: 255 seconds) |
12:05:26 | FromDiscord | <saint.___.> @morgan https://github.com/free-audio/clap-wrapper |
12:05:27 | FromDiscord | <saint.___.> Seems interesting |
12:05:40 | FromDiscord | <saint.___.> Would be cool to do a full nim wrapping of clap and then just using that |
12:05:50 | FromDiscord | <saint.___.> Would be nice not to have to use juce or iplug2 |
12:26:06 | * | gooba quit (Remote host closed the connection) |
12:30:28 | * | Guest64 joined #nim |
12:31:12 | * | Guest64 quit (Client Quit) |
12:32:04 | * | gooba joined #nim |
13:08:03 | * | azimut joined #nim |
13:36:33 | * | ntat quit (Remote host closed the connection) |
13:36:54 | * | ntat joined #nim |
13:42:25 | * | disso-peach joined #nim |
14:21:21 | FromDiscord | <rongcuid> Turns out the nim formatter still breaks lines across brackets |
14:25:02 | FromDiscord | <Robyn [She/Her]> In reply to @rongcuid "Turns out the nim": Have you tried `nph`? |
14:25:47 | FromDiscord | <rongcuid> Yeah it works better. |
14:26:16 | FromDiscord | <Robyn [She/Her]> That's good then, you just don't like the style it's enforcing then, I'm guessing? |
14:30:17 | FromDiscord | <rongcuid> I like most of the styles enforced by the default formatter, except something like this: |
14:30:32 | FromDiscord | <rongcuid> sent a code paste, see https://play.nim-lang.org/#pasty=uZsKxjGQWTUL |
14:34:06 | FromDiscord | <Robyn [She/Her]> Yeah that looks gross |
14:34:28 | FromDiscord | <Robyn [She/Her]> Hopefully someone here knows how to stop that? |
15:35:51 | FromDiscord | <kiloneie> is it possible to do this ? `template test(name: untyped or string) =` |
15:38:03 | FromDiscord | <takemichihanagaki3129> sent a code paste, see https://play.nim-lang.org/#pasty=srkABNIXJYcG |
15:44:00 | NimEventer | New thread by enaaab460: Single line ref seq[int] assignment, see https://forum.nim-lang.org/t/11083 |
15:53:22 | FromDiscord | <demotomohiro> sent a code paste, see https://play.nim-lang.org/#pasty=cxDwxhWvlTCx |
16:16:08 | * | def- quit (Quit: -) |
16:16:19 | * | def- joined #nim |
16:17:27 | FromDiscord | <takemichihanagaki3129> In reply to @demotomohiro "https://nim-lang.org/docs/system.html#unlikely.t%2C": Yes, I know. But does I need the `else`? Let's say I'm returning a value.↵I don't actually need the `else`, and I can unindent my code-block, but I'm in doubt about if the optmization will work... |
16:17:32 | FromDiscord | <takemichihanagaki3129> (edit) "optmization" => "optimization" |
16:19:15 | FromDiscord | <takemichihanagaki3129> sent a code paste, see https://play.nim-lang.org/#pasty=zoXURrcvCPaA |
16:19:38 | FromDiscord | <takemichihanagaki3129> Has the second one the same opitmization? |
16:19:57 | Amun-Ra | likely/unlikely doesn't need else branch |
16:20:13 | Amun-Ra | you just point whether given condition likely to happen or not |
16:21:31 | FromDiscord | <takemichihanagaki3129> In reply to @Amun-Ra "likely/unlikely doesn't need else": Thanks! |
16:25:14 | Amun-Ra | using (un)likely makes really sense when given condition is run maaany times |
16:25:57 | Amun-Ra | otherwise speed profit is going to be unnoticeable |
16:29:47 | * | def- quit (Quit: -) |
16:29:58 | * | def- joined #nim |
17:09:40 | * | disso-peach quit (Quit: Leaving) |
17:50:34 | * | tc424 quit (Ping timeout: 255 seconds) |
17:50:49 | * | tc424 joined #nim |
18:08:37 | * | lucasta joined #nim |
18:30:04 | * | def- quit (Quit: -) |
18:31:42 | * | def- joined #nim |
18:40:12 | * | def- quit (Quit: -) |
18:40:44 | * | def- joined #nim |
18:43:46 | * | def- quit (Client Quit) |
19:06:00 | * | def- joined #nim |
19:06:11 | * | lucasta quit (Quit: Leaving) |
19:30:48 | * | def- quit (Quit: -) |
19:53:36 | * | def- joined #nim |
19:59:07 | * | krux02 joined #nim |
20:00:04 | * | def- quit (Quit: -) |
20:02:39 | * | def- joined #nim |
20:05:22 | * | nazgulsenpai quit (Ping timeout: 264 seconds) |
20:06:11 | * | nazgulsenpai joined #nim |
20:06:57 | * | def- quit (Client Quit) |
20:11:14 | * | def- joined #nim |
20:11:14 | * | def- quit (Client Quit) |
20:12:26 | * | def- joined #nim |
20:13:32 | FromDiscord | <deech4592> How do you build Nim on Windows with the Visual Studio C/C++ compiler? The Windows batch file build script hardcodes `gcc`. |
20:15:31 | rockcavera | deech4592 you need to compile c_sourcev2 for vcc. For this you need a Nim compiler. |
20:15:35 | * | def- quit (Client Quit) |
20:16:11 | rockcavera | but if you already have a Nim compiler, it pays to bootstrap using --cc:vcc |
20:17:31 | FromDiscord | <deech4592> That's a shame I was hoping to fully bootstrap. |
20:18:08 | * | def- joined #nim |
20:18:24 | FromDiscord | <deech4592> (edit) "bootstrap." => "bootstrap, I have a C/C++ compiler in my path, that should be enough. In any case, I appreciate the response." |
20:18:36 | rockcavera | booting from C source is distributed to be with gcc |
20:19:16 | FromDiscord | <deech4592> Interesting. Is the generated code using some gcc specific extensions? |
20:19:55 | rockcavera | overflow checks are done by default with bultin gcc |
20:20:13 | rockcavera | builtin |
20:21:43 | * | jmdaemon joined #nim |
20:24:18 | FromDiscord | <Robyn [She/Her]> What's the use of `likely` and `unlikely`? I don't understand how the branch prediction works so would appreciate an explanation |
20:25:15 | FromDiscord | <Robyn [She/Her]> In reply to @rockcavera "overflow checks are done": I wonder if there's a way to turn off these specifics so that a plain C compiler could build Nim from scratch |
20:32:50 | rockcavera | Robyn I don't know |
20:37:11 | FromDiscord | <Robyn [She/Her]> Nim did use to support tinycc, right? Maybe that's a possibility? |
20:44:01 | FromDiscord | <.bobbbob> just wondering, is having a json configuration file, loading it at startup in a sort of config.nim, then loading the keys into global lets so that other files can import config.nim and use them, and to also check that the keys actually exist right away, Okay™️? |
20:44:57 | FromDiscord | <Elegantbeef> It still does support TCC just do `--threads:off` |
20:45:49 | FromDiscord | <rakgew> tcc also nice with inim \:-D |
20:49:33 | * | junaid_ quit (Remote host closed the connection) |
21:05:42 | rockcavera | Robyn I used to do some PRs to keep Nim working with tcc on Windows. But araq informed that it intends to maintain only gcc, clang and vcc |
21:06:15 | rockcavera | but as far as I know, it is still possible to use tcc with --threads:off |
21:10:20 | * | rockcavera quit (Remote host closed the connection) |
21:12:03 | * | junaid_ joined #nim |
21:13:34 | * | rockcavera joined #nim |
21:16:40 | * | droidrage joined #nim |
21:18:28 | * | junaid_ quit (Remote host closed the connection) |
21:40:42 | arkanoid | what is the point of using tcc? |
21:40:51 | arkanoid | it is just speed, or something else? |
21:52:26 | * | lucasta joined #nim |
21:52:48 | * | lucasta quit (Remote host closed the connection) |
21:55:39 | * | ntat quit (Quit: Leaving) |
21:56:11 | * | rockcavera quit (Remote host closed the connection) |
21:58:11 | FromDiscord | <jakraes> What is the performance cost of abstractions/inheritance and using method instead of proc in Nim? Is it that bad? |
21:58:35 | FromDiscord | <Robyn [She/Her]> In reply to @rockcavera "Robyn I used to": Ah fair enough |
21:58:42 | FromDiscord | <Robyn [She/Her]> In reply to @arkanoid "it is just speed,": Yeah just speef |
21:58:45 | FromDiscord | <Robyn [She/Her]> Speed |
21:58:56 | * | rockcavera joined #nim |
22:09:06 | FromDiscord | <Elegantbeef> OOP generally is slower due to pointer indirection whilst the overhead of methods might not be high it depends what you're doing↵(@jakraes) |
22:09:18 | FromDiscord | <Elegantbeef> Methods prevent inline aswell so smaller methods spend more time doing less |
22:10:03 | FromDiscord | <Elegantbeef> The less you rely on runtime polymorphism the better optimised the code can be |
22:11:58 | FromDiscord | <Robyn [She/Her]> In reply to @chronos.vitaqua "What's the use of": Hey Beef, can you explain `unlikely` and `likely` to? |
22:12:09 | FromDiscord | <Elegantbeef> Don't use them there we go |
22:12:36 | FromDiscord | <.bobbbob> Im super confused, I've had a project with prologue that's been working fine, but all of the sudden Ive been getting compile time type mismatch errors where addRoute doesnt recognize the route functions as being the right type even though I changed nothing with them, why would this be happening? |
22:12:54 | FromDiscord | <Elegantbeef> Did you change your compiler version? |
22:13:01 | FromDiscord | <Elegantbeef> Did you update the package and not pin it properly? |
22:13:25 | FromDiscord | <Elegantbeef> Robyn it's just that we have a branch predictor and we can say "just assume this is true" and it makes it the more likely prediction which can make code faster |
22:13:40 | FromDiscord | <Elegantbeef> For the vast majority of code you can just ignore it as it likely causes more harm than good |
22:13:42 | FromDiscord | <.bobbbob> I updated the compier a few weeks ago and it was working fine, the package hasnt been updated in over a year |
22:14:15 | FromDiscord | <Elegantbeef> For instance termer throws likely and unlikely around without any actual benchmarking which can lead to worst performing code |
22:17:45 | FromDiscord | <Robyn [She/Her]> In reply to @Elegantbeef "Robyn it's just that": That seems ineffective in most cases |
22:17:46 | arkanoid | I'm spending way more time than expected trying to extract connected client address-port in prologue |
22:17:57 | arkanoid | the api is obscure |
22:18:43 | FromDiscord | <.bobbbob> sent a code paste, see https://play.nim-lang.org/#pasty=JwfAgprfrCYr |
22:18:47 | arkanoid | just look at the import mess https://github.com/planety/prologue/blob/devel/src/prologue/core/beast/request.nim |
22:19:33 | FromDiscord | <.bobbbob> In reply to @arkanoid "I'm spending way more": I think ctx.request.hostName is the clients ip address if that's what you're asking |
22:20:46 | arkanoid | ctx.request.hostName returns empty |
22:22:13 | FromDiscord | <.bobbbob> oh if I remember correctly it works if you have the prolouge server behind nginx (or something) with proxy_set_header Host $host; |
22:22:47 | FromDiscord | <.bobbbob> aka "works on my machine 🙂 " |
22:22:50 | arkanoid | what? prologue owns the listening sockets, so prologue knows the source ip |
22:24:19 | FromDiscord | <.bobbbob> yeah its weird they dont have a straightforward way to get the ip like jester (or any web framework) |
22:24:44 | FromDiscord | <.bobbbob> https://github.com/planety/prologue/issues/217 |
22:47:56 | * | advesperacit quit () |
22:51:24 | FromDiscord | <Elegantbeef> @.bobbbob they expect arrays no? |
22:52:45 | FromDiscord | <.bobbbob> No it can be a single function, like I said it's been working, I changed some stuff I thought was unrelated so it must somehow have to do with that |
22:53:12 | FromDiscord | <Elegantbeef> I mean all the mismatches are on `openArray` or `Option[T]` |
22:54:45 | * | qwestion joined #nim |
22:56:26 | FromDiscord | <.bobbbob> sent a code paste, see https://play.nim-lang.org/#pasty=dTfPwsnqzAsD |
22:56:54 | FromDiscord | <Elegantbeef> Tag yours GCsafe and see what errors |
23:00:32 | FromDiscord | <.bobbbob> yep I got error not GC safe because I was trying to use a global variable created with let (which is what I was mentioning earlier). Is there a way to do that and keep it gcsafe? Because I'd like to load those at runtime but have them globally accessible |
23:00:47 | FromDiscord | <Elegantbeef> `{.cast(gcSafe.}: #code here` |
23:01:07 | FromDiscord | <.bobbbob> what at the let? |
23:01:14 | FromDiscord | <Elegantbeef> At the usage |
23:03:52 | FromDiscord | <.bobbbob> Do you mean in the function declaration? like this?↵proc index(ctx: Context) {.async, cast(gcsafe).} = |
23:04:00 | FromDiscord | <Elegantbeef> No |
23:04:08 | FromDiscord | <Elegantbeef> Inside your proc where you access the let |
23:04:51 | FromDiscord | <.bobbbob> oh well that's super lame because it totally defeats the point of even having those global constants since they were to make the code cleaner |
23:10:27 | FromDiscord | <.bobbbob> I dont really get why an async function can't access a global let variable since it should be constant right? |
23:22:53 | FromDiscord | <Elegantbeef> `let` can still be mutated using unsafe operations |
23:23:36 | FromDiscord | <Elegantbeef> Whether that's the reason idk |
23:25:09 | FromDiscord | <leorize> I think it's just "globals bad" for that analysis in particular |