00:00:01 | * | junland quit (Quit: %ZNC Disconnected%) |
00:00:43 | * | junland joined #nim |
00:38:14 | FromDiscord | <Rika> @krabbypatty they are both correct syntaxes; in fact, the first one is what is considered idiomatic |
00:38:22 | FromDiscord | <Rika> dont ask me why though |
00:39:02 | FromDiscord | <krabbypatty> every page of the docs I've seen uses the second one |
00:39:05 | FromDiscord | <krabbypatty> `case x:` |
00:39:12 | FromDiscord | <krabbypatty> I haven't seen the first one mentioned anywhere |
00:39:34 | FromDiscord | <Rika> mind linking? |
00:39:38 | FromDiscord | <krabbypatty> ok that's a lie, documentation uses both |
00:39:41 | FromDiscord | <krabbypatty> which is worse imo |
00:39:44 | FromDiscord | <krabbypatty> https://nim-lang.org/docs/manual.html#statements-and-expressions-case-statement |
00:39:55 | FromDiscord | <krabbypatty> # indentation of the branches is also allowed; and so is an optional colonβ΅# after the selecting expression: |
00:40:12 | FromDiscord | <Rika> well its to demonstrate both is fine? |
00:40:19 | FromDiscord | <krabbypatty> yeah |
00:40:27 | FromDiscord | <Rika> i dont see how its worse then |
00:40:46 | FromDiscord | <nikki> maybe it's to allow `case x of Y: foo` ? |
00:40:49 | FromDiscord | <krabbypatty> you're right, I had misread it |
00:41:05 | FromDiscord | <krabbypatty> I mean I don't like it but at least the docs do mention both |
00:41:32 | FromDiscord | <Rika> theres no language where you like every single feature it includes |
00:41:34 | FromDiscord | <krabbypatty> speaking of minor stylistic issues, styleCheck:error doesn't work |
00:41:39 | FromDiscord | <krabbypatty> I get errors from the stdlib |
00:41:42 | FromDiscord | <Rika> unless you make it yourself π |
00:41:46 | FromDiscord | <Rika> o? |
00:42:01 | FromDiscord | <nikki> even if you make it yourself, it's likely you don't haha bc. of tradeoffs and limits |
00:42:02 | FromDiscord | <Rika> can we have an example on what fails |
00:42:29 | FromDiscord | <krabbypatty> I'll file issues later |
00:42:31 | FromDiscord | <krabbypatty> nim-1.4.0/lib/std/private/underscored_calls.nim(42, 22) Error: 'nnkArgList' should be: 'nnkArglist' |
01:05:00 | FromDiscord | <krabbypatty> sent a code paste, see https://play.nim-lang.org/#ix=2Ecd |
01:05:32 | FromDiscord | <krabbypatty> this doesn't work because the different variants use the same name (e.g. both unary and binary use `operator`) |
01:05:52 | FromDiscord | <krabbypatty> is there any way to have duplicate names? |
01:06:06 | FromDiscord | <krabbypatty> (edit) "names?" => "names in variant fields?" |
01:07:18 | FromDiscord | <Joe-23> I wanted to create a lockscreen for linux for the wayland display server. I am having trouble figuring out where I should start, what to do, what libraries to use etc. |
01:10:26 | FromDiscord | <ElegantBeef> Do you know of any wayland lockscreens? |
01:12:37 | FromDiscord | <Joe-23> No mate |
01:13:03 | FromDiscord | <ElegantBeef> Well i can only suggest to look at lockscreen impls and use whatever libraries they use |
01:13:33 | FromDiscord | <Joe-23> Since a lot of applications and libraries are written in C, does NIm offer C interop? |
01:13:37 | FromDiscord | <ElegantBeef> Yes |
01:14:03 | FromDiscord | <ElegantBeef> Nim outputs C code, so it's interop is very very good |
01:15:05 | FromDiscord | <ElegantBeef> https://nim-lang.org/docs/manual.html#foreign-function-interface-importc-pragma |
01:19:52 | FromDiscord | <ElegantBeef> @nikki so disruptek responded to my for loop bug with "Feature.". So clearly we're just dumb π |
01:20:18 | FromDiscord | <nikki> huh? |
01:20:33 | FromDiscord | <nikki> i didn't question that it does that :p |
01:20:58 | FromDiscord | <ElegantBeef> That's not what i implied |
01:21:15 | FromDiscord | <nikki> o i didn't understand |
01:21:18 | FromDiscord | <nikki> what do u mean then π
|
01:21:31 | FromDiscord | <nikki> also what does feature mean in this case |
01:21:36 | FromDiscord | <nikki> just that -- being able to access the _ is a feature? |
01:21:46 | FromDiscord | <ElegantBeef> I think it's the "not a bug, it's a feature" joke |
01:22:05 | FromDiscord | <ElegantBeef> Or it's actually intended and like i said we're dumb π |
01:23:51 | FromDiscord | <nikki> i don't think so, seems like something that could go either way |
01:24:06 | FromDiscord | <nikki> one spot 'underscore' is mentioned in the compiler is 'underscored calls' or w/e |
01:24:15 | FromDiscord | <nikki> that gets used in the `with:` macro |
01:24:18 | FromDiscord | <nikki> wonder what that's about |
01:24:42 | FromDiscord | <ElegantBeef> Oh yea i think it's a bug due to being inconsistant, but i was just laughing at disrupteks 1 word response |
01:24:48 | FromDiscord | <nikki> hrhr |
01:24:50 | FromDiscord | <nikki> hehe |
01:25:05 | FromDiscord | <ElegantBeef> https://media.discordapp.net/attachments/371759389889003532/777343380879441921/unknown.png |
01:25:12 | FromDiscord | <ElegantBeef> Means it shouldnt be accessible |
01:25:25 | FromDiscord | <nikki> ah |
01:25:35 | FromDiscord | <ElegantBeef> But it's also magic so heh |
01:26:24 | FromDiscord | <Varriount> Hm, I've been busy lately... Anything new in nim-lang-land? |
01:29:08 | FromDiscord | <Joe-23> @ElegantBeef Awesome mate, just out of curiosity what about C++? |
01:29:13 | FromDiscord | <ElegantBeef> Same |
01:29:30 | FromDiscord | <Joe-23> I am surprised given how people struggle to get C++ interop to work |
01:29:42 | FromDiscord | <ElegantBeef> there is more explanation for the interop |
01:29:49 | FromDiscord | <Joe-23> Right |
01:29:57 | FromDiscord | <ElegantBeef> and there are tools like c2nim/nimterop to make it easier |
01:30:15 | FromDiscord | <ElegantBeef> But yea all cpp interop is explained here https://nim-lang.org/docs/manual.html#implementation-specific-pragmas-importcpp-pragma |
01:32:13 | FromDiscord | <Rika> @krabbypatty no |
01:32:22 | FromDiscord | <Rika> I don't know about plans to work on it either |
01:32:22 | FromDiscord | <ElegantBeef> It's in an RFC though |
01:33:40 | FromDiscord | <ElegantBeef> https://github.com/nim-lang/RFCs/issues/19#issuecomment-405520616 |
01:33:42 | disbot | β₯ Allow usage of the same attribute name in different branches within variant types |
01:33:48 | FromDiscord | <ElegantBeef> But yea just an RFC atm |
01:35:29 | FromDiscord | <Joe-23> @ElegantBeef Thanks mate |
01:45:13 | * | xet7 quit (Remote host closed the connection) |
01:48:47 | * | xet7 joined #nim |
01:53:52 | * | kinkinkijkin joined #nim |
01:54:25 | FromDiscord | <Joe-23> Just out of curiosity, does the user ever have to deal with lifetimes like in Rust, even if GC is disabled and the user uses something like smart pointers? |
01:55:00 | FromDiscord | <ElegantBeef> That's outside of my paygrade of non existant |
02:04:17 | FromDiscord | <nikki> i think you should be reasoning about the lifetimes (the general word) of objects in your code because that's just part of its functioning, but "lifetime parameters" (the rust-specific concept) don't show up in nim |
02:05:38 | FromDiscord | <Rika> lifetime parameters are probably what everyone else hates the most in rust and not lifetimes themselves |
02:06:11 | FromDiscord | <nikki> experimental:views is pretty related to this also: https://nim-lang.github.io/Nim/manual_experimental.html#view-types |
02:15:38 | * | apahl quit (Ping timeout: 264 seconds) |
02:17:32 | * | apahl joined #nim |
02:18:56 | * | blep58 joined #nim |
02:33:14 | * | blep58 quit (Remote host closed the connection) |
02:42:02 | FromGitter | <sealmove> @PMunch I tried your binaryparse lib. Wow! It's so awesome! |
02:44:24 | * | screens__ quit (Read error: Connection reset by peer) |
02:44:58 | * | screens_ joined #nim |
02:45:21 | voltist | Is anyone here lqdev (the developer of Rapid)? |
02:49:18 | FromGitter | <sealmove> I think adding more feature to binaryparse is more worth than trying to write a good Nim backend for Kaitai Struct yaml files. These files use an expression language which doesn't map well to Nim, and you can't easily mix it with more fine-grained Nim code (although KS has tons of features). Binaryparse is a lot more similar to python's Construct, and I am starting to think it's a better idea than "universal yaml |
02:49:18 | FromGitter | ... specs". The specs are easy to transpile anyway since the semantics are similar and everything is declarative. |
02:51:02 | FromDiscord | <nikki> voltist: @lqdev is lqdev |
02:51:08 | FromGitter | <sealmove> I'll finish the official KS backend (only half of the tests pass atm but there is already an official announcement https://kaitai.io/news/2020/10/16/kaitai-struct-v0.9-released.html), but nimitai is probably not worth it... |
02:53:56 | FromDiscord | <Joe-23> @Rika I meant lifetime parameters |
02:54:08 | FromDiscord | <Rika> > i think you should be reasoning about the lifetimes (the general word) of objects in your code because that's just part of its functioning, but "lifetime parameters" (the rust-specific concept) don't show up in nim |
03:02:06 | * | mmohammadi9812 quit (Ping timeout: 256 seconds) |
03:02:14 | * | mmohammadi9812 joined #nim |
03:09:30 | zedeus | hey disruptek |
03:09:54 | FromDiscord | <Joe-23> Yeah I know mate I just wanted to specify I should have been more specfic by saying _lifetime parameters_ rather than just _lifetime_ |
03:10:01 | FromDiscord | <Joe-23> But interestinng |
03:10:06 | FromDiscord | <Joe-23> glad Nim doesn't have this |
03:23:48 | * | a_chou joined #nim |
03:35:42 | FromDiscord | <Rebel> Are there any cases where converting from a string to a seq[byte] cause the length to go down? For example, if you have a string that has a length of 32 then convert to a seq[byte] the length suddenly goes down.... |
03:44:03 | FromDiscord | <ElegantBeef> Uhh, probably not |
03:44:32 | * | muffindrake quit (Ping timeout: 260 seconds) |
03:44:58 | FromDiscord | <ElegantBeef> https://play.nim-lang.org/#ix=2EcD |
03:46:45 | * | muffindrake joined #nim |
03:47:02 | FromDiscord | <nikki> @Rebel what kind of 'convert' do you mean? (eg. beef's code does a cast) |
04:06:02 | * | supakeen quit (Quit: WeeChat 2.9) |
04:06:27 | FromDiscord | <Rebel> https://play.nim-lang.org/#ix=2EcJ |
04:06:35 | * | supakeen joined #nim |
04:07:58 | FromDiscord | <nikki> unsafe ptr casts are not really meaningful conversions in many cases. like it just reinterprets the underlying memory of one type as another type, but each type tends to have its own (different) way of interpreting memory |
04:09:07 | FromDiscord | <nikki> the type system is trying to make memory associated with some type only generally interpreted as that type, but unsafe ptr casts are one way to say "no, type system, let me just do this (but i could get garbage results)" |
04:10:40 | * | a_chou quit (Ping timeout: 272 seconds) |
04:13:39 | FromDiscord | <Rebel> Ahhh ok that makes sense |
04:16:15 | * | apahl quit (Ping timeout: 272 seconds) |
04:17:01 | FromDiscord | <nikki> when you call an actual proc to do a conversion, like `something.toADifferentType` the `toADifferentType` proc contains logic that is reading the memory from the source and making a new object for the destination and writing to the destination memory with the correct layout |
04:17:05 | * | apahl joined #nim |
04:26:53 | FromDiscord | <Rebel> Yeah I realized that was not my problem, was passing params in the wrong order π€¦ββοΈ |
04:27:01 | FromDiscord | <Rebel> especially matters when doing cryptography..... |
04:28:52 | * | a_chou joined #nim |
04:29:50 | * | vicfred joined #nim |
04:39:40 | * | mmohammadi9812 quit (Quit: Quit) |
04:52:47 | * | waleee-cl quit (Quit: Connection closed for inactivity) |
04:53:03 | FromDiscord | <ThothLoki> so i just installed nim on fedora but i cant use the `nim` command to compile. anyone what what i could have done wrong? |
04:54:16 | FromDiscord | <ThothLoki> `sudo dnf install nim` is what i used |
04:59:10 | * | a_chou quit (Ping timeout: 256 seconds) |
05:07:13 | FromDiscord | <ThothLoki> nevermind. figured it out |
05:08:00 | FromDiscord | <ElegantBeef> @ThothLoki i highy suggest using choosenim instead of the package your distro ships |
05:08:50 | FromDiscord | <Rika> tell that to the nixos users |
05:09:05 | FromDiscord | <Rika> you bet they gonna whoop your ass |
05:09:05 | FromDiscord | <ElegantBeef> Hey all two of you, use choosenim |
05:09:11 | FromDiscord | <Rika> lmaoooo |
05:09:40 | FromDiscord | <ElegantBeef> Really choosenim should be shipped instead of nim π |
05:10:03 | FromDiscord | <ThothLoki> @ElegantBeef thats what i did |
05:10:27 | FromDiscord | <ElegantBeef> You said you installed through dnf |
05:10:37 | FromDiscord | <ThothLoki> then i said i got it figured out |
05:10:45 | FromDiscord | <ThothLoki> i installed it again with choosenim |
05:10:55 | FromDiscord | <ElegantBeef> Well i didnt know what figured it out meant, so sorry |
05:17:25 | FromDiscord | <ThothLoki> I take it there is not much Linux support for nim? |
05:18:02 | FromDiscord | <Rika> theres a good amount |
05:18:07 | FromDiscord | <Rika> why? |
05:18:23 | FromDiscord | <Rika> there isnt much support for package managers if thats what you mean |
05:18:27 | FromDiscord | <ElegantBeef> Linux is where most nim programmers are |
05:18:58 | FromDiscord | <ElegantBeef> Atleast that are active here |
05:19:15 | FromDiscord | <ThothLoki> Ok |
05:35:26 | FromDiscord | <nikki> @ThothLoki curious what made you think there wouldn't be much linux support π€ |
05:37:30 | FromDiscord | <nikki> funnily enough among the nim stuff i tried, the only platform-specific issue i had was having nimlsp integrate with gvim well on windows. that worked great on linux and macos. everything else worked everywhere |
05:38:55 | FromDiscord | <ThothLoki> Just the way rika and beef were talking about it |
05:55:36 | FromDiscord | <ElegantBeef> I mean i suggested choosenim and rika made a joke about nixos user |
05:55:37 | FromDiscord | <ElegantBeef> (edit) "user" => "users" |
05:55:48 | FromDiscord | <ElegantBeef> But eitherway it's a non issue |
06:01:26 | jonjitsu[m] | what version nim was ! removed? |
06:02:03 | FromDiscord | <ElegantBeef> do you mean `!=` or `!(bool)`? |
06:02:17 | FromDiscord | <ElegantBeef> Cause the latter isnt usable even in 0.13.0 |
06:02:30 | FromDiscord | <ElegantBeef> `not bool` is the way |
06:05:01 | FromDiscord | <ElegantBeef> Do remember that it takes 3 seconds to make that operator if it really is something you want |
06:05:13 | jonjitsu[m] | https://github.com/Udiknedormin/NimContracts/blob/master/contracts/declarations/keywords.nim#L61 |
06:05:40 | jonjitsu[m] | I tried using that library and got an undeclared identifier 1 |
06:05:44 | jonjitsu[m] | * I tried using that library and got an undeclared identifier ! |
06:07:30 | FromDiscord | <ElegantBeef> The only `!` in the stdlib is for the `pegs` module |
06:08:26 | jonjitsu[m] | so `not bool` always worked? |
06:08:38 | FromDiscord | <ElegantBeef> Well that's not operating on a bool |
06:09:25 | FromDiscord | <ElegantBeef> That proc is attempting to return a NimIdent which is deprecated |
06:10:12 | FromDiscord | <ElegantBeef> The nim node it was written was 17.2 so go back there and see what happens |
06:10:23 | FromDiscord | <ElegantBeef> (edit) "node" => "version" |
06:10:55 | jonjitsu[m] | I see, thx |
06:11:09 | jonjitsu[m] | Is there a quickcheck like library out there for nim? |
06:12:06 | FromDiscord | <ElegantBeef> What's quickcheck |
06:15:12 | FromDiscord | <nikki> it's a generative testing lib for haskell |
06:15:24 | FromDiscord | <nikki> but i think they're asking about generative testing, generally, for nim |
06:15:34 | jonjitsu[m] | property based checking like: https://hypothesis.readthedocs.io/en/latest/quickstart.html |
06:15:59 | jonjitsu[m] | nikki, that's right |
06:16:29 | FromDiscord | <nikki> jonjitsu: i think that'd be pretty cool if you end up trying your hand at it |
06:16:44 | FromDiscord | <nikki> the ingredients are there: you can introspect types, at compile time even, so you can generate some pretty good generator functions |
06:19:01 | * | bung joined #nim |
06:20:48 | jonjitsu[m] | ya nim's type system seems like a much better fit for that type of testing then python |
06:21:04 | bung | https://github.com/nim-lang/Nim/blob/1978b9120250f69df20a5bbb2cb11e73cd3eae5a/nimsuggest/nimsuggest.nim#L739-L743 |
06:22:26 | bung | why conf.writelnHook assign twice ? also does it needed controll here, it may controled when initNimsuggest |
06:24:30 | * | a_chou joined #nim |
06:25:17 | FromDiscord | <nikki> jonjitsu: yeah. one thing i'm super interested in is if someone makes a trie-like branching switch case for parsing strings |
06:25:48 | FromDiscord | <nikki> so like if you give a set { "abcd", "abef" } it generates a switch-case to branch at the first a and at b and then for the next one cases for c and e |
06:27:26 | FromDiscord | <nikki> essentially generating something like https://github.com/munificent/craftinginterpreters/blob/5459f9580d0065b59fba68ac3dd3555c1b326ba0/c/scanner.c#L134-L173 out of just the list of identifiers at compile time |
06:28:26 | FromDiscord | <nikki> you could imagine generating that for each set of fields in a struct when generating json parsers |
06:31:19 | bung | that need string are all known |
06:32:16 | FromDiscord | <nikki> such as in the struct field scenario mentioned? |
06:33:30 | bung | for identifiers that's fine, for json , I think no |
06:33:51 | FromDiscord | <nikki> if your structs describe a json schema, it makes sense |
06:33:56 | disruptek | zedeus: sup. |
06:34:06 | disruptek | beef: _ being a valid identifier is a feature. |
06:34:27 | FromDiscord | <ElegantBeef> It only is valid to reference inside a for loop |
06:34:40 | FromDiscord | <ElegantBeef> !eval let _ = 100; echo _ |
06:34:43 | NimBot | Compile failed: /usercode/in.nim(1, 19) Error: undeclared identifier: '_' |
06:35:25 | FromDiscord | <ElegantBeef> !eval for _ in ["a"]: echo _ |
06:35:26 | disruptek | !eval let (a, _) = (1, 2); echo a |
06:35:29 | NimBot | a |
06:35:29 | NimBot | 1 |
06:35:31 | FromDiscord | <nikki> bung: the idea is to take the compile-time known struct fields, and generate a json parser specifically for that struct |
06:35:41 | FromDiscord | <nikki> eg. with macros |
06:35:57 | FromDiscord | <ElegantBeef> I know it's supposed to be usable, but inside a for loop it doesnt have the same behaviour |
06:36:33 | FromDiscord | <nikki> disruptek: they're not talking about it being a valid identifier or not, just whether it actually can be reused once defined to refer to the same symbol |
06:36:58 | * | solitudesf joined #nim |
06:36:59 | FromDiscord | <ElegantBeef> Everywhere else it's a "discard value" except in a `for _ in iterator` |
06:37:07 | bung | if only specifical to that struct that's fine |
06:37:09 | FromDiscord | <nikki> like `let (a, _) = (1, 2); echo _` doesn't work; but `for _ in ...: echo _` does, even though `for _, _ in ...; echo _` doesn't |
06:37:58 | FromDiscord | <nikki> bung: yes. that's ... the idea |
06:38:08 | FromDiscord | <ElegantBeef> In the `for _, _ in iterator` you'd sorta expect it to say "identifier already declared" |
06:38:19 | FromDiscord | <ElegantBeef> Considering the `for _ in iterator` working |
06:38:30 | FromDiscord | <nikki> it does that only in multiple parameters for a proc i think (identifier already decl'd) |
06:38:31 | * | a_chou quit (Quit: a_chou) |
06:38:52 | FromDiscord | <nikki> !eval proc foo (_, _: int) = discard |
06:38:54 | NimBot | Compile failed: /usercode/in.nim(1, 14) Error: attempt to redefine: '_' |
06:39:15 | FromDiscord | <nikki> i promise i had underscores, even though discord won't let you see them |
06:39:24 | FromDiscord | <ElegantBeef> Is this inconsistancy a feature of Nim? |
06:39:46 | FromDiscord | <nikki> it keeps you on your toes |
06:39:56 | FromDiscord | <ElegantBeef> Thought that's what we had C for π |
06:40:17 | FromDiscord | <nikki> only if you actually write some ;p |
06:40:24 | FromDiscord | <ElegantBeef> Acceptable response |
06:42:59 | planetis[m] | hey check "new" macro dsl https://github.com/nim-lang/fusion/pull/40 |
06:43:00 | disbot | β₯ Added macro dsl based on karaxdsl |
06:46:09 | FromDiscord | <ElegantBeef> What's it for? |
06:46:35 | disruptek | put it in a lib, see if it's used, if it is, campaign for inclusion in fusion. |
06:47:04 | planetis[m] | ok will do |
06:47:06 | FromDiscord | <ElegantBeef> Yea join the party that shills their DSL when a topic is brought up |
06:47:35 | planetis[m] | i started trying to fix breeze then just copied karaxdsl and started over |
06:47:47 | planetis[m] | it's used to construct ast trees |
06:48:01 | planetis[m] | lol true |
06:48:34 | planetis[m] | i was already a member π lol |
06:48:37 | FromDiscord | <nikki> is it nicer than just `quote do`-ing all the time |
06:50:25 | FromDiscord | <ElegantBeef> Always nice to see actual use cases for sugar |
06:50:48 | planetis[m] | i don't use quote do, i used to write helper templates and getAst but i think that's better than both |
06:51:12 | disruptek | quote do is the wrong way. |
06:51:30 | disruptek | zevv: return in expr is a good way to break rewrite assumptions. |
06:51:35 | FromDiscord | <ElegantBeef> Psh i use a mix of both and live happily |
06:51:41 | disruptek | for now. |
06:51:50 | FromDiscord | <nikki> i haven't had to do anything suuuper weird yet |
06:52:10 | FromDiscord | <nikki> only this https://github.com/nikki93/ng-public/blob/e1606f2734eb587b179e8c4bec19f2af2289d6a9/src/engine/uis.nim#L68-L138 |
06:55:21 | planetis[m] | seems doable |
06:55:59 | FromDiscord | <Joe-23> Is there a library that mimics the Processing library so I can do computer graphics? |
06:56:21 | FromDiscord | <ElegantBeef> You could use nico similarly |
06:56:46 | FromDiscord | <nikki> there's nothing that mimic's processing's api directly, but yeah i'd say nico has similar levels of abstraction. you can also do graphics with aglet or raw opengl or bgfx or ... |
06:56:51 | FromDiscord | <ElegantBeef> It wouldnt support 3D, but it supports basics 2D shapes |
06:57:00 | FromDiscord | <ElegantBeef> Depends on what you're aiming for |
06:57:06 | FromDiscord | <Joe-23> @nikki I see |
06:57:11 | FromDiscord | <ElegantBeef> But yea planetis i wanna see some examples |
06:57:13 | FromDiscord | <Joe-23> I am aiming for 2D only |
06:57:32 | FromDiscord | <Joe-23> Is this for NIm by the way? |
06:57:38 | FromDiscord | <ElegantBeef> !repo nim |
06:57:40 | disbot | https://github.com/nim-lang/Nim -- 9Nim: 11Nim is a statically typed compiled systems programming language. It combines successful concepts from mature languages like Python, Ada and Modula. Its design focuses on efficiency, expressiveness, and elegance (in that order of priority). 15 10284β 1097π΄ 7& 29 more... |
06:57:42 | FromDiscord | <ElegantBeef> Lol |
06:57:45 | FromDiscord | <ElegantBeef> I'm dumb |
06:57:47 | FromDiscord | <ElegantBeef> !repo nico |
06:57:49 | disbot | https://github.com/ftsf/nico -- 9nico: 11Nim Game Framework based on Pico-8 15 217β 14π΄ 7& 6 more... |
06:57:49 | FromDiscord | <ElegantBeef> That's what i wanted |
06:57:59 | * | habamax joined #nim |
06:58:22 | FromDiscord | <nikki> i've been wrapping sdl + sdl-gpu -- just only giving myself the functionality that i need for a particular project i'm building https://github.com/nikki93/ng-public/blob/public/src/engine/graphics.nim |
06:59:00 | FromDiscord | <ElegantBeef> The suggestion on what to use highly depends on what you mean by "computer graphics" |
06:59:04 | FromDiscord | <Joe-23> Thanks guys |
06:59:20 | FromDiscord | <nikki> you could also output postscript |
06:59:21 | FromDiscord | <nikki> or svg |
06:59:22 | FromDiscord | <nikki> as text |
06:59:25 | FromDiscord | <nikki> π |
07:00:33 | FromDiscord | <Joe-23> Oh nice mate |
07:00:34 | FromDiscord | <Joe-23> π |
07:01:36 | FromDiscord | <ElegantBeef> Planetis do you have any examples of your dsl in use? |
07:06:04 | planetis[m] | the code in whenIsMainModule |
07:07:20 | planetis[m] | basically everything inside buildMacro is interpreted as returning nimnode but there is an escape hatch, append your statement with ! |
07:07:25 | planetis[m] | similar to karax |
07:08:09 | FromDiscord | <ElegantBeef> I see |
07:08:11 | planetis[m] | no need to do that for some common procs like echo, expeckKind, etc |
07:08:30 | planetis[m] | i will rewrite docs |
07:24:13 | * | narimiran joined #nim |
07:40:40 | planetis[m] | s/append/prefix |
07:41:31 | FromDiscord | <Joe-23> Does nim have `struct`s and `impl`s? |
07:46:34 | * | letto quit (Quit: Konversation terminated!) |
07:48:13 | FromDiscord | <nikki> it has documentation |
07:49:23 | * | letto joined #nim |
07:51:06 | FromDiscord | <nikki> https://nim-by-example.github.io/types/objects/ |
07:51:26 | FromDiscord | <nikki> here's some good examples of objects and procs taking objects a first param |
08:43:52 | * | cyraxjoe quit (Quit: No Ping reply in 180 seconds.) |
08:45:21 | * | cyraxjoe joined #nim |
08:48:16 | FromDiscord | <Joe-23> I see so `type` is like `struct` |
08:48:20 | FromDiscord | <Joe-23> what about `impl`s? |
08:55:16 | * | neceve joined #nim |
09:00:06 | * | nikki93[m] quit (Quit: Idle for 30+ days) |
09:30:29 | * | NimBot joined #nim |
10:21:58 | * | bung quit (Quit: Lost terminal) |
10:32:20 | * | hnOsmium0001 quit (Quit: Connection closed for inactivity) |
10:32:35 | FromDiscord | <lqdev> `impl` isn't a thing in nim |
10:33:00 | FromDiscord | <lqdev> all you need to do is declare procedures with your object as the first parameter |
10:33:18 | FromDiscord | <lqdev> and then you can use method call syntax like `myObj.myProc()` |
10:39:53 | FromDiscord | <Joe-23> Sorry mate how would this look like? |
10:47:03 | FromDiscord | <Recruit_main707> https://play.nim-lang.org/#ix=2Eem |
10:50:38 | FromDiscord | <Joe-23> I see thanks |
11:03:05 | FromDiscord | <lqdev> nim's a bit more freeform than rust in that regard :) |
11:09:37 | * | tane joined #nim |
11:26:03 | FromDiscord | <flywind> Why recent commit messages are not squashed? |
11:26:31 | FromDiscord | <flywind> (edit) "Why ... recent" added "some" |
11:26:36 | FromDiscord | <flywind> https://media.discordapp.net/attachments/371759389889003532/777494756133437440/unknown.png |
11:30:20 | FromDiscord | <Clyybber> @flywind by accident I think |
11:30:43 | FromDiscord | <flywind> this happens twice |
11:30:48 | FromDiscord | <flywind> https://github.com/nim-lang/Nim/pull/15968 |
11:30:49 | disbot | β₯ Documentation only |
11:31:09 | FromDiscord | <flywind> I don't know whether this is intended. |
11:31:22 | narimiran | probably 4raq switched computers and didn't change the default behaviour there |
11:35:44 | FromDiscord | <flywind> If so, we should stop that |
12:06:02 | * | supakeen quit (Quit: WeeChat 2.9) |
12:06:35 | * | supakeen joined #nim |
12:09:05 | * | narimiran quit (Ping timeout: 240 seconds) |
12:17:39 | * | sschwarzer joined #nim |
12:17:44 | sschwarzer | Hi :) |
12:18:38 | FromDiscord | <ache of head> π |
12:19:07 | sschwarzer | Is there a way to construct an array from another array, something like https://play.nim-lang.org/#ix=2Ef0 ? |
12:19:36 | * | lritter joined #nim |
12:19:43 | sschwarzer | I tried different variations, also didn't find anything in the docs. |
12:29:15 | FromDiscord | <Rika> sschwarzer nothing in the stdlib afaik, but i made the proc for you https://play.nim-lang.org/#ix=2Ef6 |
12:30:44 | sschwarzer | Rika: wow, thanks :-) |
12:30:54 | FromDiscord | <Recruit_main707> i would suggest using join or add since & is used for references and addresses |
12:31:32 | FromDiscord | <lqdev> since when |
12:31:44 | FromDiscord | <lqdev> sir this is nim not c++ |
12:32:15 | FromDiscord | <Recruit_main707> pretty sure there was something |
12:33:15 | FromDiscord | <lqdev> there wasn't anything |
12:33:35 | FromDiscord | <lqdev> that would use `&` for references |
12:33:46 | FromDiscord | <Rika> uh |
12:33:47 | FromDiscord | <Rika> what |
12:33:54 | FromDiscord | <Rika> are you sure you're not thinking of rust or c++ |
12:34:08 | sschwarzer | Recruit: Also, I can't find anything about `join` or `add` working on arrays (`add` wouldn't make sense as arrays are supposed to be fixed-length) |
12:34:11 | FromDiscord | <Recruit_main707> i was convinced it was in nim too |
12:34:18 | FromDiscord | <lqdev> it wasn't lol |
12:34:32 | FromDiscord | <lqdev> ~~wake up, mr. freeman~~ |
12:36:46 | FromDiscord | <ache of head> Wake up and smell the coffee, Mrs Bueller. |
12:38:11 | sschwarzer | I'll probably go for using sequences for simplicity then. Currently, I'm iterating over array elements, but in one loop the array has one element more than the other array. |
12:38:21 | sschwarzer | Rika: still nice to know the approach :) |
12:44:08 | * | sschwarzer quit (Quit: leaving) |
12:56:32 | * | MyMind quit (Ping timeout: 256 seconds) |
13:10:16 | * | MyMind joined #nim |
13:43:03 | * | PMunch joined #nim |
13:54:42 | * | xet7 quit (Quit: Leaving) |
14:07:53 | zedeus | disruptek: your submodule remotes for grok in frosty and json require a github account to clone, which breaks nitter's build |
14:07:58 | zedeus | also frosty 0.4.0 causes OOM |
14:09:00 | zedeus | I'm not sure why or how, but running nitter's test suite with frosty 0.4.0 makes it go "oh no, i'm out of memory" which is unfortunate |
14:11:36 | FromDiscord | <Mv.Quantum> hello |
14:12:02 | FromDiscord | <Mv.Quantum> (edit) "hello ... " added "@everyone" |
14:12:23 | * | natrys joined #nim |
14:23:21 | * | waleee-cl joined #nim |
14:23:57 | FromDiscord | <lqdev> nice try |
14:49:36 | FromDiscord | <krisppurg> @everyone I've been getting `An invalid argument was supplied.` whenever I do `await udp.connect(ip, Port(port))` |
14:49:45 | FromDiscord | <krisppurg> (edit) removed "@everyone" |
14:52:13 | PMunch | krisppurg, any more than just that? |
14:53:06 | FromDiscord | <krisppurg> hm not much really |
14:53:27 | FromDiscord | <krisppurg> I'm trying to send a udp message |
14:54:07 | PMunch | Wait, isn't UDP connectionless? |
14:54:16 | FromDiscord | <krisppurg> I am aware |
14:54:34 | FromDiscord | <krisppurg> but `asyncnet` doesn't have `sendTo` |
14:54:37 | PMunch | So why do you call connect on it then? |
14:55:31 | PMunch | And asyncnet does have sendTo: https://nim-lang.org/docs/asyncnet.html#sendTo%2CAsyncSocket%2Cstring%2CPort%2Cstring |
14:55:37 | FromDiscord | <krisppurg> wait |
14:55:48 | FromDiscord | <krisppurg> I mean below v1.4.0 |
14:55:53 | FromDiscord | <krisppurg> im using v1.2.0 personally |
14:56:53 | FromDiscord | <krisppurg> dial establishes connection |
14:57:05 | FromDiscord | <krisppurg> I was either guessing if connect would work |
14:57:21 | FromDiscord | <krisppurg> @PMunch |
14:57:30 | FromDiscord | <krisppurg> sad |
14:59:28 | PMunch | Why don't you upgrade to 1.4? |
14:59:53 | FromDiscord | <krisppurg> I want to make dimscord flexible with nim versions |
15:01:37 | FromDiscord | <krisppurg> the only reason why v1.2.0 is required is because of async event handlers, if it was optional and version is below v1.2.0 the event handlers probably wouldn't be much asynchronous. |
15:08:25 | FromDiscord | <krisppurg> @392962235737047041> ? |
15:08:30 | FromDiscord | <krisppurg> bruh |
15:14:16 | * | bung joined #nim |
15:19:47 | bung | am not sure if this is necessary ,https://play.nim-lang.org/#ix=2Egc please give me sugestion |
15:25:01 | FromDiscord | <krabbypatty> sent a code paste, see https://play.nim-lang.org/#ix=2Ege |
15:25:03 | FromDiscord | <krabbypatty> what is the correct way to write this closure? |
15:25:15 | FromDiscord | <krabbypatty> I'm getting "anon1" twice |
15:29:57 | FromDiscord | <krabbypatty> I realizs that I can use .global. here instead of a closure, I'm just curious why this isn't working |
15:30:18 | bung | change your const |
15:30:43 | Zevv | too late. he cant. it's a cost. no way of ever ever changing it. |
15:30:50 | bung | to let,var |
15:32:22 | FromDiscord | <krabbypatty> ah that works, thanks |
15:32:38 | Zevv | joking aside, it's a good question. Because _why_ doesn't it work with const |
15:32:38 | FromDiscord | <krabbypatty> also, is there a way to use `std/sugar`'s => with multiline procs? |
15:32:41 | Zevv | but also doesn't break |
15:32:49 | bung | it's like vm compile time compute result to a constant string |
15:33:24 | FromDiscord | <krabbypatty> I thought it would compute at compile time to the returned proc |
15:33:37 | FromDiscord | <krabbypatty> but not the returned proc's _body_ |
15:34:23 | bung | that's like js behavior |
15:35:07 | FromDiscord | <krabbypatty> what do you mean? |
15:35:37 | bung | in js you can declare a function as const |
15:36:18 | FromDiscord | <krabbypatty> right, JS's const is more like let in nim |
15:36:34 | FromDiscord | <krabbypatty> I mean, somewhat similar π let has more guarantees |
15:36:53 | FromDiscord | <krabbypatty> the code snippet is still weird to me |
15:38:40 | bung | think it oppsite of js behavior |
15:38:46 | FromDiscord | <krabbypatty> the manual says: "Constant expressions are restricted to depend only on the following categories of values and operations [...] |
15:38:53 | FromDiscord | <krabbypatty> - previously declared procedures that have no side effects beyond possibly modifying compile-time variables" |
15:38:59 | FromDiscord | <krabbypatty> doesn't my function violate this |
15:39:02 | FromDiscord | <krabbypatty> it's mutating i |
15:39:07 | FromDiscord | <krabbypatty> so it should be a compile-time error? |
15:40:12 | FromGitter | <ynfle> It's result is computed at compile time and all of the variable are local to the calculation |
15:41:16 | bung | am not sure if this is necessary ,https://play.nim-lang.org/#ix=2Egc please give me sugestion |
15:41:45 | FromDiscord | <krabbypatty> what do you mean local to the calculation |
15:41:53 | FromDiscord | <krabbypatty> shouldn't it only calculate at compile-time the _closure_ itself |
15:41:56 | FromDiscord | <krabbypatty> and not the calls to the closure |
15:43:09 | bung | come on , think it as static: would be simple |
15:44:53 | * | abm joined #nim |
15:46:04 | bung | where is yarndanico ? disapear for weeks |
15:51:09 | PMunch | Yeah haven't seen him in a while |
15:52:07 | Zevv | he was heer a few days ago |
15:52:30 | FromDiscord | <lqdev> when |
15:52:56 | PMunch | Can just do a search through the IRC logs |
15:53:15 | PMunch | ~last Yardanico |
15:53:15 | disbot | no footnotes for `last`. π |
15:53:25 | PMunch | Hmm, how was that again? |
15:53:26 | Zevv | !last Yardanico |
15:53:26 | disbot | Yardanico never seen. |
15:53:32 | PMunch | Ah |
15:53:36 | Zevv | that bot is fake |
15:53:42 | Zevv | irc/2020/11/12:05:43 #nim: < Yardanico> (pragmas for routine arguments) |
15:53:44 | FromGitter | <bung87> funny |
15:54:06 | FromDiscord | <lqdev> 10th of november is the last time he sent a message on discord |
15:54:33 | FromDiscord | <lqdev> but i'm definitely seeing him less frequently as of late |
15:55:31 | FromGitter | <bung87> I like to see him here |
15:55:52 | FromGitter | <ynfle> @krabbypatty I think you should file a bug report. Check this out https://play.nim-lang.org/#ix=2Egs β (cc @bung ) |
16:00:37 | FromGitter | <bung87> oh that's do same thing but dont work |
16:02:19 | FromGitter | <ynfle> That works to create a const closure |
16:09:08 | * | lritter quit (Quit: Leaving) |
16:12:54 | * | lritter joined #nim |
16:21:13 | disruptek | !last yardanico |
16:21:14 | disbot | Yardanico spoke in 12#nim-news 6 hours ago |
16:22:48 | disruptek | zedeus: gimme a test? i can fix the submodules. |
16:24:39 | disruptek | zedeus: jason and frosty have a new patch-level release w/o the submodule snafu. |
16:24:55 | zedeus | cool, I'll try to make a test in a bit |
16:25:24 | disruptek | the only real change in 0.4.0 is to remove the magic value. |
16:27:05 | zedeus | is that backwards compatible? |
16:27:16 | disruptek | not binary-wise, no. |
16:27:30 | disruptek | you want me to delete 0.4.0 and major it? |
16:27:43 | disruptek | does your test operate against existing redis cache? |
16:28:14 | zedeus | it does, but I'm not sure that's why it happens |
16:28:24 | zedeus | do you feel ready for the big 1.0 release? |
16:28:34 | disruptek | i don't care. |
16:29:08 | * | PMunch quit (Quit: leaving) |
16:29:29 | zedeus | is using 'sorta' always beneficial, or are there specific use cases where it helps a lot? |
16:29:48 | disruptek | it slows everything down right now because sorta is not as fast as it should be. |
16:30:03 | disruptek | ultimately, it will be beneficial in speed only, and only when you have a lot of pointers. |
16:30:15 | zedeus | ah, thanks |
16:30:26 | disruptek | how does the speed feel to you right now? |
16:30:37 | zedeus | negligible |
16:32:48 | disruptek | what does that mean? |
16:33:05 | Zevv | he feels negligible about speed |
16:33:07 | zedeus | fast enough that I don't care |
16:33:14 | disruptek | okay. |
16:33:31 | disruptek | zevv: you have a weird habit of adding spaces. what is that from? keyboard? |
16:34:09 | disruptek | i see it in your code, too. trailing spaces. everywhere. secret stego notes? |
16:34:36 | zedeus | with profiles/timelines loading in just ~240ms, compared to twitter's ~1.3s, it's really not a concern |
16:34:46 | Zevv | you see trailing spaces in my irc? |
16:34:57 | disruptek | !last Yardanico |
16:34:57 | disbot | Yardanico never seen. |
16:42:23 | FromDiscord | <krisppurg> just compiled my code and I seem to just get `out of memory`, solutions? |
16:55:17 | zedeus | download more ram |
16:56:56 | ForumUpdaterBot | New thread by Jackhftang: How do you deal with dependencies in Nim ? , see https://forum.nim-lang.org/t/7094 |
17:16:34 | * | narimiran joined #nim |
17:20:02 | disruptek | upload less data. |
17:20:41 | solitudesf | write different code |
17:21:03 | disruptek | riir |
17:21:08 | zedeus | retweet |
17:21:31 | disruptek | zedeus: how do i run the test suite? |
17:24:47 | zedeus | install a webdriver (chrome or firefox), install seleniumbase and pytest with pip, run redis-server and nitter, then run `pytest --headless -n 12` in the tests dir |
17:24:48 | disruptek | zedeus: are you serious with these damned 7-char hashes? |
17:24:58 | disruptek | i need to fucking support these in nimph now? |
17:25:00 | zedeus | yep |
17:25:34 | disruptek | nah. |
17:26:55 | planetis[m] | how to handle multiple evaluation bugs (when using templates/ macros) these days? |
17:27:14 | disruptek | fix bugs until only one bug exists. |
17:27:52 | disruptek | then fix that bug. |
17:28:02 | planetis[m] | i mean there is this: https://github.com/nim-lang/Nim/blob/devel/lib/pure/collections/sequtils.nim#L91 but it's not exported |
17:31:46 | FromDiscord | <Clyybber> planetis: Just assign to a temporary var |
17:33:52 | * | xet7 joined #nim |
17:42:12 | * | rockcavera joined #nim |
17:46:52 | planetis[m] | ok done |
18:05:05 | Oddmonger | is Β« x.int Β» sugar for Β« int(x) Β» ? |
18:05:15 | disruptek | yes. |
18:05:16 | planetis[m] | yes |
18:05:21 | Oddmonger | thanks |
18:06:56 | planetis[m] | there is a bug with generics that make x.T not work in some cases, btw |
18:08:25 | Zevv | that's not a bug |
18:08:27 | Zevv | it's by design |
18:08:33 | Zevv | https://nim-lang.github.io/Nim/manual.html#procedures-method-call-syntax bottom of the par |
18:10:38 | * | hnOsmium0001 joined #nim |
18:10:55 | planetis[m] | i don't think thats it, I encountered it with https://gist.github.com/planetis-m/c13529cac44b4a9de3f073de502315ee#file-fixed_point-nim-L67 replace R(x) with x.R |
18:12:58 | planetis[m] | man, i m still so happy with how the ast dsl turned out https://github.com/nim-lang/fusion/pull/40 |
18:13:00 | disbot | β₯ Added macro dsl based on karaxdsl ; snippet at 12https://play.nim-lang.org/#ix=2Ehm |
18:13:07 | planetis[m] | it makes macros so easy |
18:18:53 | FromDiscord | <NickSeagull> If I got a windows DLL and its corresponding `.h` file? What would be the best way to call it, by using `c2nim`? `nimterop`? Directly? |
18:26:35 | * | vicfred quit (Remote host closed the connection) |
18:27:03 | * | vicfred joined #nim |
18:28:09 | FromDiscord | <NickSeagull> (edit) If I got a windows DLL and its corresponding `.h` file, What would be the best way to call it, by using `c2nim`? `nimterop`? Directly? |
18:28:29 | FromDiscord | <NickSeagull> Been looking on the internet for some time already with no avail |
18:29:00 | FromDiscord | <lqdev> c2nim probably |
18:33:16 | FromDiscord | <Recruit_main707> both will do really, if one fails, try with the other one. |
19:06:31 | FromDiscord | <NickSeagull> Awesome thanks |
19:17:03 | zedeus | disruptek: since thawing stuff frozen with 0.3.1 gives garbled output, I dunno if it makes sense to reduce a test case that produces out of memory. the bottom line is it's not backwards compatible, so I'll just add a migration to nitter |
19:17:20 | * | neceve quit (Ping timeout: 256 seconds) |
19:17:36 | zedeus | the issue does not happen when running the tests with an empty redis |
19:20:47 | * | Jitty[m] quit (Ping timeout: 260 seconds) |
19:21:04 | * | Jitty[m] joined #nim |
19:22:00 | zedeus | the submodule issue is still present, you need to update jason in frosty |
20:11:04 | * | PMunch joined #nim |
20:17:40 | ForumUpdaterBot | New thread by Kobi: Is there a way to combine types?, see https://forum.nim-lang.org/t/7095 |
20:18:10 | * | lritter quit (Quit: Leaving) |
20:25:25 | * | habamax quit (Ping timeout: 240 seconds) |
20:34:01 | * | azed joined #nim |
20:34:35 | * | azed quit (Client Quit) |
20:45:26 | * | narimiran quit (Quit: leaving) |
20:53:10 | PMunch | Hmm, why doesn't this work? https://play.nim-lang.org/#ix=2Eib |
20:56:14 | * | natrys quit (Quit: natrys) |
20:57:44 | ForumUpdaterBot | New thread by Mildred: Which HTTP server library?, see https://forum.nim-lang.org/t/7096 |
21:01:31 | FromDiscord | <lqdev> PMunch: sadly, you can't use macros like that |
21:01:44 | FromDiscord | <lqdev> you'd have to make the macro output a type section |
21:03:05 | PMunch | Meh |
21:03:13 | PMunch | That's not pretty |
21:03:44 | FromDiscord | <lander> I replied in the forum: https://forum.nim-lang.org/t/7086, but I cannot see my messages posted unless I'm logged in. Does the account need some validation or is that a glitch? |
21:04:27 | * | junland quit (Quit: %ZNC Disconnected%) |
21:04:31 | FromGitter | <ynfle> https://play.nim-lang.org/#ix=2Ein @Pmunch |
21:05:01 | PMunch | @ynfle, I ended with something similar: https://forum.nim-lang.org/t/7095 |
21:06:07 | * | junland joined #nim |
21:06:45 | planetis[m] | that comment says they work https://github.com/nim-lang/Nim/issues/13830#issuecomment-609031271 |
21:06:46 | disbot | β₯ `macro pragmas` in type section should apply to `TypeSection`, not `TypeDef` ; snippet at 12https://play.nim-lang.org/#ix=2rOP |
21:07:24 | planetis[m] | you need to output a nnkStmtlistType |
21:09:03 | FromGitter | <ynfle> I prefer `quote do:` It's easier to see what's happening in macros |
21:11:01 | * | solitudesf quit (Ping timeout: 260 seconds) |
21:13:57 | PMunch | Ah nice, this works: https://play.nim-lang.org/#ix=2Eio |
21:14:49 | Prestige | pretty neat |
21:15:58 | * | opal quit (Remote host closed the connection) |
21:17:29 | * | opal joined #nim |
21:20:21 | Zoom[m] | How to get a pair of random non-equal ints the correct way? I rand A and then rand B in a while loop until B != A |
21:22:38 | FromDiscord | <lander> sent a code paste, see https://play.nim-lang.org/#ix=2Eir |
21:22:49 | FromDiscord | <lander> sent a code paste, see https://play.nim-lang.org/#ix= |
21:24:09 | PMunch | That is pretty much the only way to do it Zoom[m] |
21:25:17 | FromDiscord | <lander> (edit) doAssert not compiles:β΅ intEnumWithHoles:β΅ type Unordered = enum A, B, C = 12, E, D = 11, F |
21:25:39 | FromDiscord | <nikki> Zoom: correct |
21:26:15 | Zoom[m] | k, thanks |
21:27:36 | FromDiscord | <nikki> another approach is to imagine the integer cartesian plane. you basically want to ignore the x = y diagonal. you can imagine numbeing all of the points starting at 1, 0 and spiralling out from the center |
21:28:21 | FromDiscord | <lqdev> @lander https://play.nim-lang.org/#ix=2Eiu |
21:31:23 | Zoom[m] | nikki, right, I'll stick with a loop for a while :D |
21:33:31 | FromDiscord | <ElegantBeef> You could get a random number, then flip a coin to see if you want to sample higher/lower, then choose between the selected number and the high or low range |
21:33:45 | FromDiscord | <ElegantBeef> That way you dont need a while or for loop, and will get still pretty random numbers |
21:36:08 | FromDiscord | <lander> @lqdev, thank you! |
21:37:29 | PMunch | https://github.com/PMunch/notifishower |
21:37:47 | PMunch | Hooray, notifishower now has a proper icon and the latest version is now on GitHub |
21:38:02 | FromDiscord | <ElegantBeef> Grats |
21:38:13 | FromDiscord | <lqdev> @lander there also appears to be a simpler, although less pretty solution: https://play.nim-lang.org/#ix=2Eiw |
21:38:29 | PMunch | Now I just need to make some cool examples of it |
21:54:43 | FromGitter | <sealmove> hey PMunch |
21:56:07 | PMunch | Hi |
21:56:21 | PMunch | I saw your PR |
21:56:23 | PMunch | Looks good |
21:56:32 | PMunch | But I'm too tired right now to look it over properly |
21:56:50 | FromGitter | <sealmove> Np, I planned to extend binaryparser a lot but there is a big worry. |
21:57:21 | FromGitter | <sealmove> since syntax is "type: name" instead of "name: type", it seems impossible to make nested definitions |
21:58:30 | FromGitter | <sealmove> I guess if I want something much more versatile with nested defs, conditional fields and type-switching on expressions, I should make a new project and keep binaryparse small and neat? |
21:58:52 | FromDiscord | <ElegantBeef> @nikki ehhh https://github.com/nim-lang/Nim/issues/15972 |
21:58:54 | disbot | β₯ In for loop `_` is accessible ; snippet at 12https://play.nim-lang.org/#ix=2EiA |
21:59:31 | PMunch | Oh, that is all already possible |
21:59:59 | FromDiscord | <ElegantBeef> Zoom did you see my suggestion for your randomly choosing two numbers without a while loop? |
22:00:36 | PMunch | @sealmove, here is one I made to parse DNS messages: http://ix.io/2EiE |
22:01:27 | Zoom[m] | ElegantBeef, thanks, saw it. I somehow think there's no real benefit to this approach. |
22:01:40 | FromDiscord | <ElegantBeef> Well it removes the while loop π |
22:02:25 | Zoom[m] | But it adds branching for the coin toss |
22:04:11 | * | Quibono joined #nim |
22:04:20 | planetis[m] | thats a neat macro exelotl |
22:04:30 | FromDiscord | <nikki> @ElegantBeef can i see your approach |
22:04:46 | FromDiscord | <ElegantBeef> Scroll up a bit |
22:04:48 | Zoom[m] | If there's just rand(int) in a loop, it's not too bad and the code is simpler. If there were more logic involved, your solutions is of course preferable |
22:05:17 | FromDiscord | <ElegantBeef> Basically you flip a coin after picking the first number and then pick between high/low range and that number |
22:05:24 | planetis[m] | reminds me of what jblow was evangelizing about anonymous fields |
22:06:00 | FromDiscord | <nikki> yea that works too, but doesn't work for non ranged stuff i guess |
22:06:00 | FromGitter | <sealmove> @PMunch sure it's good that you can mix declarations with custom parsers (basically with plain Nim). I am talking about having the whole parser in declarative form. |
22:06:21 | FromDiscord | <nikki> altho u could choose random unsigned and add to the split? |
22:06:27 | FromGitter | <sealmove> Something like Python's Construct. |
22:06:32 | FromDiscord | <nikki> in any case integers on computers have ranges so its fine :p |
22:06:38 | PMunch | Problem is you will never get it to be 100% compatible with various formats |
22:06:45 | PMunch | That's why I added the custom parser syntax |
22:07:22 | PMunch | And it's how you compose different parsers into each other, and how you can do conditionals and such |
22:08:05 | PMunch | Notice how I in the DnsMessage parser call the Control, Question, and RR parsers |
22:09:17 | FromGitter | <sealmove> KS and Construct can encode/decode any format. But I see the benefit in keeping macros minimal and composing with plain Nim code. Maybe it's better dunno have to think about it. |
22:09:55 | PMunch | _any_ format? |
22:10:34 | FromGitter | <sealmove> yeah, they have enough features to handle anything (unlike serializers like protobuf) |
22:10:49 | PMunch | Hmm |
22:11:20 | PMunch | Well, I like binaryparse. It has a small enough syntax that you can actually know all of it. And for the edge cases you can always go back into Nim and write your own |
22:11:47 | FromGitter | <sealmove> Noted, I agree. |
22:11:50 | PMunch | And you can of course call a parser from within a custom parser to do e.g. conditionals |
22:11:54 | Zoom[m] | ElegantBeef, also, there's an edge case: If we get a Min or Max for B we can only go higher or lower. That's an additional check. |
22:13:22 | PMunch | I wrote it to parse some satellite data formats that where really weird, and I had just worked with pcap and PNG files before I wrote it. So I kept all those formats in mind and designed it to be able to read all of them. The recent DNS thing I did with it was super easy to implement and it just works perfectly |
22:13:48 | PMunch | By the way, I'd be interested in seeing how KS or Construct handles the DNS message compression algorithm |
22:13:58 | ForumUpdaterBot | New thread by Kobi: Out of memory, see https://forum.nim-lang.org/t/7097 |
22:14:47 | planetis[m] | hi sealmove checkout what i made https://github.com/nim-lang/fusion/pull/40 |
22:14:49 | disbot | β₯ Added macro dsl based on karaxdsl ; snippet at 12https://play.nim-lang.org/#ix=2Ehm |
22:14:53 | PMunch | But I'm heading off for bed now, good night |
22:14:54 | * | PMunch quit (Quit: leaving) |
22:15:25 | FromGitter | <sealmove> gn! |
22:16:22 | FromGitter | <sealmove> well for stuff like compression they allow using custom proc but only for "processing" a sequence of bytes |
22:16:52 | FromGitter | <sealmove> so I didn't consider this as part of the spec |
22:39:49 | Quibono | If there was any python library we could have in Nim, what would you want? |
22:41:32 | FromDiscord | <hobbledehoy> requests |
22:42:22 | planetis[m] | the one that orders pizzas |
22:42:39 | FromDiscord | <ElegantBeef> The inverse of `typing` π |
22:42:41 | planetis[m] | π |
22:43:05 | FromDiscord | <ElegantBeef> Purely joking, dont even attempt to implement that |
22:43:12 | FromDiscord | <Recruit_main707> we have something similar to request dont we? |
22:43:27 | FromDiscord | <ElegantBeef> httpclient? |
22:43:46 | FromDiscord | <ElegantBeef> Requests is just a http client |
22:44:04 | FromDiscord | <hobbledehoy> We have thatβ΅But it doesn't have session handling for cookies though |
22:47:51 | Zoom[m] | ElegantBeef, here's what I've got with your approach: https://play.nim-lang.org/#ix=2EiV |
22:48:58 | Zoom[m] | Isn't it too much? π |
22:49:25 | FromDiscord | <ElegantBeef> wait to make it look ugly π |
22:49:51 | * | Quibono quit (Remote host closed the connection) |
22:50:06 | Zoom[m] | BTW, so the ranges in standard library are always inclusive? |
22:50:12 | FromDiscord | <ElegantBeef> yes |
22:51:22 | Zoom[m] | <FromDiscord "<ElegantBeef> wait to make it lo"> what do you mean? I'm open for corrections, since I'm new to the language. |
22:52:41 | FromDiscord | <ElegantBeef> https://play.nim-lang.org/#ix=2EiY |
22:52:53 | Zoom[m] | IMO, inclusive ranges are weird for a language with so much indexing going on |
22:54:42 | FromDiscord | <nikki> how do you make a range that includes the min or max of the parent range by only using exclusive ranges? |
22:55:34 | Zoom[m] | `..=` instead of `..<` |
22:55:45 | Zoom[m] | That's just a preference, I suppose |
22:57:36 | Zoom[m] | ElegantBeef, probably better, but not much IMO, as your version has the repeating `rand(0..<a)` π |
22:57:50 | FromDiscord | <ElegantBeef> ok |
22:57:53 | FromDiscord | <ElegantBeef> here |
22:58:15 | FromDiscord | <ElegantBeef> https://play.nim-lang.org/#ix=2Ej2 |
23:00:12 | Zoom[m] | Yep, that's it. I almost wrote this but wanted to see the logic lined up first. |
23:00:54 | Zoom[m] | This is the way. |
23:01:00 | * | abm quit (Quit: Leaving) |
23:05:23 | * | Quibono joined #nim |
23:09:41 | Quibono | Lol, just want to contribute to the Nim ecosystem, porting a small library from python seems pretty doable. |
23:10:13 | Zoom[m] | Is using expressions like `result = if ...` discouraged for any reasons? |
23:10:54 | planetis[m] | no, no reasons against it |
23:11:26 | Zoom[m] | But is it discouraged? :) |
23:11:50 | planetis[m] | well it doesn't come up often, does it? |
23:12:27 | FromDiscord | <ElegantBeef> Expressions are not discouraged, just using them a lot like you did is unreadable imo |
23:12:55 | Quibono | Maybe case of would be more elegant? |
23:13:17 | planetis[m] | and you might come up with an elif case, then you will need to refactor it |
23:13:44 | planetis[m] | no scratch that |
23:14:29 | planetis[m] | let x = if cond: a elif cond2: b else: c work afaik |
23:14:55 | Quibono | But whhhhy |
23:14:57 | disruptek | zedeus: sorry about that. i will cut a version-1.0 once i'm done fucking with frosty for IC and then we'll have a major you can pin. i did fix submodules again for criterion. |
23:15:10 | disruptek | you can pin 0.4.2 for now. |
23:15:41 | disruptek | or just go back to the 0.3 branch for magics. |
23:15:50 | Quibono | planetis[m]: Why do you want to write it like that? |
23:16:09 | disruptek | zedeus: ^ |
23:17:16 | planetis[m] | i dont its just possible |
23:17:20 | Zoom[m] | ElegantBeef, yeah, in that case the readability really suffered. I think this is due to indentation, it's like you expect the right side of the assignment to be it's own block |
23:18:09 | Quibono | Okay I was worried there. |
23:18:54 | disruptek | Zoom[m]: rand A; if it's odd (or some other measure), B = rand(A+1 .. A.high). else: B = rand(A.low .. A-1) |
23:20:14 | Zoom[m] | disruptek, we've already ended up with something like this |
23:20:32 | disruptek | sorry, i was typing while in scrollback. π |
23:22:33 | disruptek | they won't be random, but you also won't have the loop. |
23:25:38 | Zoom[m] | https://play.nim-lang.org/#ix=2Ej7 |
23:25:40 | FromDiscord | <ElegantBeef> We just flipped a coin, the coin indicates the range to select |
23:26:55 | Zoom[m] | That probably screws up the distribution, depending on where in the range we end up with the first number. |
23:30:48 | Zoom[m] | The shorter the "half" the more favour its number get. |
23:31:03 | Zoom[m] | But I could be totally wrong, my math is that bad. |
23:31:31 | FromDiscord | <nikki> i think the distribution is correct |
23:32:35 | FromDiscord | <nikki> if the algo is: for two unique nums in a range (a, b) pick first num p, then flip a coin to decide whether to pick next num in (a, p) or (p, b) right? |
23:32:59 | FromDiscord | <ElegantBeef> Yea it should be, if it's 0-12 and you get 3. 0-2, and 4-12 should have equal opportunity to be choosen |
23:33:49 | FromDiscord | <nikki> another way to think abt this is |
23:33:51 | FromDiscord | <ElegantBeef> the only reasone it'd be unequal is if you constantly get `3` in the above example, since the bottom half would pop up more often |
23:33:52 | Zoom[m] | If max=9 and A = 1 we have 1:2 for getting 0 for B and 1:2 for getting 2..9 |
23:34:05 | FromDiscord | <ElegantBeef> yes but that's only for this one flip |
23:34:13 | FromDiscord | <ElegantBeef> Roll for another number, you get 2 |
23:34:34 | FromDiscord | <nikki> imagine all pairs of unequal numbers (p, q). sort them by q and then by p |
23:34:37 | Zoom[m] | Right, that's where I'm wrong |
23:35:09 | FromDiscord | <nikki> actually wait i think you shouldn't flip a coin |
23:35:16 | FromDiscord | <ElegantBeef> For a single sample it would appear your picking of an uneven split isnt equal, but over multiple numbers the uneven set should be equal |
23:35:30 | FromDiscord | <nikki> i think you need to decide with (p - a) / (b - a) chance to pick before p |
23:35:40 | Quibono | What is the thing you guys are trying to do? |
23:35:53 | FromDiscord | <ElegantBeef> I mean you can always test the distribution yourself |
23:36:06 | FromDiscord | <nikki> pick among all pairs of ints (p, q) where p not equal to q, uniformly |
23:36:12 | FromDiscord | <ElegantBeef> Run 0-10 a few hundered times and see what numbers pop up |
23:36:30 | Zoom[m] | Get a random pair of non equal numbers |
23:36:44 | disruptek | you're wrong because the fundamental assumption is wrong. |
23:36:47 | Zoom[m] | We need a one-liner for gnuplot |
23:37:09 | disruptek | a will be random among a range of X and b will be random among a range of X-1. |
23:37:26 | FromDiscord | <nikki> lolwut |
23:37:30 | disruptek | ergo, they are not equally random. |
23:37:34 | Quibono | Lol so random and it needs to be a one liner. |
23:38:06 | FromDiscord | <nikki> there's no assumption. there is a set of all pairs of p, q ints that are not equal. you want to pick among them uniformly |
23:38:13 | disruptek | yes. |
23:38:29 | disruptek | use miran's itertools to generate permutations. |
23:38:33 | FromDiscord | <nikki> one way is to pick p and rejection sample q (reject when equal to p) |
23:39:03 | disruptek | another way is to use a loop. |
23:39:06 | FromDiscord | <nikki> another suggested approach to pick p, flip to decide whether to pick higher or lower, then pick accordingly. we're evaluating if that works |
23:39:06 | Zoom[m] | Quibono: I meant a one-liner to feed the results of the tests to get a histogram |
23:39:21 | FromDiscord | <nikki> rejection sampling involves a loop |
23:39:33 | FromDiscord | <nikki> but you can use a loop in other approaches too, yes |
23:39:35 | disruptek | the coin flip way works but it's not correct. |
23:39:38 | * | tane quit (Quit: Leaving) |
23:40:19 | disruptek | but the whole concept is broken. |
23:41:11 | Quibono | Why not just do this? https://play.nim-lang.org/#ix=2Ejf |
23:41:17 | FromDiscord | <nikki> that's what one thinks immediately. but if you think about it more, it seems like maybe it works |
23:41:26 | FromDiscord | <nikki> so then you need a proof |
23:41:28 | FromDiscord | <nikki> not confidence |
23:41:37 | Zoom[m] | I recon, we need to regenerate both of the numbers until we get a pair, not just the second one. |
23:41:47 | Zoom[m] | If we go with the loop approach |
23:41:55 | FromDiscord | <nikki> nah zoom first then loop on second works |
23:42:14 | FromDiscord | <nikki> you select among all pairs involving first p uniformly, which is right |
23:42:16 | disruptek | pick a random index from the array. rotate the array randomly, less than N. now use the same index. you have two random numbers that are not equal if the array holds distinct values. |
23:42:21 | Quibono | Why do you need to regenerate both? |
23:42:50 | disruptek | and you can do it with one line. |
23:42:52 | Zoom[m] | Quibono, that's what we started from! I asked if it's the correct way and here we go |
23:43:02 | FromDiscord | <nikki> it's a correct way |
23:43:12 | FromDiscord | <nikki> it's only the correct way if all other approaches are provably wrong |
23:43:23 | disruptek | nah. |
23:43:44 | Quibono | Lol but the first variable is still random, and because the second number can't equal var1, why would you regen it? |
23:44:00 | zedeus | disruptek: you need to update the jason module in frosty, it still points to a hash with git+ssh |
23:44:03 | Zoom[m] | To be sure :D |
23:44:10 | disruptek | zedeus: i looked at it and didn't see it. |
23:44:12 | FromDiscord | <ElegantBeef> Yep it's not actually random |
23:44:22 | FromDiscord | <ElegantBeef> https://play.nim-lang.org/#ix=2Ejg |
23:44:28 | FromDiscord | <ElegantBeef> Distribution is off |
23:44:32 | disruptek | zedeus: i'm looking at it now and don't see it. |
23:44:46 | FromDiscord | <ElegantBeef> (9, 10) consistantly gets around 4500 |
23:45:01 | FromDiscord | <lander> @PMunch, after looking at your Scancodes mapping forum response and learning about enum with holes I've sketched this macro that I think it could add good value to the C enums that are properly enums with holes, i.e. densely packed and not the other cases described as enum maps |
23:45:06 | FromDiscord | <lander> https://github.com/nim-lang/Nim/pull/15983 |
23:45:07 | disbot | β₯ Utility macro to fill holes in enums with synthetic values |
23:45:08 | disruptek | zedeus: 0.3.1 is fixed; is it not pushed? |
23:45:20 | FromDiscord | <nikki> @ElegantBeef well the primitive rand ur using may not be uniform itself |
23:45:34 | zedeus | disruptek: the jason submodule in frosty is pinned at 1842883, which is "update benchmarks", the next commit in jason is "submodule fix" |
23:45:41 | FromDiscord | <nikki> the only issue can be if it biases toward the middle or sth |
23:45:45 | disruptek | oh shit. |
23:46:00 | Quibono | https://play.nim-lang.org/#ix=2Ejh Okay so wouldn't this be the shortest way to do it? |
23:46:13 | disruptek | zedeus: who pinned it? |
23:46:35 | zedeus | dunno, you probably |
23:46:36 | FromDiscord | <lander> I expect controversy for stirring the holed enum pot but let's see what you think. |
23:47:38 | disruptek | zedeus: well, it's not pinned for me. |
23:47:52 | disruptek | zedeus: get a real package manager and stop pinning everything. |
23:48:08 | zedeus | it's pinned according to github's web interface, I dunno how that works |
23:48:22 | disruptek | clearly. |
23:48:45 | disruptek | look at the .gitmodules file in the repo. |
23:48:49 | zedeus | yeah, I see it |
23:48:54 | FromDiscord | <ElegantBeef> Just tested it with only a single number nikki times it was very close per each value |
23:49:18 | disruptek | an example of a pin is where i changed skflatbuffers to point to `branch = nim1`. |
23:49:21 | FromDiscord | <ElegantBeef> for 100k randoms it was around 9k per each |
23:49:28 | FromDiscord | <ElegantBeef> Which is reasonable distribution |
23:50:13 | zedeus | recursively cloning frosty with git prints this "Submodule path 'jason': checked out '18428839d5a41299366b52f9842b27906e0967e4'" |
23:55:35 | FromDiscord | <lander> How does the forum moderation work? |
23:58:11 | zedeus | you can also see it when doing `git ls-tree HEAD` in frosty |
23:58:13 | zedeus | 160000 commit 18428839d5a41299366b52f9842b27906e0967e4 jason |
23:58:22 | zedeus | I think you misunderstand how submodules |
23:58:27 | zedeus | work* |
23:59:34 | FromDiscord | <nikki> you could do sample first num in 0..range and second num in 0..<range |
23:59:46 | FromDiscord | <nikki> and if they are equal, use second num = range |