00:04:46 | * | krux02 quit (Ping timeout: 260 seconds) |
00:18:43 | arkanoid | Another question. What's the proper way to export C headers from nim? I'd like to call nim code from ffi interface of another language |
00:19:35 | arkanoid | The headers generated by nim c backend are ugly, and variable, is there a way to export them nicely? |
00:20:22 | FromDiscord | <Rika> Weren’t they designed to be ugly |
00:20:54 | FromDiscord | <exelotl> is this using the --header option? |
00:21:32 | FromDiscord | <exelotl> as that's unsupported I believe (though I depend on it 😭) |
00:21:40 | FromDiscord | <Rika> Ah that option |
00:22:34 | arkanoid | Oh, wait, there's exportc https://nim-lang.org/docs/backends.html#interfacing-backend-code-calling-nim |
00:22:36 | FromDiscord | <Rika> Unfortunate it was culled but manpower is hard to come by (iirc) |
00:24:18 | FromDiscord | <exelotl> exportc just removes name mangling so that you can declare the proc as "extern" in C code and call it |
00:24:40 | arkanoid | Is NimMain required to be called even with ARC/ORC? |
00:24:48 | FromDiscord | <Rika> Technically yes |
00:24:57 | FromDiscord | <Rika> Globals are set there |
00:24:57 | arkanoid | I mean, what's the runtime after ARC/ORC? |
00:25:02 | arkanoid | Oh! Ok |
00:27:46 | FromDiscord | <exelotl> if you're making a library and want to produce a .so/DLL + header so you can call it from C, genny is good for that: https://github.com/treeform/genny |
00:28:39 | * | arkurious quit (Quit: Leaving) |
00:28:39 | arkanoid | Sweeeet |
00:29:08 | arkanoid | treeform quality 👌 |
00:30:22 | arkanoid | I don't see where NimMain is defined in maths.c example file here https://nim-lang.org/docs/backends.html#backend-code-calling-nim-nim-invocation-example-from-c |
00:31:25 | arkanoid | The example has forward definition for fibs, but not for NimMain |
00:36:49 | FromDiscord | <exelotl> NimMain is generated by the compiler |
00:47:11 | FromDiscord | <sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=4dns |
00:47:57 | FromDiscord | <exelotl> sent a code paste, see https://play.nim-lang.org/#ix=4dnt |
00:48:45 | FromDiscord | <sOkam!> Oh, i guess i was missing the name of each field before. Tried something similar but wasn't working 🤷♂️ |
00:48:49 | FromDiscord | <sOkam!> tyty |
00:49:31 | FromDiscord | <sOkam!> Is it possible to initialize objects without giving the name of the field, like with C structs? |
00:50:48 | FromDiscord | <sOkam!> C has both options, so wonder if there is the option here too |
00:56:16 | FromDiscord | <exelotl> nope there's not, but then it's common in Nim to make an `initFoo` procedure to use as a constructor |
01:05:15 | qwr | &nim... https://devclass.com/2022/10/11/like-c-before-it-breaking-change-in-go-may-fix-design-decision-that-makes-programs-incorrect/ |
01:08:09 | FromDiscord | <Rika> Bad site I can’t even see the code |
01:08:29 | FromDiscord | <Rika> Nim doesn’t have this issue |
01:08:32 | FromDiscord | <Rika> I don’t think it does |
01:12:22 | * | def- quit (Quit: -) |
01:12:37 | * | def- joined #nim |
01:27:46 | * | wallabra joined #nim |
02:08:22 | FromDiscord | <Elegantbeef> It has a similar issue, but yea it doesnt have the same issuue |
02:10:12 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4dnE |
02:10:35 | * | rockcavera joined #nim |
02:10:35 | * | rockcavera quit (Changing host) |
02:10:35 | * | rockcavera joined #nim |
02:45:08 | FromDiscord | <Tanguy> sent a code paste, see https://play.nim-lang.org/#ix=4dnQ |
02:45:32 | FromDiscord | <Elegantbeef> That's slightly different though |
02:46:49 | FromDiscord | <huantian> I feel like that’s the default behavior for most programming langs |
02:47:02 | FromDiscord | <Elegantbeef> It is things generally arent automatically raised to closure |
02:48:40 | FromDiscord | <Tanguy> I think if you assign to a variable beforehand it works, so looks very similar |
02:49:04 | FromDiscord | <Tanguy> Or maybe I'm confused actually |
02:49:07 | FromDiscord | <Elegantbeef> Nope it doesnt work that way eiither |
02:49:17 | FromDiscord | <Elegantbeef> It'd be a pointer to the same value in the end |
02:50:36 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4dnT |
02:51:55 | FromDiscord | <Elegantbeef> Oh god the code is here, but it's not rendering properly |
02:52:05 | FromDiscord | <Elegantbeef> image.png https://media.discordapp.net/attachments/371759389889003532/1031399171187552256/image.png |
02:52:13 | FromDiscord | <Elegantbeef> image.png https://media.discordapp.net/attachments/371759389889003532/1031399203693400104/image.png |
02:54:56 | FromDiscord | <huantian> In reply to @Elegantbeef "Nope it doesnt work": well it does right? |
02:55:01 | FromDiscord | <huantian> since you make a copy when assigining an int in nim |
02:55:15 | FromDiscord | <Elegantbeef> Except the variable is the same address |
02:55:43 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4dnV |
02:57:21 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4dnW |
02:57:29 | FromDiscord | <Elegantbeef> Where `capture x` is expanded into `proc (x: int): auto = add(myProcs, proc (): int = result = x)(x)` |
02:59:15 | FromDiscord | <Elegantbeef> Whoops that shouldnt be `assert p() == 10` now |
02:59:25 | FromDiscord | <Elegantbeef> Should be `assert p in 0..10` 😛 |
03:06:28 | FromDiscord | <huantian> huh yeah |
03:06:51 | FromDiscord | <huantian> ig I was thinking of c# lol |
03:58:01 | * | rockcavera quit (Remote host closed the connection) |
04:26:24 | * | derpydoo joined #nim |
05:10:06 | * | sagax joined #nim |
05:13:03 | * | sagax quit (*.net *.split) |
05:13:03 | * | xet7 quit (*.net *.split) |
05:13:04 | * | mahlon quit (*.net *.split) |
05:13:04 | * | notchris quit (*.net *.split) |
05:13:05 | * | drewr quit (*.net *.split) |
05:13:13 | * | notchris joined #nim |
05:13:41 | * | mahlon joined #nim |
05:14:48 | * | xet7 joined #nim |
05:24:26 | * | sagax joined #nim |
05:26:30 | * | xet7 quit (Ping timeout: 264 seconds) |
05:56:50 | * | kenran joined #nim |
06:22:18 | FromDiscord | <Bung> any reason koch.exe silently quite on win10? |
06:55:16 | Amun-Ra | I guess https://nim-lang.org/docs/times.html#initTime%2Cint64%2CNanosecondRange |
06:55:27 | Amun-Ra | sorry, paste from backlog |
07:06:28 | * | kenran` joined #nim |
07:07:53 | * | kenran quit (Ping timeout: 250 seconds) |
07:18:30 | * | sagax quit (Remote host closed the connection) |
07:34:19 | * | PMunch joined #nim |
08:03:39 | * | xet7 joined #nim |
08:11:03 | * | derpydoo quit (Quit: derpydoo) |
08:13:17 | FromDiscord | <planetis> Does the .align pragma work with -d:useMalloc? |
08:16:01 | * | derpydoo joined #nim |
08:32:48 | * | derpydoo quit (Quit: derpydoo) |
08:54:13 | * | wallabra_ joined #nim |
08:56:12 | * | wallabra quit (Ping timeout: 264 seconds) |
08:56:14 | * | wallabra_ is now known as wallabra |
09:00:09 | * | TrueBlue[m] quit (Quit: You have been kicked for being idle) |
09:05:48 | * | wallabra quit (Ping timeout: 264 seconds) |
09:27:58 | PMunch | @planetis, doubtful. It will likely align by default though based on platform |
09:53:36 | FromDiscord | <planetis> I see, tried it myself and doesn't seem like it. I have a weird issue with UB due to incorrect alignment that poped up only after the threaded allocator. Can't tell what it's about, but my code could have always been incorrect but now it crashes. |
10:06:34 | * | xet7 quit (Remote host closed the connection) |
11:29:11 | * | jmdaemon quit (Ping timeout: 250 seconds) |
12:06:52 | * | xet7 joined #nim |
12:12:59 | NimEventer | New Nimble package! jtr - jtr is a commmand of JSON tree viewer with type, see https://github.com/u1and0/jtr |
12:14:10 | NimEventer | New thread by pietroppeter: Working towards a Nim Devroom at FOSDEM 2023 (physical event), see https://forum.nim-lang.org/t/9534 |
12:16:30 | * | xet7 quit (Remote host closed the connection) |
12:19:52 | * | arkurious joined #nim |
12:36:51 | * | derpydoo joined #nim |
12:45:11 | FromDiscord | <Horizon [She/Her]> I wonder if there'd be a point to forking nano and adding a plugin system with it (in Nim ofc) |
12:45:41 | FromDiscord | <Horizon [She/Her]> A Nimscript plugin system for nano would be neat to add stuff like autocompletion |
12:47:08 | FromDiscord | <Rika> But wouldn’t that be antithetical to the idea of nano |
12:49:22 | FromDiscord | <Horizon [She/Her]> Yes, but that's why it's a fork↵↵Plus it's simple, and familiar to use, being able to just open it up and get decent autocompletion and such is appealing to me, even if it isn't to others |
12:50:23 | FromDiscord | <Horizon [She/Her]> It's likely not what everyone wants or is looking for like, at all, but people who do want something like nano but nicer and more convenient to use? Then let's give them that option |
13:00:58 | FromDiscord | <ChocolettePalette> It's a better idea to write an Emacs plugin or smth with Nano key bindings. The new fork would be an overkill and it's generally a bad thing to develop something brand new just to fix a tiny issue considering that the number of programmers grows slower than the number of the programs they make |
13:04:33 | FromDiscord | <Horizon [She/Her]> I've never used Emacs tbh |
13:32:54 | PMunch | Ugh, the times module seriously needs a "second subpart" specifier.. |
13:33:35 | PMunch | A timestamp like this is impossible to parse with the times module: 2022-10-12T12:51:58.6727057Z |
13:57:25 | * | PMunch quit (Quit: Leaving) |
14:09:46 | Amun-Ra | why? |
14:12:22 | Amun-Ra | ah, it doesn't use % |
14:13:52 | FromDiscord | <ShalokShalom> In reply to @Isofruit "If you're checking out": What would speak for Prologue? |
14:14:55 | Amun-Ra | I'm not a fan of custom format specifiers |
14:32:21 | FromDiscord | <auxym> @Horizon [She/Her] micro is sort of like nano and supports lua scripts (https://micro-editor.github.io/) sort of OT though |
14:32:44 | FromDiscord | <ShalokShalom> Yeah, it's great! |
14:32:56 | FromDiscord | <ShalokShalom> Love micro |
14:34:49 | FromDiscord | <ShalokShalom> There is also a lsp implementation...↵↵https://github.com/AndCake/micro-plugin-lsp |
14:36:57 | FromDiscord | <Horizon [She/Her]> In reply to @auxym "<@909883978717204561> micro is": Haven't used micro much, the keybinds aren't like nano which is slightly annoying, i prefer nano because it's quick an easy but also wish it had autocomplete |
14:37:21 | FromDiscord | <ShalokShalom> The keybindings can be changed? |
14:37:53 | FromDiscord | <ShalokShalom> https://github.com/zyedidia/micro/blob/master/runtime/help/keybindings.md |
14:37:56 | FromDiscord | <Horizon [She/Her]> From what I've messed around with, exact nano keybinds for stuff like cut, paste, exit and saving ain't doable |
14:38:06 | FromDiscord | <Horizon [She/Her]> I've messed with it a while ago though so may of changed? |
14:38:21 | FromDiscord | <ShalokShalom> Write a plugin, otherwise 😅 |
14:39:34 | FromDiscord | <Horizon [She/Her]> Yeah I'll probably have to haha |
14:47:15 | FromDiscord | <Phil> In reply to @ShalokShalom "What would speak for": Less magic, IMO more understandable, middleware support which makes creating some extensions easier, I'd argue better docs |
14:47:41 | FromDiscord | <ShalokShalom> K |
14:50:36 | FromDiscord | <Phil> Jester points with more concise syntax that focuses reduces the amount of code on screen to the absolute minimum and... Likely some other things but I haven't used jester so the first one is all I'm aware of |
14:51:09 | FromDiscord | <Phil> (edit) removed "focuses" |
14:59:42 | FromDiscord | <ShalokShalom> Sad, that its almost always 'good thing here, good thing there' and by that, some kind of tradeoffs |
15:05:48 | * | pbsds joined #nim |
15:07:43 | FromDiscord | <Phil> The only way you can achieve "Throw away boilerplate" to this scale is through macro magic, which will make things more of an "You need to know X to understand" by virtue of being macro magic |
15:09:23 | FromDiscord | <Phil> Prologues "Boilerplate", which stems 99% from the procs that set up routes, is imo stuff that allows you to simply set stuff up.↵Yeah its more typing, but it feels more familiar to how frameworks in other languages do it as well (django and java in my case as basis of experience) |
15:09:58 | FromDiscord | <Phil> (edit) removed "simply" | "up.↵Yeah" => "up in a simple and likely somewhat familiar manner that is more understandable in how it connects things.↵Yeah" |
15:10:47 | FromDiscord | <Phil> "addRoute" on an object that represents my server is immediately understandable for example. |
15:13:23 | FromDiscord | <Phil> Concise via throwing out syntax that explicitly states actions that always need to happen for any application (connecting a route to your web-application)↵vs↵Understandability via Boilerplate from keeping syntax that explicitly states things that always need to happen for any application |
15:16:33 | FromDiscord | <ShalokShalom> https://surrealdb.com/ |
15:16:38 | FromDiscord | <ShalokShalom> Nim binding when |
15:18:21 | * | kenran` quit (Remote host closed the connection) |
15:18:47 | * | rockcavera joined #nim |
15:18:47 | * | rockcavera quit (Changing host) |
15:18:47 | * | rockcavera joined #nim |
15:20:53 | FromDiscord | <Phil> ~~right after mongo and elastic search packages~~ |
15:36:49 | FromDiscord | <Phil> Turns out we have a mongo package, so only elastic search then |
15:41:24 | * | rez joined #nim |
15:49:35 | FromDiscord | <wick3dr0se> If anyone has time, could they check the validity of my notes? It's rather short currently (~2 min read)↵↵https://github.com/wick3dr0se/learn-nim |
16:05:52 | FromDiscord | <Phil> Do you only care about syntax or do you also want hints when to use what? |
16:07:06 | FromDiscord | <Phil> Specifically case statements at a glance are the kind of things where you need to learn their purpose and how to appreciate them first, thus the question |
16:09:29 | FromDiscord | <wick3dr0se> Well I'm keeping a seperate personal file for examples like common functions/procedures. I am very familiar with case statements in C and BASH but I want any corrections |
16:10:34 | FromDiscord | <wick3dr0se> Maybe I'm not right about when to use if vs case. That would definitely help |
16:12:24 | FromDiscord | <Phil> Prefer let over var in general. Only use var if you're absolutely forced to |
16:12:50 | FromDiscord | <wick3dr0se> Really? Is that because let is immutable? |
16:13:30 | FromDiscord | <wick3dr0se> I was confused by let with a heavy shell background. `let` is much different then and not as performant |
16:13:38 | FromDiscord | <Phil> Aye. Let gives your reader the guarantee that you won't change the value of something, making reading easier |
16:14:16 | FromDiscord | <Phil> If you can, use const, that just isn't always viable since you can't know everything at compile time |
16:14:17 | FromDiscord | <wick3dr0se> Ok good to know. So prefer const or let if defining |
16:16:45 | FromDiscord | <Phil> Aye. Case statements are as usual, they are there to cover all possibilities of a value, I would generally prefer them over if else trees, though I'd only break them out if you want to cover at least 3 (case1, case2 and default / case3 )different cases, but that's specific rule is personal preferences |
16:17:37 | FromDiscord | <wick3dr0se> Ok that's what I wrote was 3 or more conditions for case. I think that's a good point to prefer a case |
16:17:57 | FromDiscord | <Phil> Use enums whenever possible instead of magic numbers/strings, though that's true for any language |
16:18:30 | FromDiscord | <wick3dr0se> Whats the difference between object and enum? |
16:18:43 | FromDiscord | <Phil> Question, do you differentiate between what you wrote down as data types and objects? |
16:18:59 | FromDiscord | <wick3dr0se> I'm not very familiar with enums either |
16:19:20 | FromDiscord | <wick3dr0se> No I'm not sure what you mean |
16:23:08 | * | xet7 joined #nim |
16:23:29 | FromDiscord | <Phil> sent a long message, see http://ix.io/4dql |
16:24:06 | FromDiscord | <Phil> Another benefit is general readability.↵PowerState.Off is more readable than just 0, you know what is meant |
16:25:57 | FromDiscord | <wick3dr0se> Yea that makes a lot of sense now. Magic numbers as in numbers that are hard to interpret or could easily be changed ig. So the enums defines constant names for these values, which I can see being better all around |
16:26:05 | FromDiscord | <Phil> A third benefit is case statements. If you case over an enum and don't provide a default case, the compiler will error out telling you that you also need to handle enum value Z that you've forgotten.↵Particularly useful if you expand the number of values in an enum, as the compiler will tell you if something is missing in your code |
16:26:38 | FromDiscord | <Phil> (edit) "forgotten.↵Particularly" => "forgotten, should you not have a case for every possible enum value.↵Particularly" |
16:27:01 | FromDiscord | <wick3dr0se> Unless you do else: discard? |
16:27:08 | * | PMunch joined #nim |
16:27:16 | FromDiscord | <Phil> Basically, enums represent a finite amount of values that are allowed for a given variable |
16:27:27 | PMunch | Hype! Just saw that the NimConf presentation are now scheduled on YouTube :) |
16:27:33 | FromDiscord | <Phil> Correct, else discard would be handling the default case |
16:27:52 | FromDiscord | <Phil> The default case being any case you didn't cover |
16:28:50 | FromDiscord | <wick3dr0se> Ok so I'm really thinking enums is a lot like a dictionary in BASH lol |
16:29:45 | FromDiscord | <Phil> In reply to @wick3dr0se "No I'm not sure": An object is strictly speaking also a data type, though you didn't list it there.↵I was thinking you might be differentiating between ref types, which get allocated on the heap, Vs value types that get allocated on the stack |
16:30:45 | FromDiscord | <Phil> In which case your list would be true for languages like java, but not quite for Nim where everything can be a ref or a value type (some exceptions apply) |
16:31:19 | FromDiscord | <wick3dr0se> sent a code paste, see https://play.nim-lang.org/#ix=4dqp |
16:31:52 | FromDiscord | <wick3dr0se> (edit) "https://play.nim-lang.org/#ix=4dqp" => "https://play.nim-lang.org/#ix=4dqr" |
16:32:13 | FromDiscord | <wick3dr0se> I'll have to look more into objects vs data types now |
16:32:45 | FromDiscord | <Phil> I haven't written much in bash, but I don't think at a glance that the analogy holds true. There are similarities, but dicts in bash are most likely analogous to tables in Nim |
16:33:43 | FromDiscord | <Phil> Your life becomes easier if you think of it all as just types, with objects and tuples allowing you to group different values together in a package |
16:34:06 | FromDiscord | <Phil> (edit) "Your life becomes easier if you think of it all as just types, with objects and tuples allowing you to group different values together in a package ... " added "that you can simply pass back and forth" |
16:34:37 | FromDiscord | <wick3dr0se> Thanks a ton for all the info! I have some to study now and I'll make some changes once I know a proper difference |
16:36:01 | FromDiscord | <Phil> When also is somewhat special as it will literally cut out the piece of code inside of it if the condition is false |
16:36:57 | FromDiscord | <Phil> That is important because the compiler will not evaluate that piece of code. So you can write completely syntactically wrong code if you hide it behind a when false statement |
16:37:53 | FromDiscord | <Phil> Your project should still be able to compile because that invalid code behind when false is never actually there, it gets cut out |
16:39:58 | FromDiscord | <Phil> That allows some funky stuff like removing a feature from a binary if a specific compiler flag is set or not set |
16:40:14 | FromDiscord | <Phil> (edit) "That allows some funky stuff like removing a feature from a binary if a specific ... compiler" added "custom" |
16:41:14 | FromDiscord | <wick3dr0se> Oh wow that's cool but confusing a bit at the same time. I would think the false if statements wouldnt be seen by the compiler either unless true |
16:41:43 | FromDiscord | <Phil> That's only true for if, not when, hence why it's its own keyword |
16:42:46 | FromDiscord | <Phil> A lot of packages make use of that for example to cut out any logging from their packages unless the user provides a specific flag to remove any hits to performance these flags might otherwise have |
16:43:44 | FromDiscord | <Phil> (edit) "flags" => "logging calls" |
16:44:39 | FromDiscord | <wick3dr0se> Ok that makes more sense to me. I just have a hard time telling the difference. I know you could achieve the same affect with an if but basically the difference is false if statements are seen by the compiler and false when statements are not? |
16:45:39 | FromDiscord | <wick3dr0se> I know I'm going to have to read something details about this when statement. I'll have to look that one up to undsrstsnd it likely |
16:46:19 | FromDiscord | <Phil> In reply to @wick3dr0se "Ok that makes more": Aye |
16:46:38 | FromDiscord | <wick3dr0se> (edit) "something" => "some more" | "undsrstsnd" => "understand" | "likely" => "fully" |
16:48:26 | FromDiscord | <Phil> When statements are also heavily used with generics, but that's a topic for a different time.↵On that note: You may not yet have generics in your list, but the following is useful to keep in mind for them:↵Generics are not actually code, they themselves do not get compiled. ↵They are a template that the compiler-preprocessor (or something) copy pastes wherever you use the generic with a specific type that is needed there |
16:49:25 | FromDiscord | <wick3dr0se> I guess its just really confusing to me because an if statement stops executing when a condition evaluates as true. So wouldn't a when statement be quicker/better than if? Idk why you'd ever want to evaluate a false statement |
16:50:15 | FromDiscord | <Phil> In reply to @wick3dr0se "I guess its just": Keep in mind when only works with booleans you know at compile-time.↵If works with booleans you know at compile- and runtime.↵How familiar are you with the differences between the two? |
16:50:59 | FromDiscord | <wick3dr0se> Ok I got you. So when works with constants and if works with mutable variables that could be supplied as arguments for example |
16:51:58 | FromDiscord | <Phil> When works only with const (aka compile-time variables), if works with const, let and var. I'd be hesitant to say "Mutable variables" because that only means var. "Runtime variables" would be the thing that encompasses let and var both and is the intended usecase for if |
16:52:56 | FromDiscord | <wick3dr0se> Ok I get that because let becomes a constant value but can be initialized at runtime by a function or something |
16:53:52 | FromDiscord | <Phil> let becomes a constant value in the sense that you can't change it, aye, not in the sense that you can know its value before the program actually runs |
16:54:06 | FromDiscord | <Phil> (edit) "becomes a" => "variables represent" | "it," => "them," |
16:54:17 | FromDiscord | <Phil> The latter is what const is for |
16:55:35 | FromDiscord | <wick3dr0se> Ok I get that! Thanks a lot man. You've helped more than reading for an hour lol |
16:56:13 | FromDiscord | <wick3dr0se> I'll jump into objects/data types and generics next |
16:56:17 | FromDiscord | <Phil> Happy to help. I assume I've bombarded you with more than enough for now.↵There is more about various other things, but I think what you've got right now already is a decent chunk |
16:56:28 | FromDiscord | <wick3dr0se> Yea no lie lol |
16:56:42 | FromDiscord | <wick3dr0se> I'll come back later with an updated list lol |
16:56:56 | FromDiscord | <wick3dr0se> Prob not today |
16:57:08 | FromDiscord | <Phil> Fun fact though, if you want to play around with nim in scripting in it like bash, you can type in `nim secret` into the terminal |
16:57:29 | FromDiscord | <Phil> It'll open a REPL like in python where you can do stuff like write `5 + 2` and it'll respond with the answer |
16:57:45 | FromDiscord | <wick3dr0se> So it becomes an interpeter? |
16:57:59 | FromDiscord | <wick3dr0se> Thats awesome |
16:58:02 | FromDiscord | <Phil> Aye.↵Nim secret (aka the VM) is what nim uses to evaluate macros and such |
16:58:18 | * | PMunch quit (Quit: leaving) |
16:58:26 | FromDiscord | <wick3dr0se> Def gonna try that out |
16:58:28 | FromDiscord | <Phil> You don't have access to all nim libraries with it as some just can't be used the way the VM does, but for normal stuff it should be enough |
16:59:20 | FromDiscord | <wick3dr0se> Been trying to figure out how to script in Nim since I saw it's capable of high-level workings like Python is |
16:59:55 | FromDiscord | <auxym> INim works pretty well for me for a REPL, though it actually compiles to C on the fly, rather than run in the nim VM |
17:00:02 | FromDiscord | <Phil> If you want to use it with full library access, try inim.↵Inim is not strictly speaking a REPL, it works by basically writing a file with whatever you enter and compile it every time you enter a line |
17:00:17 | FromDiscord | <Phil> Auxym was faster 😄 |
17:00:21 | FromDiscord | <wick3dr0se> Lmao |
17:00:58 | FromDiscord | <wick3dr0se> I'll try both. You guys are a lot of help here |
17:01:00 | FromDiscord | <Phil> Installing inim is also pretty straight forward, `nimble install inim` and then just type `inim` in the terminal |
17:01:09 | FromDiscord | <Phil> Happy to help |
17:01:24 | FromDiscord | <wick3dr0se> I'll be back once my brian isn't close to metlting |
17:01:37 | FromDiscord | <Phil> Understandable, felt similar to me start of the year when I got into nim 😄 |
17:02:52 | FromDiscord | <wick3dr0se> Lol my BASH and not very proficent C, does not compare! I absolutely love Nim so far tho. I'm grateful to be learning it before it's mainstream |
17:21:26 | FromDiscord | <jos> ok so i got my sexpr based compilation working for wasm |
17:21:29 | FromDiscord | <jos> now i wanna emit the binary format |
17:21:34 | FromDiscord | <jos> i am lookin for |
17:21:45 | FromDiscord | <jos> a good lib to write structs to binary, i think |
17:21:56 | FromDiscord | <jos> like something like |
17:22:33 | FromDiscord | <jos> sent a code paste, see https://play.nim-lang.org/#ix=4dqB |
17:22:54 | FromDiscord | <jos> and then i want to flatten that into a byte array `@[id, size[0], size[1], size[2], size[3], contents[0] ... contents[n]]` |
17:23:32 | FromDiscord | <jos> that might be overkill or even kind of shitty for a compiler so i will settle for something like just a way to write it out manually like you would with python's `struct` module |
17:44:53 | FromDiscord | <Horizon [She/Her]> In reply to @ShalokShalom "https://surrealdb.com/": Are there C bindings? :P |
17:45:21 | FromDiscord | <Horizon [She/Her]> Probably could use Futhark to wrap it up, then add some destructor magic to make it work well with the GC |
18:03:18 | FromDiscord | <Horizon [She/Her]> Question: How am i supposed to compile my C code with Nim code? |
18:03:32 | FromDiscord | <Horizon [She/Her]> I'm including Nim code in an existing C project |
18:07:32 | FromDiscord | <Phil> In reply to @jos "ok so i got": Missunderstandings of `sexpr` incomiiiiiiing (why yes, I indeed have the sense of humour of a 14 year old in some respects) |
18:08:08 | FromDiscord | <jos> wat |
18:09:43 | FromDiscord | <Phil> s-expression I assume, can also be read sex-pression |
18:09:58 | FromDiscord | <jos> :cartired: |
18:10:03 | FromDiscord | <jos> sip |
18:14:54 | * | hellstabber joined #nim |
18:15:51 | * | hellstabber left #nim (#nim) |
18:33:17 | FromDiscord | <Phil> I don't know what changed, but something changed, because I've never seen my endpoint that gives me an overview over the most recently updated articles on my webpage be that flopping fast |
18:35:17 | FromDiscord | <Phil> That mofo is busting through somewhere between 24 and 48 sqlite-DB queries, parsing that into objects, then parsing those objects into JSON with truncated texts after 30 words in under 30 ms at the moment. That took like 120ms before and I'm semi-certain I didn't touch the parsing code... maybe the shared CPU of my server is just not being used at the moment |
18:35:49 | FromDiscord | <Phil> (edit) "moment." => "moment (plus another 30ms of latency)." |
18:55:49 | FromDiscord | <ShalokShalom> In reply to @Event Horizon "Are there C bindings?": Yep ↵↵And JavaScript |
18:55:50 | FromDiscord | <ShalokShalom> https://github.com/surrealdb/surrealdb.c |
18:59:12 | FromDiscord | <Horizon [She/Her]> @ShalokShalom yeah then you can just use Futhark to make the bare minimum C bindings, then just add ontop of that |
19:03:13 | FromDiscord | <ShalokShalom> Mhn |
19:10:39 | FromDiscord | <Takemichi Hanagaki> Does Nim have any eval function? |
19:11:26 | FromDiscord | <Patitotective> futhark calls me https://azul.rs |
19:11:55 | FromDiscord | <Patitotective> In reply to @Takemichi Hanagaki "Does Nim have any": to evaluate code at runtime? no |
19:12:18 | FromDiscord | <Patitotective> (edit) "no" => "dont think so" |
19:12:32 | FromDiscord | <Takemichi Hanagaki> In reply to @Patitotective "to evaluate code at": Ohh, thanks! |
19:12:48 | FromDiscord | <Patitotective> what do you want to do? |
19:47:36 | * | wallabra joined #nim |
20:06:39 | FromDiscord | <wick3dr0se> Is there a library for setting wallpapers? |
20:07:51 | FromDiscord | <jos> i looked around and i still can't find a good way to write binary data with a specific endianness in nim |
20:08:05 | FromDiscord | <jos> casting is kind of dense, looking for something with an interface more like serde |
20:08:27 | FromDiscord | <Elegantbeef> Frosty + https://nim-lang.org/docs/endians.html |
20:12:23 | FromDiscord | <jos> that looks good, is there something like a ByteStream in nim std |
20:12:30 | FromDiscord | <jos> in std/streams i only see file and string |
20:12:46 | FromDiscord | <Elegantbeef> What's special about a byte stream? |
20:12:59 | FromDiscord | <Elegantbeef> It's just a string stream by a different name |
20:13:14 | FromDiscord | <jos> i figure string is probably char, maybe even utf8, instead of the byte data type |
20:13:18 | FromDiscord | <jos> not sure |
20:13:21 | FromDiscord | <jos> relatively new to nim |
20:13:59 | FromDiscord | <Elegantbeef> strings in Nim are just byte sequences with a `\0` at the end |
20:14:00 | FromDiscord | <Elegantbeef> utf8 encoded strings are bytes |
20:15:42 | FromDiscord | <jos> well yeah but if the data type i'm reading out is char or codepoint or something |
20:15:49 | FromDiscord | <jos> prolly gonna run into weird issues, no? |
20:15:57 | FromDiscord | <Elegantbeef> Why? |
20:16:08 | FromDiscord | <Elegantbeef> Most Nim string operations are not unicode aware |
20:16:12 | FromDiscord | <Elegantbeef> That's what `std/unicode` is for |
20:16:34 | FromDiscord | <jos> is byte an alias for char? |
20:16:42 | FromDiscord | <Elegantbeef> A vast majority of string operations are only byte aware |
20:16:52 | FromDiscord | <jos> eh |
20:17:10 | FromDiscord | <jos> it's definitely odd |
20:17:27 | FromDiscord | <jos> the only reason it feels normal is because c did it first for weird reasons |
20:17:34 | FromDiscord | <Elegantbeef> They're both 1 byte |
20:17:34 | FromDiscord | <Elegantbeef> They're distinct tpyes |
20:17:35 | FromDiscord | <Elegantbeef> !eval echo ord("🐧"[0]) |
20:17:39 | NimBot | 240 |
20:18:09 | FromDiscord | <Elegantbeef> It makes sense as it removes a bunch of noob traps |
20:18:27 | FromDiscord | <Elegantbeef> `[]` being O(1) is much easier to understand than `[]` being O(n) |
20:18:52 | FromDiscord | <Elegantbeef> If one cares about unicode they use the unicode module and everything is fine |
20:19:15 | FromDiscord | <Elegantbeef> https://github.com/beef331/recyclable/blob/master/src/recyclable/unicodestrs.nim stuff like this also can be made |
20:19:19 | * | LuxuryMode joined #nim |
20:20:23 | FromDiscord | <jos> well i mean i agree with a lot of what you're saying but we're pretty far away from where we started |
20:20:36 | FromDiscord | <jos> i just want stream[byte] instead of stream[char] for ergonomics reasons |
20:20:43 | FromDiscord | <jos> it doesn't look like it exists, is there an alternative? |
20:20:46 | FromDiscord | <Elegantbeef> It literally doesnt matter |
20:20:54 | FromDiscord | <Elegantbeef> You read from the stream using operations |
20:21:14 | FromDiscord | <Elegantbeef> https://nim-lang.org/docs/streams.html#readUint8%2CStream |
20:21:18 | FromDiscord | <jos> i mean at the bare minimum i'm going to have to cast the char to a byte because the rest of my api assumes byte for bytes |
20:21:28 | FromDiscord | <Elegantbeef> https://nim-lang.org/docs/streams.html#readData%2CStream%2Cpointer%2Cint |
20:21:37 | FromDiscord | <Elegantbeef> The internal data doesnt matter |
20:21:52 | FromDiscord | <jos> oh i see |
20:22:01 | FromDiscord | <jos> that's probably tru |
20:22:17 | FromDiscord | <Elegantbeef> you can also use `myStrStream.data.toOpenArrayByte(0, myStrStream.getPos())` if you want to pass it to a `openArray[byte]` |
20:22:24 | FromDiscord | <jos> yes that was my next question |
20:22:27 | FromDiscord | <jos> that sounds fine though |
20:22:29 | FromDiscord | <jos> i can use this for now, thanks |
20:22:37 | FromDiscord | <Elegantbeef> No problem |
20:23:31 | FromDiscord | <Elegantbeef> thought i made it clear which is why i want on the tangent of the unicode 😛 |
20:24:03 | FromDiscord | <jos> well i didn't realize it was just an internal representation |
20:24:23 | FromDiscord | <jos> i didn't look at the api, once i saw that each data type had a method to read out, it made sense |
20:24:33 | FromDiscord | <jos> but given what i was asking for that should have been obvious |
20:24:36 | FromDiscord | <jos> 🙂 |
20:51:16 | qwr | operating on bytes is often good enough - if you treat offsets as pointers to utf-8 text, and not as actual symbol offsets, which they are not |
20:53:37 | qwr | and often enough, that imho its actually rare to care how many symbols somewhere actually is - that's usually important when formatting text into some layout using fixed-width characters |
20:59:00 | qwr | or when doing long-term data storage, like database - then you need to be sure what the actual encoding is |
21:01:11 | qwr | for that it is useful to have separate text type, like the unicodestr referred by Elegantbeef |
21:17:30 | FromDiscord | <Takemichi Hanagaki> In reply to @Patitotective "what do you want": Just create a simple REPL. 🙂 |
21:17:53 | arkanoid | is there a nim package that deals with uncertainties and error propagation? |
21:18:05 | FromDiscord | <Takemichi Hanagaki> In reply to @Takemichi Hanagaki "Just create a simple": Most a prototype than a project.↵I was think do it using nimScript. |
21:18:54 | FromDiscord | <Takemichi Hanagaki> Just to learn to do terminal applications with nim. |
21:23:20 | FromDiscord | <Horizon [She/Her]> A friend talked about constant pointers, but what does that mean? And are they doable in Nim? (I'm clueless about it) |
21:23:48 | FromDiscord | <Elegantbeef> `--experimental:strictFuncs` and `ref T` |
21:23:49 | FromDiscord | <Elegantbeef> Done |
21:24:25 | FromDiscord | <Recruit_main707> strictFuncs still experimental? :( |
21:24:31 | FromDiscord | <Horizon [She/Her]> Oh so constant pointers are reference types? |
21:24:42 | FromDiscord | <Horizon [She/Her]> In reply to @Recruit_main707 "strictFuncs still experimental? :(": Iirc they're being made standard in Nim 2.0 |
21:25:40 | FromDiscord | <Recruit_main707> reference types are just pointer types, and with strict funcs arguments cannot be mutated |
21:26:33 | FromDiscord | <haywireSSC> sent a code paste, see https://play.nim-lang.org/#ix=4drI |
21:27:11 | FromDiscord | <haywireSSC> If the name doesn't have letters and is something like `====` it works like this but with letters doesn't |
21:27:24 | FromDiscord | <haywireSSC> (edit) "`====`" => "\`====\`" |
21:27:37 | FromDiscord | <Recruit_main707> iirc you cant, the closest you can get is `a.myFunc b` |
21:27:46 | FromDiscord | <haywireSSC> Oh |
21:27:58 | FromDiscord | <haywireSSC> Ty |
21:28:05 | FromDiscord | <Recruit_main707> np |
21:28:31 | FromDiscord | <Horizon [She/Her]> In reply to @Recruit_main707 "reference types are just": Ah |
21:28:39 | FromDiscord | <haywireSSC> Another question, do you know how I would use the callconv pragma? |
21:29:39 | FromDiscord | <Recruit_main707> for a single function? |
21:30:09 | arkanoid | is there a tool that converts all snake_case to camelCase? |
21:30:16 | FromDiscord | <haywireSSC> Yeah, I couldn't find what options to give it |
21:30:19 | FromDiscord | <Recruit_main707> `proc name(args) {.[calling convention (cdecl, nimcall, etc).}` |
21:30:27 | arkanoid | I'm porting python code and it would save me some time |
21:30:32 | FromDiscord | <Recruit_main707> forgot closing ] but you get it :P |
21:30:41 | FromDiscord | <Elegantbeef> sent a code paste, see https://paste.rs/xv8 |
21:30:45 | FromDiscord | <haywireSSC> Thanks! |
21:31:26 | FromDiscord | <haywireSSC> In reply to @Recruit_main707 "forgot closing ] but": What do the [] do? |
21:32:20 | FromDiscord | <Recruit_main707> it means that whatever its written its not what you are supposed to write exactly, but that its an explanation |
21:32:22 | FromDiscord | <Elegantbeef> Recruit is just being funky |
21:34:05 | FromDiscord | <haywireSSC> In reply to @arkanoid "is there a tool": https://media.discordapp.net/attachments/371759389889003532/1031681532588462130/Screenshot_20221017-223338_Samsung_Internet.jpg |
21:34:28 | FromDiscord | <Recruit_main707> time zone reveal 👀 |
21:34:43 | FromDiscord | <haywireSSC> In reply to @Recruit_main707 "it means that whatever": Ah lol k |
21:35:18 | FromDiscord | <haywireSSC> In reply to @Recruit_main707 "time zone reveal 👀": Bri'ish time heh |
21:35:28 | FromDiscord | <Elegantbeef> Fucking tea drinkers |
21:35:49 | FromDiscord | <Recruit_main707> the T word |
21:36:12 | FromDiscord | <haywireSSC> In reply to @Elegantbeef "Fucking tea drinkers": Yup |
21:36:19 | * | om3ga quit (Read error: Connection reset by peer) |
21:37:31 | * | om3ga joined #nim |
21:44:18 | * | jmdaemon joined #nim |
22:12:34 | FromDiscord | <auxym> In reply to @jos "i looked around and": https://justine.lol/endian.html scroll to the bottom for the WRITExLE/BE macros, pretty straightforward to translate in nim. Also the article is worth a read, justine is the author of cosmopolitan-libc and a bunch of other bit hacks, she knows her stuff. |
22:17:17 | FromDiscord | <auxym> In reply to @Elegantbeef "strings in Nim are": wut. I thought nim strings stored the length in a separate field, basically the same as a seq[char]. Not null terminated |
22:18:20 | FromDiscord | <Elegantbeef> They do both |
22:18:38 | FromDiscord | <Elegantbeef> Notice how i said "they're just byte sequences", then followed it with "a \\0 at the end" 😄 |
22:19:39 | FromDiscord | <auxym> didn't know they stored an extra null byte at the end. For easy conversion to cstring I guess? |
22:19:46 | FromDiscord | <Elegantbeef> Yes 0 cost cstrings |
22:19:54 | FromDiscord | <Elegantbeef> Almost all languages with pascal strings do this |
22:20:03 | FromDiscord | <auxym> that's a nice extra for the cost of 1 byte I guess |
22:22:43 | FromDiscord | <Elegantbeef> It's a very beneficial feature for like next to no effort |
22:24:31 | FromDiscord | <Elegantbeef> For any FFI interop you dont need to do any extra allocations, so you are become speed |
22:28:28 | FromDiscord | <jos> In reply to @auxym "https://justine.lol/endian.html scroll to the": I mean the stuff in std/endians is good for this I just want a nice interface to write binary data in general |
22:29:00 | FromDiscord | <jos> higher level than just write(littleEndian16(val)) |
22:38:37 | FromDiscord | <auxym> hm, does `shallowCopy` actually do anything for refs? Seems like it's just doing an assignment like `=`. |
22:39:27 | FromDiscord | <Elegantbeef> It doesnt increment/decrement the ref counter. It's removed with `orc`/ `arc` |
22:42:08 | FromDiscord | <auxym> Any way to copy data from one ref to the other, but no deepCopy of nested refs? low level copyMem with pointers I guess? |
22:42:42 | FromDiscord | <Elegantbeef> `myRef[] = myOtherRef[]` |
22:42:58 | FromDiscord | <Elegantbeef> That will copy strings/seqs, but only those |
22:44:03 | FromDiscord | <auxym> Sounds like what I need, but surely it will also copy other value-type fields like ints, plain objects, etc? |
22:44:55 | FromDiscord | <Elegantbeef> of course it copies those |
22:45:03 | FromDiscord | <auxym> yeah, looks like it's working as expected, ty 👍 |
22:45:05 | arkanoid | lineinfos.nim(287) raiseRecoverableError Error: unhandled exception: cannot extract number from invalid AST node [ERecoverableError] |
22:45:22 | arkanoid | what kind of error is this? |
22:45:25 | FromDiscord | <Elegantbeef> How else do you have contiguous data that isnt a refernce auxym 😄 |
22:46:12 | FromDiscord | <auxym> yeah I know lol. Was just surprised by the fact that shallowCopy was not actually copying anything |
22:46:33 | FromDiscord | <Elegantbeef> ShallowCopy is pretty much a fancy `ptr` |
22:49:05 | arkanoid | proc foo[A,B,C](a: A, b: B): C, how can I pass generic argument C when calling foo? I don't remember the syntax |
22:55:27 | FromDiscord | <Generic> you need to explicitly instantiate it |
22:55:38 | FromDiscord | <Generic> e.g. foo[int, int, int]() |
22:56:25 | arkanoid | Generic, but A and B can be implicitly acquired by arguments |
23:01:09 | FromDiscord | <Generic> then put C first |
23:01:29 | FromDiscord | <Generic> proc foo[C,A,B](a: A, b: B): C |
23:01:51 | FromDiscord | <Generic> foo[int](1,2) so that A and B should be int should work, though I'm not 100% sure |
23:08:37 | arkanoid | Generic, nope, it asks for 3 even if I send 1 and 2 are implicit |
23:09:24 | FromDiscord | <huantian> Perhaps you can use a typedesc |
23:09:40 | FromDiscord | <huantian> But you’d have to pass the type as a parameter |
23:10:31 | FromDiscord | <huantian> `proc foo[A, B, C](a: A, b: B, _: typedesc[C]): C` |
23:12:03 | FromDiscord | <Generic> what about auto? |
23:13:52 | arkanoid | huantian, your solutions works! Thanks! |
23:14:15 | arkanoid | Generic, I was using auto, but I was getting weird macro errors from within compiler |
23:15:03 | FromDiscord | <Generic> ah |
23:23:49 | arkanoid | Generic, I've just made "auto" work! I didn't know I could cast to auto |
23:24:09 | arkanoid | return 0.auto is valid |
23:24:09 | qwr | Elegantbeef: you're right, in go-lang the for has worse issue due by allowing to take direct ref of loop variable, nim has only closure capture fun |
23:24:37 | FromDiscord | <Generic> you could cast to auto |
23:24:38 | FromDiscord | <Generic> ? |
23:24:41 | FromDiscord | <Generic> til |
23:41:30 | arkanoid | I have "type Percent = range[0.00001..0.99999]". If I sum or subtract two Percent variables, the resulting type is float. What's the correct way to enforce the range? |
23:41:57 | arkanoid | should I make it distinct and rewrite/borrow the ops, or should I cast after the op? |