00:07:39 | * | abm quit (Quit: Leaving) |
00:12:36 | * | rnrwashere joined #nim |
00:35:28 | FromGitter | <jrfondren> is there a nice way to define multiple constants with a block? I've found the following, and apart from being nice, it seems to be bugged: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5cbd0c50990feb4518def7b0] |
00:35:41 | FromGitter | <jrfondren> *apart from not being nice |
00:47:34 | FromGitter | <jrfondren> Nim but not the generated code thinks b is still in scope after that... I'll just make an issue and stick with const blah = someFunction() |
00:49:40 | FromGitter | <jrfondren> https://github.com/nim-lang/Nim/issues/5395 |
01:02:14 | FromGitter | <jrfondren> oh this works: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5cbd12965b3f941aa56e0555] |
01:03:09 | FromGitter | <jrfondren> well the uint64 issue remains, but b's messed up scope is gone. |
01:22:10 | leorize | jrfondren: you can declare constants in blocks similar to `let` or `var` blocks |
01:28:12 | FromGitter | <jrfondren> take a look at the last example in my comment at https://github.com/nim-lang/Nim/issues/5395 |
01:29:44 | FromGitter | <jrfondren> I want to define total and board as two constants whose values are determined by the same work. the usual way, let let or var, would require that one constant is completely defined before I can start on the next |
01:31:26 | leorize | I mean you can structure a `const` block just like a `let` or `var` block :p |
01:32:30 | leorize | also, type inference works with const as well |
01:32:56 | leorize | the uint64 bug seems to be a VM bug, please open an another issue for that |
01:33:28 | FromGitter | <jrfondren> another one? alright. |
01:38:49 | * | [rg] quit (Remote host closed the connection) |
01:39:12 | * | [rg] joined #nim |
01:43:44 | * | [rg] quit (Ping timeout: 246 seconds) |
01:44:27 | * | rnrwashere quit (Remote host closed the connection) |
02:03:42 | * | [rg] joined #nim |
02:07:14 | * | banc quit (Quit: Bye) |
02:29:53 | * | banc joined #nim |
02:40:59 | * | mosORadi joined #nim |
02:42:37 | * | fanta1 joined #nim |
02:47:29 | FromGitter | <kaushalmodi> Is there a way to assign values to a slice of array? |
02:48:40 | FromGitter | <kaushalmodi> ```var ⏎ foo: array[5, int] ⏎ foo[1 .. 3] = [100, 200, 300]``` ⏎ ⏎ I thought above would work, but it doesn't [https://gitter.im/nim-lang/Nim?at=5cbd2b873d78aa6c0372a0be] |
02:54:37 | * | Snircle quit (Quit: Textual IRC Client: www.textualapp.com) |
03:00:04 | disruptek | https://nim-lang.github.io/Nim/tut1.html#advanced-types-slices |
03:00:36 | * | [rg] quit (Ping timeout: 268 seconds) |
03:00:49 | * | fanta1 quit (Quit: fanta1) |
03:04:26 | FromGitter | <kaushalmodi> I don't follow .. what's different in what I am doing? may be the same slice assignment doesn't work with arrays? |
03:04:47 | disruptek | sorry, mine was not such a useful comment. |
03:05:04 | disruptek | it does work. i think you have extra spaces in your slice range? |
03:05:16 | disruptek | `foo[1..3] = [100, 200, 300]` works. |
03:05:22 | disruptek | doesn't it? |
03:05:43 | * | disruptek squints at stupid gitter. |
03:06:45 | FromGitter | <kaushalmodi> you're right.. I thought the spaces around `..` worked everywhere (need to update my notes) |
03:06:50 | FromGitter | <jrfondren> if works for me with the spaces though. |
03:07:48 | disruptek | yeah, it works. not sure what is going on with your code. ;-) |
03:08:12 | disruptek | this damned exception issue is kicking my ass. |
03:08:37 | FromGitter | <kaushalmodi> @jrfondren you are right too :P |
03:08:43 | FromGitter | <kaushalmodi> sorry I misread the error |
03:09:02 | FromGitter | <kaushalmodi> I spotted my mistake :) |
03:09:03 | FromGitter | <kaushalmodi> > Error: type mismatch: got <array[0..149, cint], HSlice[system.int, system.int], array[0..50, int]> |
03:09:22 | FromGitter | <kaushalmodi> who can guess what mistake I am making? :P |
03:09:27 | FromGitter | <kaushalmodi> s/am/was |
03:09:51 | disruptek | seems pretty clear. :-D |
03:10:08 | disruptek | i hate it when i don't read error messages. :-/ |
03:39:15 | disruptek | okay, it's something to do with adding a DateTime field to my Exception object and trying to throw it. works fine on C backend, can only be caught in a default except: clause in C++ with --noCppExceptions, and segfaults without --noCppExceptions. weird. |
04:11:16 | * | a_chou joined #nim |
04:11:37 | * | a_chou quit (Client Quit) |
04:14:16 | leorize | disruptek: a C++ codegen bug I believe? can you open a new issue? |
04:17:12 | disruptek | yeah, i did. |
04:19:07 | shashlick | for some reason, qemu-arm is not registered as a binfmt_misc format in dockcross |
04:30:28 | * | nsf joined #nim |
04:33:03 | * | [rg] joined #nim |
04:46:32 | disruptek | leorize: btw, thanks for the vim plugin. :-) |
04:48:22 | leorize | np :) |
04:49:48 | leorize | you should thank Araq for nimsuggest instead, as that's what powers most of the plugin :) |
04:50:45 | * | mosORadi quit (Quit: Connection closed for inactivity) |
05:14:47 | * | Cthalupa quit (Ping timeout: 246 seconds) |
05:15:32 | * | Cthalupa joined #nim |
05:44:58 | * | dddddd quit (Remote host closed the connection) |
05:48:09 | * | solitudesf- joined #nim |
05:59:05 | shashlick | ok finally got nim-0.19.9-linux_arm6.tar.xz built with ready binaries |
05:59:32 | shashlick | anyone interested, i'll post tomorrow |
06:00:07 | shashlick | i plan on extending nightlies - appreciate feedback |
06:13:14 | * | [rg] quit (Quit: Leaving) |
06:13:54 | * | fanta1 joined #nim |
06:31:37 | * | hoijui joined #nim |
06:38:36 | * | hoijui quit (Remote host closed the connection) |
06:46:20 | * | kapil____ joined #nim |
06:47:42 | * | jjido joined #nim |
07:00:00 | * | gmpreussner quit (Quit: kthxbye) |
07:04:55 | * | gmpreussner joined #nim |
07:14:31 | * | jjido quit (Quit: Textual IRC Client: www.textualapp.com) |
07:14:37 | leorize | if you could statically link it with musl, maybe it could run on android :p |
07:14:58 | * | jjido joined #nim |
07:19:24 | * | jjido quit (Client Quit) |
07:23:14 | * | solitudesf- quit (Ping timeout: 255 seconds) |
07:35:41 | FromGitter | <mratsim> Why do we need both a len and safelen in the AST? https://github.com/nim-lang/Nim/blob/750f50b6c04e275207ec5d1aace478369e1acf9e/compiler/ast.nim#L1035-L1045 |
07:36:33 | * | jjido joined #nim |
07:44:55 | * | SebastianM joined #nim |
07:48:39 | * | Cthalupa quit (Ping timeout: 244 seconds) |
07:49:02 | * | SebastianM quit (Quit: Leaving) |
07:53:38 | * | Cthalupa joined #nim |
07:56:37 | FromGitter | <jrfondren> len(42)'s an error in normal Nim. safeLen(42) would return 0. and safeLen on a nkIntLit returns 0. |
08:00:31 | * | SebastianM joined #nim |
08:01:52 | * | SebastianM quit (Client Quit) |
08:06:17 | * | Cthalupa quit (Ping timeout: 246 seconds) |
08:07:03 | * | Cthalupa joined #nim |
08:15:19 | * | SebastianM joined #nim |
08:22:30 | * | SebastianM quit (Quit: Leaving) |
08:28:41 | * | SebastianM joined #nim |
08:28:48 | * | Cthalupa quit (Ping timeout: 250 seconds) |
08:29:38 | * | SebastianM quit (Client Quit) |
08:29:53 | * | SebastianM joined #nim |
08:30:05 | * | SebastianM quit (Client Quit) |
08:31:06 | * | Cthalupa joined #nim |
08:32:51 | * | SebastianM joined #nim |
08:36:33 | * | Vladar joined #nim |
08:45:19 | * | stefanos82 joined #nim |
08:51:45 | * | SebastianM quit (Quit: Leaving) |
08:56:16 | * | SebastianM joined #nim |
08:57:11 | SebastianM | quit |
08:58:34 | * | Cthalupa quit (Ping timeout: 246 seconds) |
08:59:10 | * | SebastianM quit (Remote host closed the connection) |
09:01:08 | * | Cthalupa joined #nim |
09:05:28 | * | Cthalupa quit (Ping timeout: 245 seconds) |
09:06:09 | * | Cthalupa joined #nim |
09:20:48 | * | Vladar quit (Ping timeout: 250 seconds) |
09:25:11 | * | kapil____ quit (Quit: Connection closed for inactivity) |
09:55:43 | * | Trustable joined #nim |
10:28:47 | * | fanta1 quit (Quit: fanta1) |
11:23:33 | shashlick | @leorize: there's a separate container for Android which i will try later |
11:33:25 | leorize | anyone want to guess the output of the following on --newruntime? `var s = "str" ; s = s; echo s` |
11:34:48 | Zevv | "7" |
11:36:28 | FromGitter | <mratsim> output of a completely random dice roll? |
11:43:40 | leorize | all wrong, the answer is nothing :p |
11:44:44 | * | lritter joined #nim |
11:45:57 | FromGitter | <mratsim> moving to oblivion |
11:48:36 | * | dddddd joined #nim |
11:52:58 | * | Cthalupa quit (Ping timeout: 245 seconds) |
11:53:58 | * | Cthalupa joined #nim |
12:03:56 | * | fanta1 joined #nim |
12:19:23 | * | Snircle joined #nim |
12:36:05 | * | stefanos82 quit (Remote host closed the connection) |
12:40:33 | * | jjido quit (Quit: Textual IRC Client: www.textualapp.com) |
13:38:26 | Araq | leorize: uh oh, that's bad. :-/ could mean I need to redesign '=sink'... bummer |
13:41:35 | shashlick | Araq you okay adding arm6 and few other builds to nightlies eventually? Assuming I can compile and test in Travis without timing out |
13:41:51 | Araq | of course |
13:44:21 | shashlick | Thinking android, armv6 for raspberry pi for starters |
13:44:43 | shashlick | Will add others depending on demand |
13:46:56 | Zevv | hard float or soft float, neon or no neon, what about thumb and aarch64. so many options when going arm. |
13:47:55 | shashlick | Need to look at dom96 feedback on the nocompiler PR, lots of comments, will take a while to implement and test everything again |
13:48:20 | shashlick | There are many on dockcross |
13:48:26 | Araq | gah, so bad, the elegance of =sink goes out of the window |
13:48:45 | shashlick | I've already figured out armv6 so others won't be as hard |
13:48:46 | Araq | :-( |
13:49:15 | Araq | at least we found it before hard-coding this in the spec. |
13:49:31 | shashlick | Armv5, v6, v7, v7a, 64 |
13:51:28 | Zevv | sahashlick: muliply with [soft, softfp, hard, vfpv4, neon, ...] |
13:52:22 | Zevv | I guess it makes sense to just target the most popular permutations - indeed rpi at least |
14:01:22 | * | kapil____ joined #nim |
14:16:21 | * | stefanos82 joined #nim |
14:27:20 | * | drewr quit (Remote host closed the connection) |
14:30:36 | * | drewr joined #nim |
14:34:29 | * | SebastianM joined #nim |
14:45:55 | * | clyybber joined #nim |
14:58:26 | * | solitudesf- joined #nim |
15:08:22 | shashlick | @rayman22201 - trying out the arm build on your Pi |
15:16:48 | FromGitter | <Varriount> Araq: What's wing with sink? |
15:21:22 | shashlick | just works! brilliant |
15:24:03 | * | _leorize joined #nim |
15:24:41 | * | leorize is now known as Guest70925 |
15:24:41 | * | Guest70925 quit (Killed (sinisalo.freenode.net (Nickname regained by services))) |
15:24:41 | * | _leorize is now known as leorize |
15:24:48 | * | Guest70925 joined #nim |
15:25:16 | * | clyybber quit (Quit: WeeChat 2.4) |
15:31:12 | SebastianM | Hi guys, its my first time on IRC, cound you confirm that you se my message? |
15:31:48 | leorize | SebastianM: confirmed |
15:35:26 | SebastianM | Thank you, leorize. Good to join nim community:) |
15:38:05 | * | stefanos82 quit (Remote host closed the connection) |
15:41:09 | * | shadowbane joined #nim |
15:53:48 | * | rauss quit (Quit: WeeChat 2.4) |
15:54:13 | * | SebastianM quit (Quit: ERC (IRC client for Emacs 26.1)) |
16:08:38 | * | natrys joined #nim |
16:31:53 | * | iLiquid joined #nim |
16:38:29 | * | iLiquid quit (Read error: Connection reset by peer) |
16:38:45 | * | iLiquid joined #nim |
16:39:49 | * | kapil____ quit (Quit: Connection closed for inactivity) |
16:41:21 | * | vlad1777d quit (Remote host closed the connection) |
16:41:52 | shashlick | if anyone wants latest devel build for raspberry pi: https://www.dropbox.com/s/6rhkeeayeki1rbh/nim-0.19.9-linux_armv6.tar.xz?dl=0 |
16:42:22 | * | vlad1777d joined #nim |
16:42:50 | FromGitter | <arnetheduck> shasklick, do you build releases also (ie 0.19.4)? |
16:45:21 | shashlick | am planning on adding these to nightlies, but this is a one off build I made |
16:45:26 | shashlick | i can make one for 0.19.4 if you need |
16:54:58 | * | Jesin quit (Quit: Leaving) |
16:57:05 | * | Jesin joined #nim |
17:04:22 | * | krux02 joined #nim |
17:04:52 | krux02 | @cooldome: are you around? |
17:05:58 | * | [rg] joined #nim |
17:29:39 | rayman22201 | @shashlick: awesome! I'm glad you got the rpi build working 👍 🎉 |
17:30:55 | shashlick | building 0.19.4 now |
17:31:01 | shashlick | and scripting it |
17:31:59 | rayman22201 | Inclusion in nightlies and official releases won't be far behind 😛 |
17:32:31 | * | krux02 quit (Remote host closed the connection) |
17:33:48 | shashlick | am wondering whether i should use travis stages or have a separate job for each new build |
17:34:05 | shashlick | cause we need to start with a tar.xz which gets built already with linux 32/64 builds |
17:38:40 | FromGitter | <arnetheduck> jit coming to clang: https://arxiv.org/pdf/1904.08555.pdf |
17:47:04 | shashlick | @arnetheduck - here's the 0.19.4 armv6 build - https://www.dropbox.com/sh/4i0lon90rwi0uat/AADZr8EUwExggMQ46PYCz0oIa?dl=0 |
17:47:19 | shashlick | i'll create a few others in some time - armv7, arm64, android, etc. |
17:47:31 | FromGitter | <jrfondren> the Feature suggestions page on the github wiki says that introspection like Python's dir() is "Possible via metaprogramming". Does anyone have an example of that? Specifically a dir(), showing all exports in a module, or all 'methods' of a type |
17:48:57 | FromGitter | <arnetheduck> shashlick that was quick :) |
17:48:59 | FromGitter | <jrfondren> someone's building an arm64 Android nim right now actually, for Termux |
17:49:54 | FromGitter | <jrfondren> https://github.com/termux/termux-packages/tree/master/packages/nim |
17:58:14 | rayman22201 | I built the termux version on my Android a while ago. I had to install an fsutils package but it worked flawlessly |
17:58:31 | rayman22201 | It's been around for a while |
18:11:21 | FromGitter | <arnetheduck> @mratsim for your arraymancer, an IR: https://github.com/tensorflow/mlir |
18:13:35 | * | rnrwashere joined #nim |
18:13:53 | shashlick | just added armv7 |
18:20:48 | Zevv | \o/ |
18:31:37 | * | rnrwashere quit (Remote host closed the connection) |
18:36:47 | * | dddddd_ joined #nim |
18:38:23 | * | dddddd quit (Ping timeout: 245 seconds) |
18:38:42 | * | dddddd_ is now known as dddddd |
18:39:01 | * | rnrwashere joined #nim |
18:41:36 | * | rnrwashere quit (Remote host closed the connection) |
18:49:09 | * | vlad1777d quit (Remote host closed the connection) |
18:51:14 | * | vlad1777d joined #nim |
18:55:20 | * | [rg] quit (Quit: Leaving) |
19:03:19 | Zevv | https://alexgaynor.net/2019/apr/21/modern-c++-wont-save-us/ |
19:04:54 | xace | hmm, does nim-gdb support conditional breakpoints or am I dreaming? |
19:10:56 | * | nsf quit (Quit: WeeChat 2.4) |
19:14:10 | * | vlad1777d quit (Remote host closed the connection) |
19:16:11 | * | vlad1777d joined #nim |
19:22:36 | FromGitter | <mratsim> @arnetheduck Ugh, that's like the 5th IR for ML compiler :P |
19:25:07 | FromGitter | <mratsim> I actually made quite a bit of progress today on my compiler project, I can AOT compile expression/statement --> AST --> Nim code for scalars. |
19:26:15 | FromGitter | <mratsim> Next I need to apply that to sequence/pointers+len. And made the objects carefully so I can use them also at runtime to do expression/statement --> AST --> LLVM IR or any 3 address code format |
19:41:35 | * | fanta1 quit (Quit: fanta1) |
19:46:56 | * | rnrwashere joined #nim |
19:47:25 | * | rnrwashere quit (Remote host closed the connection) |
19:50:59 | * | ng0 joined #nim |
20:40:06 | * | noonien joined #nim |
20:41:40 | noonien | hello folks |
20:42:09 | noonien | is it customary to pass data that would otherwise be an array of bytes, as strings in nim? |
20:46:04 | * | luis_ joined #nim |
20:47:54 | FromGitter | <jrfondren> I reckon. strings aren't required to have a valid encoding and can just be a stream of bytes if read from a file. |
20:48:44 | noonien | oh, ok |
20:48:47 | FromGitter | <jrfondren> from the manual: Per convention, all strings are UTF-8 strings, but this is not enforced. For example, when reading strings from binary files, they are merely a sequence of bytes. The index operation s[i] means the i-th char of s, not the i-th unichar. The iterator runes from the unicode module can be used for iteration over all Unicode characters. |
20:49:02 | FromGitter | <mratsim> @noonien, I strongly argue that you use a seq[byte] or a ptr UncheckedArray[byte] instead |
20:49:39 | noonien | yes, it's what i would have used, but i want to use some crypto libraries, and they all seem to work on strings for some reason |
20:50:00 | FromGitter | <mratsim> you're in for a treat |
20:50:13 | FromGitter | <mratsim> https://github.com/nim-lang/RFCs/issues/32 |
20:52:15 | noonien | array[bits div 8, uint8] |
20:52:25 | noonien | wht bits div 8 instead of byte? |
20:52:49 | noonien | i'm guessing because `char` is also compatible with `bits div 8`? |
20:52:59 | FromGitter | <mratsim> No it's from here: https://github.com/cheatfate/nimcrypto/blob/master/nimcrypto/hash.nim#L20-L23 |
20:53:17 | FromGitter | <mratsim> for exemple SHA3-256 is a 256-bit hash |
20:53:28 | FromGitter | <mratsim> we use 256 as an static parameter |
20:53:41 | FromGitter | <mratsim> 256 bit = 256 div 8 byte |
20:54:28 | * | LyndsySimon quit (Ping timeout: 258 seconds) |
20:55:09 | disruptek | now i have a new issue where an overload with an identical {.raises: [Defect].} tells me that it has an unlisted Defect exception. change the name of the proc and it compiles fine. Error: target STRING not available |
20:55:49 | * | noonien quit (Read error: Connection reset by peer) |
20:56:42 | disruptek | redefine the procs in a separate file and they are fine. |
20:58:39 | * | LyndsySimon joined #nim |
20:59:00 | * | Trustable quit (Remote host closed the connection) |
20:59:02 | disruptek | guess it's just a misleading error message. :-/ |
20:59:34 | * | LyndsySimon quit (Max SendQ exceeded) |
20:59:44 | FromGitter | <mratsim> Also for crypto lib @noonien I suggest you use nimcrypto, it's used in production at Status (my company), we have very large stake (Ethereum blockchain) and we plan to audit it, support it, and in time hopefully add constant time implementation. |
21:01:35 | FromGitter | <mratsim> Only isue is documentation. You have 2 API. Either "digest", or stream hashing via ctx.init, ctx.update, ctx.finish: https://github.com/cheatfate/nimcrypto/blob/master/nimcrypto/hash.nim#L60-L91 |
21:02:14 | * | LyndsySimon joined #nim |
21:03:38 | disruptek | i really want to be able to define my lets outside the scope where they are assigned. is that so crazy? |
21:03:58 | FromGitter | <mratsim> let foo = block: |
21:04:23 | disruptek | it's more like let foo = try: but yeah. |
21:05:10 | FromGitter | <mratsim> but assignment is scoped. Maybe there is a way to have a "write-once" var, I often have this need as well. |
21:05:33 | FromGitter | <mratsim> otherwise use an initialization function or template |
21:05:34 | disruptek | i just want to be able to define it and then assign it later. |
21:05:42 | disruptek | albeit, once. |
21:05:59 | FromGitter | <jrfondren> that introduces the possibility that you'll refer to it before it's assigned. |
21:06:02 | FromGitter | <jrfondren> do you just want that for neatness? |
21:06:54 | * | LyndsySimon quit (Ping timeout: 244 seconds) |
21:07:09 | FromGitter | <mratsim> it's more useful when the assignment depends on a if/case conditional logic. |
21:07:33 | FromGitter | <mratsim> Also the generated code is cleaner :P |
21:07:53 | disruptek | i want to capture stuff in a try/except: and, if successful, work with it in a subsequent scope. it's not entirely cosmetic; the flow is technically different. |
21:09:12 | * | noonien joined #nim |
21:09:15 | * | LyndsySimon joined #nim |
21:09:56 | disruptek | the possibility that i may refer to it before it is assigned is easily caught by the compiler. |
21:10:02 | FromGitter | <jrfondren> you could put the try/except in a function and pass a function to it that's called in the success case, and you get your no-further-assignment bindings in the parameters to the function. and then make that neater. |
21:11:18 | disruptek | you have it admit, that sounds harder than `let foo: int`, right? |
21:11:23 | FromGitter | <jrfondren> I guess you're wanting a var {.singleassignment.}, or the convention that let without a definition is treated that way. |
21:11:36 | disruptek | let without assignment, rather, but yes. |
21:11:40 | FromGitter | <jrfondren> it sounds harder to write, but it's also something you can do |
21:11:55 | disruptek | no, i know. i just don't know why it's so hard. |
21:12:06 | FromGitter | <jrfondren> rather, it's either uglier or harder to write. passing a lambda is uglier, making that pretty with a macro is harder. |
21:12:09 | FromGitter | <mratsim> to prevent nil |
21:12:19 | FromGitter | <jrfondren> well you could just use var and exercise discipline :) |
21:13:57 | * | Cthalupa quit (Ping timeout: 268 seconds) |
21:14:35 | FromGitter | <jrfondren> fwiw it's something I've wanted as well, let without a definition like that. |
21:14:36 | disruptek | sure; this isn't important. i'm just trying to find the cleanest ways to write what i feel is idiomatic, legible, and correct nim. |
21:14:49 | disruptek | let hoisting. |
21:14:50 | FromGitter | <jrfondren> I think the macro option is the best way. |
21:14:54 | disruptek | right. |
21:15:00 | FromGitter | <jrfondren> for this specific case |
21:15:48 | * | Cthalupa joined #nim |
21:15:52 | * | luis_ quit (Ping timeout: 245 seconds) |
21:19:25 | disruptek | i'm sure i've coded in languages where the immutable var may be hoisted and is write-once. |
21:19:26 | FromGitter | <mratsim> @narimiran, why was the exception label removed and what was it into? |
21:23:49 | disruptek | the thing about #10975, the arbitrary varargs parameter passing, is that it allows you to twiddle an incoming varargs before passing it to another proc that takes varargs. i don't know another way to do that, if this changes. |
21:25:02 | disruptek | eg. in python we can dereference an array to cause it to be passed as args, as in `foo(*somelist)`, but if there's a way to do that in nim, i haven't seen any docs on it. |
21:26:32 | FromGitter | <arnetheduck> disruptek: ⏎ ⏎ ```let x = ⏎ try: ⏎ 42 ⏎ except: ⏎ 45``` [https://gitter.im/nim-lang/Nim?at=5cbe31883d78aa6c0379a4d3] |
21:26:55 | disruptek | yeah, that's what i'm doing. |
21:28:14 | FromGitter | <jrfondren> that's a lot less pleasant if you want multiple bindings |
21:28:32 | FromGitter | <arnetheduck> your single-assignment suggestion is tricky, you can't decide it generally: ⏎ ⏎ ``` let x ⏎ for a in b: ⏎ x = a``` ⏎ ⏎ was x assigned? [https://gitter.im/nim-lang/Nim?at=5cbe3200b4700e023db6a504] |
21:29:13 | FromGitter | <arnetheduck> ```let (a, b, c) = block: ⏎ (42,43,44)``` ⏎ ⏎ should work.. [https://gitter.im/nim-lang/Nim?at=5cbe3229b489bb6ed7a9db91] |
21:30:06 | FromGitter | <jrfondren> I created two Nim issues after trying that the first time, and it's still not pretty |
21:30:36 | FromGitter | <arnetheduck> lol, every feature I try comes with at least two issues created - trust me, we've gone through a lot of them :) |
21:30:40 | disruptek | yeah, it gets hairy quicky in those issues. :-P |
21:33:44 | * | solitudesf- quit (Ping timeout: 246 seconds) |
21:35:51 | FromGitter | <jrfondren> ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5cbe33b7375bac7470eaae01] |
21:37:54 | FromGitter | <jrfondren> I can see that you are all stunned to silence by the perfection of this solution. |
21:38:38 | FromGitter | <jrfondren> ah wait. I added proc because block: doesn't come with its own result, but now block's not needed |
21:38:46 | FromGitter | <jrfondren> ```let (a, b) = (proc: (int, int) = ⏎ result[0] = 42 ⏎ result[1] = 43 ⏎ )()``` [https://gitter.im/nim-lang/Nim?at=5cbe34661cd0b8307d56c021] |
21:43:47 | FromGitter | <arnetheduck> that's an easy way to shoot yourself in the foot though.. the tuple solution guarantees that each var gets a value - with the result thing, apart from the result repetition, it's also easy to forget to assign stuff (when refactoring).. |
21:44:51 | FromGitter | <jrfondren> aye. missed results will be zero at least. |
21:58:43 | * | arecaceae joined #nim |
21:58:46 | * | arecacea1 quit (Ping timeout: 246 seconds) |
21:58:55 | * | WilhelmVonWeiner quit (Ping timeout: 246 seconds) |
21:58:55 | * | Sargun quit (Ping timeout: 246 seconds) |
21:58:55 | * | onionhammer quit (Ping timeout: 246 seconds) |
21:58:55 | * | FromGitter quit (Ping timeout: 246 seconds) |
21:58:55 | * | joshbaptiste quit (Ping timeout: 246 seconds) |
21:59:03 | * | FromGitter joined #nim |
21:59:04 | * | Lord_Nightmare quit (Ping timeout: 246 seconds) |
21:59:05 | * | zama quit (Ping timeout: 246 seconds) |
21:59:05 | * | onionhammer joined #nim |
21:59:25 | * | Jjp137 quit (Ping timeout: 246 seconds) |
21:59:26 | * | livcd quit (Ping timeout: 246 seconds) |
21:59:36 | * | zama joined #nim |
22:00:00 | * | Sargun joined #nim |
22:00:09 | * | disruptek quit (Ping timeout: 246 seconds) |
22:00:18 | * | WilhelmVonWeiner joined #nim |
22:00:27 | * | disruptek joined #nim |
22:00:43 | * | WilhelmVonWeiner is now known as Guest96258 |
22:01:09 | * | livcd joined #nim |
22:02:05 | * | banc quit (Ping timeout: 255 seconds) |
22:02:13 | * | Lord_Nightmare joined #nim |
22:02:25 | * | Jjp137 joined #nim |
22:02:29 | * | joshbaptiste joined #nim |
22:02:44 | * | iLiquid quit (Quit: iLiquid) |
22:04:05 | * | banc joined #nim |
22:06:38 | * | vlad1777d_ joined #nim |
22:07:12 | * | natrys quit (Quit: natrys) |
22:07:15 | * | vlad1777d quit (Ping timeout: 276 seconds) |
22:11:03 | * | FromDiscord_ joined #nim |
22:13:36 | * | mal``` joined #nim |
22:15:08 | * | lritter quit (Ping timeout: 255 seconds) |
22:16:33 | * | mal`` quit (Ping timeout: 250 seconds) |
22:16:33 | * | cornfeedhobo quit (Ping timeout: 250 seconds) |
22:16:35 | * | FromDiscord quit (Ping timeout: 250 seconds) |
22:16:36 | * | deepend quit (Ping timeout: 250 seconds) |
22:16:38 | * | gsingh93 quit (Ping timeout: 250 seconds) |
22:18:36 | * | gsingh93 joined #nim |
22:23:03 | * | ng0 quit (Quit: Alexa, when is the end of world?) |
22:23:56 | * | deepend joined #nim |
22:24:15 | * | deepend quit (Remote host closed the connection) |
22:24:48 | * | deepend joined #nim |
22:24:55 | * | cornfeedhobo joined #nim |
22:30:31 | noonien | hmm, what can i pass as buf to `proc recvLine(socket: AsyncSocket; flags = {SafeDisconn}; maxLength = MaxLineLength): Future[ |
22:30:31 | noonien | string] {...}`? i tried `var buf: array[1024, byte]`, and passing `buf`, but i get a "type expected" error |
22:32:41 | noonien | sorry, i meant `proc recvInto(socket: AsyncSocket; buf: pointer; size: int; flags = {SafeDisconn}): Future[int]` |
22:32:42 | FromGitter | <jrfondren> that doesn't take a buf |
22:33:37 | FromGitter | <jrfondren> buffer: array[0..BufferSize, char] is what asyncnet itself uses for a buffer |
22:34:02 | FromGitter | <jrfondren> var size = readInto(addr socket.buffer[0], BufferSize, socket, flags) |
22:34:32 | FromGitter | <jrfondren> https://nim-lang.github.io/Nim/system.html#addr,T |
22:34:46 | noonien | yes, i discovered .addr, thanks! :D |
22:36:53 | shashlick | just posted arm64 build of 0.19.4 |
22:39:06 | * | luis__ joined #nim |
22:41:49 | * | luis__ quit (Client Quit) |
22:44:51 | noonien | given `var buf: array[1024, byte]`, what type is `buf[..32]`? |
22:45:46 | * | cyraxjoe quit (Remote host closed the connection) |
22:55:10 | FromGitter | <jrfondren> seq[byte] |
22:55:46 | noonien | ah, ok |
22:56:04 | FromGitter | <jrfondren> you can confirm that by importing typetraits and then looking at $type(buf[..32]) |
22:56:09 | noonien | i have a function that requires a sequence of a certain size, is there a type for that? |
22:57:22 | noonien | for example, i want to pass `buf[..32]` as an `array[32, byte]`, the size is constant in this case |
22:59:31 | FromGitter | <jrfondren> I think that'd require copying the 32 bytes. |
23:00:34 | * | [rg] joined #nim |
23:00:57 | noonien | i was afraid of that, thanks! |
23:04:34 | noonien | i've got `type Signature* = array[64, byte]`, given the type name, can i get the size of the array? in this case 64? |
23:06:05 | FromGitter | <jrfondren> len(Signature) == 64 |
23:06:16 | noonien | hmmm, interesting |
23:06:30 | FromGitter | <jrfondren> it's 64 for an array of 64 ints as well. |
23:06:56 | noonien | basically sizeof(arr) / sizeof(arr[0]) in C |
23:07:10 | noonien | arr being a type |
23:07:14 | * | jasper joined #nim |
23:07:15 | FromGitter | <jrfondren> well sizeof()'s available if you want that |
23:07:26 | noonien | nah, just wanted to learn |
23:09:50 | FromGitter | <jrfondren> btw that's 33 bytes, not 33. the result of a [..32] slice. |
23:09:54 | FromGitter | <jrfondren> *not 32 |
23:11:01 | noonien | hmm, ok |
23:14:11 | noonien | are there any helpers to turn a sequence into a fixed array? |
23:22:42 | FromGitter | <jrfondren> I didn't see any. I'd try a simple loop to populate the array. |
23:26:33 | FromGitter | <jrfondren> seqs are implemented as growable arrays. |
23:27:29 | FromGitter | <jrfondren> so the slice might also be a copy. what you might do instead is pass indexes around. |
23:28:53 | FromGitter | <jrfondren> as this thing I tried doesn't mutate the original array: https://gist.github.com/jrfondren/6afb3050343cf1915ebf17ec3b59454c |
23:29:18 | noonien | i don't need mutation |
23:30:16 | FromGitter | <jrfondren> aye, but the lack of mutation means I mutated a copy |
23:32:27 | noonien | i guess what i'm asking is, given a sequency of enough length, can i not pass a reference to it as an array of specific size? |
23:32:35 | noonien | an immutable array |
23:33:05 | noonien | the memory should be the same, i would like to avoid a copy if possible |
23:35:52 | FromGitter | <jrfondren> aye. It's possible but if it's done I don't see it. I'm still new to Nim though. |
23:35:58 | FromGitter | <jrfondren> ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5cbe4fde990feb4518e759eb] |
23:45:54 | * | Snircle quit (Read error: Connection reset by peer) |
23:46:38 | * | Snircle joined #nim |
23:48:51 | jasper | Maybe system.shallow or system.toOpenArray would help? If copying you can wrap memcpy in a fairly safe way: https://hastebin.com/eqekuzolot.md |
23:52:03 | FromGitter | <jrfondren> https://github.com/mratsim/Arraymancer/blob/master/src/tensor/data_structure.nim - very bottom, Fdata there is a Seq |
23:58:30 | FromGitter | <jrfondren> ah I bet this is it. proc toOpenArrayT (x: seq[T]; first, last: int): openArray[T] |