ChanServ changed the topic of #zig to: zig programming language | https://ziglang.org | be excellent to each other | channel logs: https://irclog.whitequark.org/zig/
kristoff_it has joined #zig
cheesy has quit [Quit: zzz]
kristoff_it has quit [Ping timeout: 244 seconds]
mikdusan has quit [Ping timeout: 248 seconds]
nifker has quit [Quit: nifker]
<tgschultz> For the record andrewrk, I'd rather you reject anything I submit than accept something you think is detremental to zig, so don't feel bad about rejecting my stuff anyway.
kristoff_it has joined #zig
kristoff_it has quit [Ping timeout: 268 seconds]
fsateler has quit [Read error: Connection reset by peer]
fsateler has joined #zig
marijnfs_ has joined #zig
mikdusan has joined #zig
marijnfs has quit [Ping timeout: 248 seconds]
ntgg has joined #zig
<daurnimator> marler8997_: you might find https://github.com/ziglang/zig/issues/2383 interesting
darithorn has quit [Quit: Leaving]
fengb has quit [Ping timeout: 260 seconds]
renatorabelo has joined #zig
cheesy has joined #zig
kristoff_it has joined #zig
kristoff_it has quit [Ping timeout: 258 seconds]
kristoff_it has joined #zig
kristoff_it has quit [Ping timeout: 245 seconds]
ltr- has joined #zig
<ltr-> andrewrk: is your plan to implement an lsp server as part of the std lib?, for example i can "start" the server with 'zig run-lsp' ?? so the build.zig will eventually run the main function of the server in a separate process when the editors start?
<ltr-> yes im writing a comment there
<ltr-> proposing a way to do it.
<ltr-> i like the idea of an lsp server in the standard library , so editors can call and execute build.zig with an special argument to spawn a server
kristoff_it has joined #zig
kristoff_it has quit [Ping timeout: 272 seconds]
kristoff_it has joined #zig
kristoff_it has quit [Ping timeout: 245 seconds]
renatorabelo has quit [Remote host closed the connection]
ltr- has quit [Quit: leaving]
cheesy has quit [Quit: zzz]
kristoff_it has joined #zig
kristoff_it has quit [Ping timeout: 245 seconds]
hio has joined #zig
<meowray> there are many lessons we can learn from clangSema for completion. Its on-the-fly diagnostics is great
ManDeJan has joined #zig
kristoff_it has joined #zig
kristoff_it has quit [Ping timeout: 268 seconds]
ManDeJan has quit [Ping timeout: 248 seconds]
kristoff_it has joined #zig
kristoff_it has quit [Ping timeout: 245 seconds]
laaron has joined #zig
kristoff_it has joined #zig
kristoff_it has quit [Ping timeout: 245 seconds]
kristoff_it has joined #zig
kristoff_it has quit [Ping timeout: 245 seconds]
cheesy has joined #zig
brakmic has joined #zig
brakmic has quit [Remote host closed the connection]
kristoff_it has joined #zig
brakmic has joined #zig
kristoff_it has quit [Ping timeout: 245 seconds]
kristoff_it has joined #zig
jjido has joined #zig
kristoff_it has quit [Ping timeout: 258 seconds]
kristoff_it has joined #zig
<daurnimator> emekankurumeh[m]: you there?
<emekankurumeh[m]> yes
<daurnimator> Re: socket module. you've gone with a very classic BSD socket API. I'd like to propose that zig prefers a more modern command buffer approach
<marler8997_> Is there a library that you could reference that uses such a commmand buffer approach?
<marler8997_> Also, for any higher level API, I would think it could work on top of the socket api right?
<daurnimator> marler8997_: no. a fast/efficient command buffer api would need to bypass that socket api...
<daurnimator> marler8997_: in that link have a look at `so_exec`
kristoff_it has quit [Ping timeout: 245 seconds]
<marler8997_> Everything I'm looking at looks like it works on top of the socket api
<daurnimator> marler8997_: in that file yes. but a fast and efficient one wouldn't
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<marler8997_> is there an example, or can you elaborate?
<daurnimator> marler8997_: on linux, you'd instead build on top of uring (see http://kernel.dk/io_uring.pdf)
<daurnimator> on windows you'd use all OVERLAPPED operations
<emekankurumeh[m]> fyi, everything in that pr is more or less up for debate
<marler8997_> I'll have to read up on this. I've done alot of socket programming but am not familiar with "command buffer api"
<marler8997_> I am familair with overlapped IO though
<emekankurumeh[m]> i suppose andrewrk would have the final say though
<marler8997_> it's not a replacement for the socket api
<marler8997_> it relies on the socket api as well
<marler8997_> at least parts of it
<daurnimator> marler8997_: on windows it's all io submission requests underneath
<emekankurumeh[m]> isn't iocp better than "vanilla" overlapped io
<daurnimator> emekankurumeh[m]: no IOCP is terrible
<marler8997_> sure but you still need the socket api, it's not a replacement
<daurnimator> marler8997_: huh?
<emekankurumeh[m]> really?
<marler8997_> overlapped IO is just how you send/receive data
<marler8997_> you still need a socket library for everything else
<marler8997_> IOCP is terrible?
<marler8997_> it's been a few years since I've used this stuff...
<marler8997_> I recall IOCP being the most scallable and most efficient variant...
<daurnimator> emekankurumeh[m]: IOCP only allows registering a single IOCP controller per handle. it's better to use overlapped IO yourself.
<marler8997_> I could be remembering wrong though, it's been a few years
<daurnimator> but then sockets are different again
<daurnimator> sockets aren't.... "real" on windows
<marler8997_> you mean they aren't files like on linux?
<daurnimator> on windows when you use sockets you are actually talking to the AFD driver
<marler8997_> never heard of the AFD driver...what is that?
<marler8997_> not much coming up on google
<daurnimator> a socket HANDLE is actually just a random handle to the AFD driver, and send/recv are ioctls on the AFD HANDLE
jjido has joined #zig
<marler8997_> is there docs on this?
<daurnimator> marler8997_: not that it'll help you find info, but AFD stands for "Advanced Function Driver"
<daurnimator> marler8997_: uh. no I don't think so
<marler8997_> ?? then how do you know this?
<daurnimator> uh... uh..... *looks around*
<marler8997_> cool, some inside look into how windows operates
<marler8997_> windows is quite odd, it provides a userspace C ABI rather than exposing the kernel interfaces
<emekankurumeh[m]> mio for rust used iocp and that powers hyper/tokio which score relatively high on the techenpower benchmarks
<marler8997_> oh, very interesting
<daurnimator> emekankurumeh[m]: if you want to go fast with sockets on windows you talk directly to the AFD driver.
<emekankurumeh[m]> I suppose midpix would be helpful hrre
<marler8997_> Sounds like an interesting project, but in the immediate, providing a socket library that supports the BSD style socket API also makes sense in my opinion
<daurnimator> I think I was the one that told midipix this some of this stuff
<daurnimator> but yes midipix has some good defines for it
<daurnimator> and in psxscl he wrote the best windows socket polling piece I've ever seen
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<daurnimator> marler8997_: yes and no...
<daurnimator> I think we can do command buffer style now
<emekankurumeh[m]> it might make sense to ~~steal~~ port some of that stuff from midipix
<daurnimator> emekankurumeh[m]: note that midipix is GPL.
<marler8997_> shouldn't we support the basic well-defined officially supported interface first?
<mq32> daurnimator, what would "command buffer style" exactly be? i know these words from Vulkan, but not in connection to networking
<daurnimator> so what am I suggesting now?: the socket object should have: socket.queueListen(), socket.queueSend(); socket.queueRead(); etc. method.
<daurnimator> and then only finally *do* them when you do. socket.exec() or similar
<mq32> so my primary use case would be .queueReceive(), .exec() ?
<daurnimator> this will then be easy to write different 'backends' internally that use uring/overlapped IO/raw AFD operations without changing the public API
<emekankurumeh[m]> do you have a proposal typed up?
<emekankurumeh[m]> (on the issue tracker)
<daurnimator> emekankurumeh[m]: I don't think so? I've mentioned it before here on IRC and I think in #2525 ?
<daurnimator> originally #2525 contained the start of my implementation
kristoff_it has joined #zig
<daurnimator> but I changed that PR to be just the uring defines.
<emekankurumeh[m]> also any async stuff would have to be built on top of this stuff right?
<daurnimator> emekankurumeh[m]: well you'll notice that if you have .queueReceive(), you already sort of have async ;)
<emekankurumeh[m]> furthermore the traditional BSD style api could be built on top of this right?
<daurnimator> emekankurumeh[m]: yep
kristoff_it has quit [Ping timeout: 272 seconds]
<daurnimator> recv() would be .queueReceive() and then .exec()
<emekankurumeh[m]> I'll try to address some of the comments on the pr and then I'll look into some of this other stuff
<daurnimator> My branch with this stuff got paused until I see how coroutines end up looking
<emekankurumeh[m]> most of the code in that pr is from a while ago
<emekankurumeh[m]> ~1400 commits ago
kristoff_it has joined #zig
kristoff_it has quit [Ping timeout: 246 seconds]
marijnfs__ has joined #zig
kristoff_it has joined #zig
ntgg has quit [Quit: leaving]
kristoff_it has quit [Remote host closed the connection]
kristoff_it has joined #zig
marijnfs__ has quit [Ping timeout: 272 seconds]
marijnfs__ has joined #zig
samtebbs has joined #zig
brakmic has quit [Read error: Connection reset by peer]
brakmic has joined #zig
IntoxicatedHippo has joined #zig
<IntoxicatedHippo> Does anyone have a NixOS derivation for a recent version of Zig? I'm trying to build it and I'm getting this error: Generating libuserland.a, Unable to create builtin.zig: access denied
<samtebbs> IntoxicatedHippo: Is that a NixOS-specific error or a general permissions error? I'm pretty sure that andrewrk himself develops on NixOS.
<IntoxicatedHippo> It's an error from the zig build, but I don't know what within the build causes it or where it's trying to create builtin.zig
cheesy has quit [Quit: zzz]
cheesy has joined #zig
cheesy has quit [Client Quit]
brett-soric has joined #zig
ibutra has joined #zig
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #zig
kristoff_it has quit [Ping timeout: 246 seconds]
ibutra has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
brett-soric has left #zig [#zig]
<samtebbs> IntoxicatedHippo: A verbose build might tell you what's causing it
ltr- has joined #zig
bheads has joined #zig
ibutra has joined #zig
marijnfs__ has quit [Quit: WeeChat 2.4]
ibutra has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ibutra has joined #zig
ibutra has quit [Ping timeout: 264 seconds]
ibutra has joined #zig
marijnfs_ has quit [Quit: WeeChat 2.4]
<bheads> Watching the live stream from yesterday, not done yet but was wondering in andrewk figures out you can use msync to test if a page is mapped
<bheads> msync sets errno to ENOMEM if the page address is not mapped
<Tetralux> OOC, what does it set it to if it is?
<bheads> msync would return 0
<bheads> no success
<bheads> on success****
<samtebbs> Tagging andrewrk for above ^
<bheads> I think you can also use madvise as well
<bheads> This might be the most platform safe to use: http://man7.org/linux/man-pages/man3/posix_madvise.3.html
nifker has joined #zig
<dimenus> does zig have format specifiers in print?
<dimenus> or is it intended that you always leverage the RTTI to print it correctly?
shritesh has joined #zig
<bheads> but its not document yet, so you need to dig through the code
<bheads> but to look at the tests at the end of the file
very-mediocre has joined #zig
<dimenus> bheads: thanks
<bheads> @dimenus: np
Tetralux__ has joined #zig
Tetralux has quit [Ping timeout: 248 seconds]
Tetralux__ is now known as Tetralux
<IntoxicatedHippo> What's the name for the files cached in ~/.local/share/zig/stage1/o/ ?
Tetralux has quit [Ping timeout: 268 seconds]
Tetralux has joined #zig
<mikdusan> IntoxicatedHippo: that's another level of `zig-cache`; feel free to delete `~/.local/share/zig`; zig will populate it as necessary
<IntoxicatedHippo> It doesn't seem to get updated when -mllvm options change, I'm trying to work out if that's been reported or not
gamester has joined #zig
ibutra has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
very-mediocre has quit [Read error: Connection reset by peer]
very-mediocre1 has joined #zig
<emekankurumeh[m]> should it?
<IntoxicatedHippo> I assume there are flags that will change the output, I ran in to an issue here when I tried to use `-llvm-features -sse`: https://github.com/ziglang/zig/pull/2595
ltr- has quit [Ping timeout: 245 seconds]
<mikdusan> --> "Cached files in ~/.local/share/zig are not updated when --llvm-features flags are changed."
<mikdusan> is that referring to files like compiler_rt.o and libcompiler_rt.a ?
<IntoxicatedHippo> Yes
<mikdusan> i did this, and it seems to confirm: `zig run -mllvm -mcpu=avx hello.zig`
<mikdusan> noticed this: a new `run.o` was populated in cache. but not `compiler_rt.o` and `libcompiler_rt.a`
<nifker> where can I find docs for 'builtin'?
<Tetralux> `zig builtin` may help you (cmdline)
<mikdusan> nifker: if you're looking for TypeInfo docs; search for `@typeInfo` in zig main doc
<nifker> I dont seem to be able to access "builtin.Arch.Arm32.v7m" somehow
<emekankurumeh[m]> it's a tagged union
<nifker> so I found this line which works but doesnt fit my requirement "exe.setTarget(builtin.Arch{ .aarch64 = builtin.Arch.Arm64.v8 }, builtin.Os.freestanding, builtin.Abi.eabihf);"
<nifker> but this doesnt "exe.setTarget(builtin.Arch{ .aarch64 = builtin.Arch.Arm64.v8 }, builtin.Os.freestanding, builtin.Abi.eabihf);"
<emekankurumeh[m]> so you have to do builtin.Arch{ .arm = .v7 }
<nifker> copied wrong stuff
<emekankurumeh[m]> *v7m
<emekankurumeh[m]> these come in handy here https://ziglang.org/documentation/master/#Enum-Literals
<nifker> It was this line "exe.setTarget(builtin.Arch{ .thumb = builtin.Arch.Arm32.v7m }, builtin.Os.freestanding, builtin.Abi.eabihf);"
<nifker> but the first I pasted in works
IntoxicatedHippo has quit [Quit: Leaving]
<emekankurumeh[m]> it sounds like you are accessing inactive fields
<emekankurumeh[m]> if you want to change the active fields you have to reassign the whole variable
<emekankurumeh[m]> or use @unionInit
fengb has joined #zig
<nifker> I dont get it
<nifker> paste 1 compiles and did it like there but then it doesnt
<emekankurumeh[m]> are you on master?
very-mediocre1 has quit [Read error: Connection reset by peer]
<emekankurumeh[m]> i can't find that line in the paste anywhere.
very-mediocre has joined #zig
ibutra has joined #zig
Akuli has joined #zig
samtebbs has quit [Quit: leaving]
<emekankurumeh[m]> i mean the compiler_rt line
<nifker> this is from 0.4
<emekankurumeh[m]> ok
<emekankurumeh[m]> are you editing compiler_rt or is this an error from the std that comes shipped with 0.4.0
<nifker> it comes from there
darithorn has joined #zig
knebulae has quit [Read error: Connection reset by peer]
fengb has quit [Remote host closed the connection]
avoidr has joined #zig
<ibutra> I want to explore using zig for embedded development on an STM32f3 alongside the HAL which is written in c. This introduces some quiestions:
<ibutra> 1. do build for that target I have to build with.build-lib not build-exe?
<ibutra> If I build with build-exe the .text reagion (or all reagions for that matter) are empty, not so fo rbuild-lib. Could I just flash the built lib on the controller?
<ibutra> 2. Can I give the zig buildsystem a linker file where I define the memory layout and the layout in .text? This is crucial for stuff like interrupt tables
<nifker> 2. you can
<andrewrk> nifker, (looking at your earlier conversation) at this point I'd recommend master over 0.4
<emekankurumeh[m]> 1. can't you just specify in your linker script to keep the text section?
<andrewrk> ibutra, are you aware of `export` and `@export` in that they are necessary to generate symbols in the output object file?
<ibutra> nifker, thx I will look into that, it looks helpfull, actually the whole project does
<ibutra> I am not exactly sure what you mean with that. I want to try to build the whole project with the zig compiler including the c files so the elf will be created by zig, not just a library I want to use from c
very-mediocre has quit [Read error: Connection reset by peer]
<andrewrk> yes you can do that
<ibutra> But then I don't need export or do I?
<nifker> I guess I cant build never versions with an older version of zig
<andrewrk> build-exe is correct - let us figure out why the text region is empty
very-mediocre has joined #zig
<andrewrk> nifker, yeah, the project is still young and moving quickly, so that's one downside you'd have to put up with
<andrewrk> zig is still beta software; to build a non-trivial project in zig will probably mean participating in the development process of zig to some degree (at least by reporting bugs)
<ibutra> I started with a minimal example trying to build for thumbv7em-standalone-eabihf which is basically just a volatile pointer (so it doens't get optimized away) and some operations on it (additons mainly)
<ibutra> I am aware of that and not reluctant to participate :)
<ibutra> But looking at the disassembly now it seems maybe it was still optimized away, because all that is present in the lib file is <std.special.panic>
<ibutra> I guess I will implement something none trivial and report back.
<andrewrk> ibutra, have a look at https://godbolt.org/z/uI16ub
<andrewrk> try deleting the `export` keyword there
<andrewrk> you can see that zig no longer generates code for the function. zig has lazy analysis; anything not reachable from an exported function is not generated
fengb has joined #zig
<andrewrk> so make sure that your entry point (is it `_start`?) is exported
<nifker> compiling for thumbv7m works now 👍
<fengb> There's been major breaking changes since 0.4.0 release. We have a few more before 0.5.0 lands
<ibutra> Ah, I see, thank you! (it normally is _start, yes)
<fengb> andrewrk: I apparently know someone who works on Github Sponsor. I'm gonna see what can be done :P
<nifker> And how can I look at the std documentation?
<andrewrk> fengb, thanks!
<andrewrk> wow, this game is really fun already: https://github.com/thejoshwolfe/legend-of-swarkland (the "zig" branch)
jjido has joined #zig
<fengb> Oh? Based on the README I had assumed even the C++ version is pretty unfinished
<nifker> ok can I output as bin directly or do I need external tools?
marler8997 has joined #zig
lunamn_ has joined #zig
<scientes> Status
<scientes> Doesn't work.
<scientes> haha
<andrewrk> there's about 10 min of gameplay in the zig branch
<fengb> I've been staring at this code for 2 days trying to figure out why it doesn't work: `while (i < BG_TILES) : (i += 0) {`
<scientes> hehe
<andrewrk> omg I just saw it
<andrewrk> I was about to say "really? that looks pretty simple to me"
<andrewrk> nifker, build-exe will generate an ELF
<andrewrk> you want something different than that?
lunamn has quit [Ping timeout: 245 seconds]
<nifker> I mostly output to Intel HEX before
<andrewrk> I see. let me open an issue for this, because I have this same problem here: https://github.com/andrewrk/clashos/blob/3f786d4294c71f909b1ecaf3c8d0e247b90c5c86/build.zig#L32-L37
<Tetralux> Is .bin == .hex?
<andrewrk> I think those are different
darithorn has quit [Quit: Leaving]
<Tetralux> They sound different xD
<Tetralux> I missed the context for this
<Tetralux> But I too have wondered about writing code for MCUs.
<Tetralux> So being able to do that with Zig would be quite nice.
<Tetralux> The very little research I did told me I needed to upload .hex files to the chip.
<fengb> Looks like HEX is ASCII
<Tetralux> But I'm not familiar enough with them to know if you can actually upload non-dothex files.
<Tetralux> Maybe literally machine instructions but written as their hex sequences in ASCII?
<nifker> Both can be used to write them to the ROM
<fengb> Looks like it also has additional metadata: mostly some basic checksums to validate integrity
<Tetralux> nifker: As an aside, if you have resources you can link me to that explains that I'd appreciate it.
<andrewrk> the workaround for now is objcopy
<nifker> nice
<andrewrk> if we end up having to implement intel hex format, it could be done in .zig code
<scientes> yeah build-obj is always there if you want to use zig as a traditional compiler
<ibutra> where can i find the builtin file in the source tree? I am trying to figure out how to set the correct target in build.zig
<andrewrk> ibutra, `zig builtin` will print the source
<andrewrk> it's a generated file that depends on build parameters
<ibutra> alright, thx!
<andrewrk> ibutra, these docs might also help: https://ziglang.org/documentation/master/#union
redj has quit [Ping timeout: 258 seconds]
<ibutra> Thank you very much it is indeed helpful. Maybe I should actually read the whole documentation and not glance over the parts I thought I don't need right now :)
<fengb> I've got a controversial proposal: "automatic semicolon insertion" after a closing brace
<very-mediocre> If JavaScript is any indication, that's gonna be flaky
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<fengb> JS has too many permutations. I just want 1
<fengb> Is it worth writing up?
very-mediocre has quit [Read error: Connection reset by peer]
<fengb> Man, he rage quit :(
very-mediocre has joined #zig
<very-mediocre> I didn't rage quit :]
<very-mediocre> my internet is flaky
<very-mediocre> some edge cases come to mind, like inline array literals e.g. [_]u8{'x', 'y'}, if/while/for blocks
<fengb> Argh you're right
<very-mediocre> you can also have { } scoped blocks anywhere if you're so inclined
<very-mediocre> I wish we didn't have to label a block to break out of it with a value
<fengb> I wonder how that'd look with a different keyword
<fengb> I think "break :blk" and "break" are semantically different enough now
<fengb> Maybe rename the current "break" into "break loop"?
<fengb> Then a bare "break" can be block based
<very-mediocre> hm i'm not sure if you can break out of a while/for loop with a value, but if not, then it's not ambiguous
<very-mediocre> you could just do `const x = { ... break val; };
<fengb> I think loops can be expressions
<very-mediocre> maybe I am abnormal but I take forever trying to come up with variable names, especially for a disposable scope
<fengb> Everyone sucks at naming. Some people don't recognize it :P
<fengb> `incompatible types: 'u8' and 'void' — const foo = for (x) |a| {`
<fengb> I guess you can't make an expression
<andrewrk> the :blk thing is pretty unpopular. unfortunately people are too used to `break` applying to the innermost loop
<andrewrk> :blk exists because sometimes you need that level of control. and then I simply didn't add any shortcut syntax
<very-mediocre> yeah, there's no way around the labels for n>1 block depth
<fengb> It makes sense for nested loops. It's just a little awkward for blocks
<fengb> I think most languages just work around it by not allowing block breaking
<very-mediocre> I really like having a block evaluate to a single value though
<very-mediocre> it's so desirable JS people do inline self-invoking functions
<fengb> Yeah it's very natural. Especially with switches and stuff
<ibutra> How do I declare an array of strings? Or any multidimensional array for that matter?
<fengb> [N][]const u8
<ibutra> thx
<andrewrk> that's an array of slices, not a multi-dimensional array
<fengb> Oh right
<very-mediocre> if you're lazy you can do a struct that contains an array, for the 2nd dimension
<very-mediocre> easier to heap-allocate too
<ibutra> I want to tell the buildsystem all c files it should add and thought the easiest way is to have an array where I put all the paths in and then just iterate over it to addCSourceFile for everyone. In my mind that is an array of strings therefore an array of array
<very-mediocre> [n]SecondDimensionStruct
<fengb> Arrays are fixed size. Is your list known at compile time?
<ibutra> yes
<ibutra> I just want to save myself from having to type addCSourceFile for every file again :P
Ichorio has joined #zig
<very-mediocre> not sure if this is supposed to work in zig. I wrote `var x: [5][5]u8 = undefined; x[0][0] = 67;` and it compiled fine
<very-mediocre> can't test it rn as im in the middle of sthg
<andrewrk> uh that syntax needs to be updated to [_][]const u8 though
<ibutra> Thank you, the support here is outstanding!
<ibutra> ok I think I can do that ;)
<emekankurumeh[m]> you could even just have the file names and use `++` to append the dirname
<very-mediocre> andrewrk: dumb question: is that different from what fengb wrote earlier? how is that not an array of slices.
<andrewrk> very-mediocre, it is, but until the use case was explained we thought ibutra wanted a multi-dimensional array
<very-mediocre> ah, okay
<andrewrk> this is why I love use cases :)
<ibutra> yeah,
<ibutra> that's why i provided it, I figured there is probably an idiomatic way
lunamn has joined #zig
ibutra has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
lunamn_ has quit [Ping timeout: 248 seconds]
<andrewrk> zig fmt fixes whitespace now
<emekankurumeh[m]> andrewrk: that was fast
<very-mediocre> great, CRLF is an annoyance on windows
<andrewrk> emekankurumeh[m], thanks for the original PR, I wanted to just get it done and add a test, and move the switch cases to one line and not mess up the compiler_rt formatting
<fengb> I'm always confused when the irc name doesn't match the Github name
<hryx> thanks for knocking out the whitespace thing quickly emekankurumeh[m] and andrewrk. hopefully will result in less noise on IRC/github now
<fengb> Is this idiomatic for switching a nullable? `const addr = switch (cmp.active() orelse return null) {`
<fengb> Feels super weird to have orelse return null squeezed in the middle
<andrewrk> fengb, it looks good to me
<fengb> Sounds good
<Tetralux> I have a slightly related question: You can do `if (optional) |value| { ... }` -- can you do `if (!optional) return;` ?
<andrewrk> Tetralux, const payload = optional orelse return;
ltr- has joined #zig
<Tetralux> andrewrk, Yeah - Figured. Just wondered if there was a way to check it without assigning it to something.
<andrewrk> if (optional == null) return;
<Tetralux> Oh of course! xD
<scientes> well it is special in the compiler
<scientes> null is its own type
very-mediocre has quit [Read error: Connection reset by peer]
very-mediocre1 has joined #zig
<Tetralux> I was curious about how `if (!optional) return` does not work, but `if (optional == null) return` _does_ work
<fengb> Not operator only works on bools
<very-mediocre1> I guess optionals do not evaluate to booleans
very-mediocre1 is now known as very-mediocre
<hryx> nothing casts to boolean (I think)
<scientes> not even u1
<very-mediocre> I guess the if statement unwrap is like the "if the unwrap is successful" boolean
<andrewrk> if-optional is separate syntax
<Tetralux> Zig borrowing from C# over here :P
<andrewrk> ideas are cheap. implementation is hard work
<very-mediocre> also it's easy not to see massive problems with ideas when you're not knee-deep in implementation-land
<very-mediocre> I keep doing that.
<Tetralux> Why'dya think I was asking? ;P
<Tetralux> I'm curious about why's and why nots in things.
laaron has quit [Remote host closed the connection]
laaron has joined #zig
<Tetralux> Though I am curious what makes that one hard.
<very-mediocre> re:allocator pattern - at what point should I stop exposing an allocator param and just decide on one?
<andrewrk> very-mediocre, in your main() function
<very-mediocre> say I have a component I really really want people to use an ArenaAllocator for
<andrewrk> yeah then your component should probably make an arena allocator. the self hosted parser does that
<very-mediocre> okay
<very-mediocre> specifically I've got a bunch of tree nodes on the heap and deallocating with traversal would be a pain, and the tree itself shouldn't be seen by the library consumer anyway...
marler899749 has joined #zig
<marler899749> I just noticed that zig seems to be completely statically compiled. Doesn't even use a dynamc loader as an interpreter
<marler899749> makes sense for a self-contained downloadable compiler....will zig use dynamic linking when it's a package in a package manager?
<Tetralux> I'm not entirely clear what you mean, but I doubt it.
<andrewrk> marler8997, yes it will follow the system guidelines
<marler899749> ok makes sense. I like that it's statically compiled when you just download it. Then you only need one version
<Tetralux> Oh - by package manager you mean like apt etc?
<andrewrk> yes
<Tetralux> Okay - that makes sense then xD
<Tetralux> I read it as "_the_ package manager".
<Tetralux> Oops.
<fengb> very-mediocre: if it's not exposed, you can pass around the arena internally, but the entry function should take the underlying allocator for creating the arena
<very-mediocre> noted
<andrewrk> there's a plan to make it possible to detect whether an allocator is already an arena: https://github.com/ziglang/zig/issues/2292
<andrewrk> (not just type-matching, but in a semantically meaningful way)
<andrewrk> basically allocator implementations could specify that free() does nothing, and you could query this
<very-mediocre> right, looks good
<hryx> andrewrk: purely just curious, what don't you like about the @cast(T, x) syntax? I reread the thread but couldn't see the flaw in it
<andrewrk> hryx, @cast is actually not bad. I think it would be worth looking at the std lib diff for that
<hryx> ah you mean like, is it gonna be too verbose or hard to read if it's everywhere?
lunamn has quit [Ping timeout: 248 seconds]
<scientes> hryx, what is the issue #?
<andrewrk> hryx, right
<scientes> that makes the @shuffle that I introduced woorse. because its best to use ~ to do indexes from the second vector, and you can't do ~ on comptime_int
<scientes> (which was rejected)
<fengb> Do it the C way and put parens around the type :P
<scientes> yeah that would work too
<scientes> I have the feeling that it would be confusing that @cast can only do implicit casts, which it looks pretty explicit (but that is already a difference from C)
<fengb> Does this mean we'll have @cast _and_ @intCast? That feels super weird to me
<gamester> Don't some languages do this to specify literal types? 1234'i32, 45.5'f32
<gamester> Maybe they don't, but I find it short and simple
<fengb> Oh I see (after rereading)
<hryx> fengb: it's not settled yet. maybe @cast would replace @intCast
<hryx> if I understand correctly
<fengb> I like @cast to replace @intCast... but I feel like it could be a bit much for @ptrCast
<hryx> do they deserve different builtins? if so maybe @scalarCast and @ptrCast or something
<fengb> I guess technically @ptrCast is non-destructive so that might be a better candidate?
<fengb> intCast definitely changes the internal representation
<fengb> (And floatCast)
<hryx> oh cool, maybe it could be separated by lossy/not. like @cast and @lossyConvert
SimonNa has joined #zig
<Tetralux> If we had @cast, I'd expect it to be a combination of @intCast, @floatCast, and @ptrCast - so that seems bad considering that we have those already.
<emekankurumeh[m]> i think `_` in number literals would be a nice thing in zig
<hryx> Tetralux: you could propose to replace them. I sure they're not sacred or set in stone
wootehfoot has joined #zig
<hryx> emekankurumeh[m]: wasn't that already rejected?
<emekankurumeh[m]> was it?
<hryx> oh jeez, I think I'm remembering a golang/go proposal
<andrewrk> fengb, @intCast asserts; implicit casting integers never asserts
<Tetralux> I'd like '_' in Zig personally.
<Tetralux> (for num literals)
<Tetralux> esp. for large numbers.
<hryx> thanks. perhaps my memory sort of still works
<Tetralux> Yeah - the whole "you could write 100_00_00" argument - I don't buy that; I'd rather be able to write 1_000_000 than not.
fengb has quit [Ping timeout: 260 seconds]
<Tetralux> I buy the "but 100000" means the same thing in regardless of where you are"
<Tetralux> Don't buy that either.
<Tetralux> You don't read the underscores.
<Tetralux> They're there for clarity when reading/writing the number.
<Tetralux> It has the same number of digits regardless of what you do
<Tetralux> Just as when writing a number with a pen.
<Tetralux> (100_00_00 == 1,000,000)
<Tetralux> You may have written the underscores that way because the last four digits in the number you are writing means something special in your code.
<Tetralux> I'm definitely not writing (v1 << 24) | (v2 << 16) | (v3 << 8) | (v4 << 0) - that's for sure.
<Tetralux> I don't buy the "but 100000" means... *
<Tetralux> Interestingly--though I don't know about you--but to me, "1000000" is harder to read than "100_00_00"
<Tetralux> Not by much mind.
<Tetralux> Whereas 1_000_000 is positively amazing by comparison.
<emekankurumeh[m]> we could allow those and have zig fmt enforce one formatting method?
very-mediocre has quit [Read error: Connection reset by peer]
<Tetralux> That would destroy any meaning in where you put the underscores though.
very-mediocre has joined #zig
<Tetralux> Maybe that doesn't matter though /shrug
<very-mediocre> what's your use case for not grouping by 3 digits
<very-mediocre> i can see 2 nibbles for hex
<Tetralux> Isn't the burden a positive one? Why would you limit it?
<very-mediocre> only thing i can think of for decimal is using an int as a bit array
<very-mediocre> er
<Tetralux> Maybe you only care about seperating millions.
<very-mediocre> I dunno, if there are not conceivable use cases then zig fmt would make things easier
<Tetralux> (..For that particular literal.)
<Tetralux> Maybe only ten thousands.
<Tetralux> Indeed
<Tetralux> For hex
fengb has joined #zig
<Tetralux> 0x11_22_33_44__55_66_77_88
<Tetralux> (Note the double '_' in the middle)
<ltr-> is going to be posible to do this in the future? : for(buf) functionDeclaredElsewere; ??
ntgg has joined #zig
<fengb> I think since we're bickering about what is better, having it be simple is the best approach :P
<Tetralux> Meaning `for(buf) |x| functionDeclaredElsewhere(x)` ?
<ltr-> oh you can omit the {
<Tetralux> fengb, I'd argue "simple" is just "underscores are allowed in indents"
<fengb> Simple to compiler/parser
<Tetralux> ltr-, I believe so.
<Tetralux> fengb, Sounds simple to me.
<fengb> And language since there's less to define
<ltr-> Tetralux: yes you can omit them
<Tetralux> I've even written a parser which parsed underscores in idents; just skip any underscores, done.
<Tetralux> in numbers*
<fengb> I'm not saying it's complicated... but it takes a bit more work to support and we're back to bickering about what's better
<very-mediocre> i don't know that any of this stuff is bickering
<Tetralux> I mean... "A bit more work" is a bit of a stretch since you're checking if the char is a digit anyway xD
<ntgg> underscores in numbers makes it much more readable
<Tetralux> You literally just check for one other char while you're at it.
<Tetralux> I'm struggling to think of anything simplier XD
<fengb> n + 1 > n
<Tetralux> simpler*
<fengb> nvm
<fengb> Forget I said anything
<Tetralux> hahaha
<Tetralux> I also don't use `zig fmt` so... /shrug.
<very-mediocre> Really? I adore beautifiers, can type abominable code and have it get fixed automatically
<hryx> Tetralux: if this is important to you, I suggest formatting a chunk of stdlib the way you want and link to it so that people can visualize the difference
<hryx> keeping in mind that the proposal has already been rejected in the past
<fengb> I can't *not* use zig fmt because andrewrk added it to Vim
<Tetralux> fengb, I'm choosing to ignore that example. ;)
<Tetralux> fengb, Though I don't really use Vim for editing that much so :p
<Tetralux> very-mediocre, I don't use them because I usually write code in the way I want for a reason - I don't need a 'beautifier' to undo it all.
<Tetralux> I'm not sure a uniform way to format code even matters at all.
<Tetralux> _except_
<Tetralux> For being able to write sloppily and not care because it'll fmt it.
<Tetralux> But... /shrug.
<very-mediocre> I find it relieving to just write awkward stuff really really fast
<Tetralux> In my experience, it's a little hard to write code _that_ sloppily.
<fengb> Tetralux: check out the Go ecosystem
<fengb> And try doing autoformatting for a week
<Tetralux> fengb, That's how I found I hate them xD
<fengb> I hated it my first 2 days
<fengb> Then I started to ignore it
<fengb> And then I loved it
<very-mediocre> Tetralux: do you hit the space bar 4n times for indentation?
<fengb> So much of my life has been wasted by bickering about tabs, trailing commas, etc.
<Tetralux> Nope - Tab once = 4 spaces.
<Tetralux> If I did have to do 4 spaces (like I have to in Vim) , I'd either not be a programmer, use hard tabs, or my idents would be 1 space.
<fengb> I still don't like the Go format style, but it's so much better than everyone having their own style
<Tetralux> Like - the one place I'd find the beautifier useful is when you want to put fn args onto their own lines.
<Tetralux> But I can do that already by going to the ',' and multi-cursoring those things.
<fengb> That's not the pont
<Tetralux> No it isn't xD
<fengb> It's not for you reading your own code
<Tetralux> Give me an example of badly written Zig code that you couldn't read.
<fengb> It's not even about badly written
<Tetralux> "badly written" = "badly formatted"
<fengb> Have you ever hopped on a project where someone yells at you "hey turn off tabs"
<fengb> Or "braces go on a different line"
<fengb> Or "add a space between opening function calls"
knebulae has joined #zig
<fengb> Or a dozen different idiosyncracies that are slightly off from what you're used to
<Tetralux> I'd argue that if that is important to a project, that they should have a formatter that runs on commits.
<fengb> Exactly, that's why zig fmt exists
<fengb> But instead of project based, it's language based
<very-mediocre> imho zig fmt nails the coding style, and i'm very happy that it handles things smartly, e.g. preserves 1-liners, or breaks up an array declaration into multiple lines only if you have a comma after the last element...
<Tetralux> If your style is basically what it does anyway, then I can see why you might like it.
<Tetralux> That thing about "leave a comma after the last element" -- that's useful.
<fengb> I don't agree with everything zig fmt does, but I agree enough that I'd rather not argue about it
<Tetralux> That's the example I had in my mind when I said about multi-cursoring things.
<fengb> (Although I thing zig fmt is better than Go :P)
<Tetralux> Personally, I'd rather just not have the extra work of having to deal with potential bugs in something I don't need.
<Tetralux> Simpler my workflow is the better.
<very-mediocre> well it uses the AST as a source of truth, not much room for "serious" bugs
<fengb> It's the same parser (or it will be in stage2)
<Tetralux> > It's the same parser
<Tetralux> The reading part, I assume you mean.
<Tetralux> Well - maybe not - because of `zig builtin`.
Ichorio has quit [Ping timeout: 250 seconds]
<Tetralux> Or does that use `zig fmt` to render it?
<Tetralux> I imagine it does actually.
<emekankurumeh[m]> i'm starting to have a growing hatred of windows
<Tetralux> hehe
<Tetralux> Sounds about right.
<Tetralux> Personally, I suspect I'd prefer it if OSes were little more than hypervisors.
<Tetralux> And programs were little more than just pure x64 code that the hv brokered the actual execution of.
<Tetralux> more/less.
<Tetralux> Like - I dunno - but the idea seems worthy of exploration at least.
very-mediocre has left #zig [#zig]
cheesy has joined #zig
brakmic has quit [Read error: Connection reset by peer]
cheesy has quit [Client Quit]
brakmic has joined #zig
jjido has joined #zig
Akuli has quit [Quit: Leaving]
kristoff_it has joined #zig
<fengb> andrewrk: the compiler is crashing *only* when I do release-safe, fast/small/debug all work. Is this a known problem?
kristoff_it has quit [Ping timeout: 244 seconds]
Flaminator has quit [Disconnected by services]
darithorn has joined #zig
brakmic has quit []
<andrewrk> fengb, no - would you mind filing an issue?
<fengb> Sure
SimonNa has quit [Remote host closed the connection]
<fengb> I feel like all I ever do is complain about bugs :/
<Tetralux> That is a good thing xD
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]