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/
ur5us has quit [Ping timeout: 260 seconds]
frmdstryr has joined #zig
<frmdstryr> Is there a ring buffer / circular queue anywhere in the std lib?
<daurnimator> std.LinearFifo
dermetfan has quit [Ping timeout: 260 seconds]
stripedpajamas has quit [Quit: sleeping...]
dermetfan has joined #zig
r4pr0n has quit [Quit: r4pr0n]
<frmdstryr> That should work, thanks!
dermetfan has quit [Ping timeout: 246 seconds]
fraktor is now known as Guest84333
Guest84333 has quit [Ping timeout: 246 seconds]
<pixelherodev> LinearFifo = :)
<pixelherodev> Is there a way to check `if (@TypeOf(val) == tuple`?
doublex has quit [Read error: Connection reset by peer]
doublex_ has joined #zig
doublex_ has quit [Read error: Connection reset by peer]
doublex has joined #zig
nephele_ has joined #zig
nephele has quit [Ping timeout: 256 seconds]
nephele_ is now known as nephele
doublex has quit [Ping timeout: 260 seconds]
aerona has joined #zig
_Vi has quit [Ping timeout: 260 seconds]
doublex has joined #zig
doublex has quit [Ping timeout: 272 seconds]
bjornroberg has quit [Quit: leaving]
doublex has joined #zig
<leeward> whee, fixing comments and examples
<leeward> and writing the world's worst program
<leeward> ported https://github.com/nmichaels/pycrash to zig...no idea why
doublex has quit [Ping timeout: 256 seconds]
<pixelherodev> leeward: pycrash?
<leeward> Yeah, it looks like a Python interpreter, but gives a SyntaxError for everything you do.
<fengb> Ah... like a modern ed
<leeward> A terrible program, with no value to anyone, and for some reason it now has a Zig version.
<pixelherodev> So... a fake Zig compiler?
<leeward> Well, I know the reason. It's so I can easily build for MacOS and Windows.
<pixelherodev> Or you ported the Python fake *interpreter* to Zig?
<leeward> No, it's still a fake Python compiler.
<pixelherodev> lol
<leeward> er, interpreter
<pixelherodev> nice
<leeward> I put it on a coworker's computer on April 1st of last year. It was a pretty good day.
<pixelherodev> lol
<pixelherodev> nice
<pixelherodev> I love it
<pixelherodev> link me?
<leeward> To what?
<leeward> You want the Zig implementation?
doublex has joined #zig
<pixelherodev> Yeah :P
<pixelherodev> "Here, I made a smaller Python implementation; enjoy!"
<pixelherodev> "It's a static windows build with all of the standard libraries embedded in a compressed form!"
<leeward> That's what it looks like at the moment. I wouldn't call it good, but it mostly works.
<leeward> cPython: 5.3M. My Python: 412k
<pixelherodev> Haha
<pixelherodev> I love it
<leeward> Hmm, on a mac I get "Spmbol not found: __tlv_bootstrap"
<leeward> er, symbol
<pixelherodev> I'm totally posting that around now ;)
<leeward> hah
<leeward> oh, looks like I ran into 5067
<leeward> cool
<pixelherodev> Yay, bugs
<pixelherodev> size is down to 200k with --release-smal
<pixelherodev> :)
stripedpajamas has joined #zig
dddddd has quit [Ping timeout: 264 seconds]
layneson has joined #zig
layneson has quit [Ping timeout: 246 seconds]
jicksaw has quit [Quit: ZNC is kill]
jicksaw has joined #zig
wozeparrot__ has quit [Ping timeout: 246 seconds]
satchmo has quit [Ping timeout: 260 seconds]
dimenus has quit [Ping timeout: 272 seconds]
waleee-cl has quit [Quit: Connection closed for inactivity]
<marler8997> how would I convert an int to an enum, but detect if it is not a valid value of that enum and take a different codepath?
<pixelherodev> hmm... good question
<pixelherodev> You really just need a way to check `if (int_valid_enum_value)`
<pixelherodev> Did you check std.meta?
<marler8997> no, I'll check
<pixelherodev> That's where I'd expect such a function to be
<aerona> there's intToEnum in std.meta
<marler8997> ah yes, that works
<pixelherodev> Yeah, that's it
<pixelherodev> You'd want something like `if (std.meta.intToEnum(T, val)) |e| { } else {}`
aerona has quit [Quit: Leaving]
_whitelogger has joined #zig
stripedpajamas has quit [Quit: sleeping...]
Invader_Bork has joined #zig
opDispatch has quit [Quit: Konversation terminated!]
stripedpajamas has joined #zig
ATP7 has joined #zig
greenfork has joined #zig
ATP7 has quit [Client Quit]
st4ll1 has quit [Quit: WeeChat 2.8]
stripedpajamas has quit [Quit: sleeping...]
tdc has joined #zig
<greenfork> how do I check if computation is during runtime or comptime? e.g. when is this executed: "GET".len
dermetfan has joined #zig
<daurnimator> greenfork: unless you have a `comptime` in front, you don't know
<greenfork> okay, thanks
neceve has joined #zig
dermetfan has quit [Quit: WeeChat 2.7.1]
FireFox317 has joined #zig
wootehfoot has joined #zig
ur5us has joined #zig
wootehfoot has quit [Read error: Connection reset by peer]
xackus_ has joined #zig
r4pr0n has joined #zig
dddddd has joined #zig
_whitelogger has joined #zig
<pixelherodev> Valuable lesson learned today: if the path changes, zig-cache needs to be wiped
<pixelherodev> `could not find build.zig: /old/path/build.zig not found`
<pixelherodev> Rather
<pixelherodev> `unable to open /old/path/build.zig : file not found`
_whitelogger has joined #zig
<ikskuh> yep
ur5us has quit [Ping timeout: 260 seconds]
mokafolio has quit [Remote host closed the connection]
mokafolio has joined #zig
riba has joined #zig
r4pr0n has quit [Remote host closed the connection]
riba has quit [Ping timeout: 272 seconds]
_whitelogger has joined #zig
_Vi has joined #zig
r4pr0n has joined #zig
kristoff_it has joined #zig
lanodan has quit [Read error: Connection reset by peer]
lanodan has joined #zig
bjornroberg has joined #zig
dingenskirchen has quit [Quit: dingenskirchen]
dingenskirchen has joined #zig
bheads has joined #zig
riba has joined #zig
Aransentin has joined #zig
<Aransentin> Is it just me or is latest Zig release broken wrt. `io_mode = .evented;`? `zig run test.zig` on this simple file fails with "Instruction does not dominate all uses!": https://pastebin.com/raw/SXQkDEMw
Akuli has joined #zig
riba has quit [Ping timeout: 272 seconds]
alexnask has joined #zig
wozeparrot__ has joined #zig
<andrewrk> ah, I've been meaning to set up CI test coverage for evented I/O
decentpenguin has joined #zig
<blueberrypie> is the zig meetup is happening in an hour right?
mokafolio has quit [Ping timeout: 260 seconds]
<andrewrk> yes
Michcioperz has joined #zig
<wilsonk> andrewrk: update for you and any others that were asking the other day. I have added a new store for merchandise with the new logo designs (as well as new zero, ziggy and a few zigfast items <<-- ifreund). Check the new link at the https://github.com/ziglang/zig/wiki/community#merchandise
<fengb> Awesome 🥳
<andrewrk> thank you wilsonk! it's been really nice having you manage the store so that I can focus on other things <3
<alexnask> wilsonk, tyty
<wilsonk> no problems
dingenskirchen has quit [Quit: dingenskirchen]
dingenskirchen has joined #zig
<ifreund> wilsonk: this is awesome, thank you!
<wilsonk> my daughter (who actually did all the changes to earn a few bucks from me since she lost her job in this climate) thinks that zigfast is her spirit animal :) I will probably order a sample of one zigfast item for her to see how it looks.
antaoiseach has joined #zig
<andrewrk> haha I love that zigfast made it in there
<marler8997> I'd like to be able to use std.fs.path.join to create a pathname that needs to be available at comptime
<marler8997> I wrote my own that puts "comptime" as a parameter modifier on the "paths" array, but that means it can't be used at runtime
<marler8997> And the one in std.fs.path requires an allocator
<marler8997> I wonder if we could make join work at compile-time by having some sort of comptime allocator?
<marler8997> @ctAllocator() or something
<marler8997> or better yet, just create the allocator primitives such as @comptimeRealloc(..) and @comptimeShrink(...), then we can create an Allocator type that calls them, so then the details of mem.Allocator don't get into the language
antaoiseach has quit [Quit: leaving]
<andrewrk> marler8997, you can use a ++ fs.path.sep_str ++ b
<andrewrk> it's pretty cumbersome but you could possibly create a helper function or alias or something
<marler8997> right, but I want to use the standard library implementation instead of my own
<marler8997> this comment looks eerily similar to what I just described :) https://github.com/ziglang/zig/issues/1291#issuecomment-526243360
<squeek502> zig virtual meetup starting soon: https://www.twitch.tv/kristoff_it
dimenus has joined #zig
wozeparrot__ has quit [Quit: Leaving]
<andrewrk> it's starting now
decentpenguin has quit [Quit: decentpenguin]
ifreund has quit [Quit: WeeChat 2.8]
ifreund has joined #zig
jfo has joined #zig
FireFox317 has quit [Ping timeout: 265 seconds]
xentec has quit [Ping timeout: 260 seconds]
<andrewrk> kristoff_it, Q for fengb: What's the #1 issue in Zig that you would like to see addressed which would help FUN+DUDE?
<dimenus> how would i iterate over std.builtin.StructFields at runtime?
<andrewrk> dimenus, you would create an array at comptime, then iterate over that array at runtime
<alexnask> StructField is a comptime only type though I believe
<dimenus> yeah that's my challenge here, basically i'm trying to debug offset issues
<dimenus> the goal is to just print out all of the struct fields and their offsets
<alexnask> If you only want to print stuff you should be able to `inline for` over the fields and do your `std.debug.warn`s in there
lanodan has quit [Ping timeout: 272 seconds]
<dimenus> alexnask: inline for works, thanks for the tip
<dimenus> also i'm not sure i know how to create an array at comptime yet
lanodan has joined #zig
craigo has joined #zig
<alexnask> dimenus, `const array = [_]T { T{...}, T{...}, T{...} };` this is comptime if all the things inside are comptime
<dimenus> alexnask: i should clarify, i'm not quite sure what Andrew is referring to. How would i create a comptime array of something the compiler hasn't figured out yet?
metaterically has joined #zig
waleee-cl has joined #zig
<greenfork> how do I convert `*[8000]u8` to `*[]const u8`? I've read that it's possible to convert `var` type to `const` and tried `@as` with no success
<BaroqueLarouche> greenfork: does `my_array[0..]` does the trick ?
<greenfork> BaroqueLarouche: no, it still complains
<andrewrk> dimenus, const foo = comptime blk: { ...; break :blk foo};
wootehfoot has joined #zig
Invader__Bork has joined #zig
<andrewrk> greenfork, are you sure you want `*[]const u8`? that's a double pointer
<dimenus> andrewrk: thanks
<andrewrk> you can already coerce *[8000]u8 to []const u8, without any casting builtins
<greenfork> expected type '*std.io.fixed_buffer_stream.FixedBufferStream([]const u8)', found 'std.io.fixed_buffer_stream.FixedBufferStream([]u8)'
<greenfork> when I try to construct this fixed buffer with an array type it complains that the type is not correct
<greenfork> this error comes from a function where I require this buffer to be of u8 type
<greenfork> I should probably make a code snippet
<alexnask> That would be helpful :)
Invader_Bork has quit [Ping timeout: 272 seconds]
<fengb> greenfork: it's because you're trying to pass a const slice into a mutable one
<greenfork> fengb: I've also tried the other way around, I will make a correct snippet :)
Aransentin has quit [Remote host closed the connection]
Aransentin has joined #zig
lanodan has quit [Read error: Connection reset by peer]
<dimenus> comptime is so awesome, i'm glad stuff like this works: https://bpa.st/Y3JQ
<dimenus> a generic function for pulling objects off the wire and byte swapping specific fields
lanodan has joined #zig
_whitelogger has joined #zig
decentpenguin has joined #zig
fraktor has joined #zig
reductum has joined #zig
<karrick> @kristoff_it Awesome show!
<fengb> +1
<greenfork> yeah, thanks!
<karrick> Yeah, and the speakers, thank you so much for putting yourselves in the spotlight!
<karrick> You guys inspire me to start doing something Zig
<pixelherodev> I haven't seen it yes, but I'm sure you all did a great job!
<pixelherodev> yet*
<karrick> I want to get river running on my box now.
<ikskuh> ifreund: nice talk!
dottedmag has quit [Quit: QUIT]
<ifreund> ikskuh: thanks!
<ifreund> karrick: if you run into any issues let me know :)
satchmo has joined #zig
dottedmag has joined #zig
<kristoff_it> karrick: thanks!
drewr has joined #zig
wootehfoot has quit [Ping timeout: 246 seconds]
decentpenguin has quit [Quit: decentpenguin]
satchmo has quit [Ping timeout: 260 seconds]
greenfork has quit [Ping timeout: 264 seconds]
metaterically has quit [Remote host closed the connection]
<Aransentin> Here's an optimization for ArenaAllocator that somebody more skilled than me might want to implement:
<Aransentin> As it is, when running ArenaAllocator over page_allocator it initially very wastefully creates memory areas smaller than the page size; i.e. the OS returns a full 4KiB page but it only uses the first few bytes, and when those are used up it requestsan entirely new page.
<Aransentin> Maybe if ArenaAllocator can "know" that it's running over page_allocator you can add a special case for it
jfo has quit [Ping timeout: 240 seconds]
<fengb> There’s an issue to allow for in place resizing
<fengb> So once that’s done, the first expand will just resize into the page
mokafolio has joined #zig
<Aransentin> Ah, that'd solve it, yes
mokafolio has quit [Remote host closed the connection]
mokafolio has joined #zig
tdc has quit [Ping timeout: 246 seconds]
<pixelherodev> You could also do e.g. arena over FBA over page allocator
<pixelherodev> Or a custom FBA-like that grows when it runs out of space
Akuli has quit [Quit: Leaving]
slowtyper has quit [Ping timeout: 246 seconds]
Invader__Bork has quit [Ping timeout: 264 seconds]
data-man has joined #zig
<data-man> Hello everyone! Is there any Sublime Text users?
<pixelherodev> probably
dingenskirchen has quit [Quit: dingenskirchen]
dingenskirchen has joined #zig
wootehfoot has joined #zig
<ikskuh> hmm
<ikskuh> does anyone else also see the need for a library that wraps all primitive types with operators into a struct that provides functions like add, sub, wrappingAdd, mulWithOverflow, ...?
cole-h has quit [Quit: Goodbye]
cole-h has joined #zig
<gonz_> Heh
<ikskuh> it would be a good base for arithmetic-type-agnostic libraries
<gonz_> Someone flamebaited r/haskell with a video where andrewrk said you can't write perfect software in lots of languages, Haskell included.
<pixelherodev> Nah
<pixelherodev> I mean, I don't see the need for such a library
<pixelherodev> That just seems like unnecessary abstraction to me
<ikskuh> pixelherodev:
<ikskuh> then tell me how i should write a type-agnostic library eg for linear algebra
<ikskuh> i have actual use case for that and i don't want to write the library twice
<ikskuh> once for custom types, once for builtin types
<alexnask> gonz_, lol that sounds hilarious, link? :D
<gonz_> ikskuh: If I need this my go-to way is to have a function that generates an interface from a specification given to it, matching the types I want to use.
<gonz_> You can generate it at comptime and it'll be normal calls
<ikskuh> so the only way i can see that working without operator overloading is inversing the process
<alexnask> nvm Ill go get it myself and stop being lazy >.>
<pixelherodev> ikskuh: what's the use case for built-in types?
<pixelherodev> s/built-in/custom
<pixelherodev> Sorry
<pixelherodev> brainfart
<ikskuh> fixed-point arith or similar
<ikskuh> i use them a lot on embedded HW instead of fp32
<pixelherodev> Maybe try to get fixed point into the language, instead?
<ikskuh> and every other custom-arithmetic type?
<pixelherodev> Such as?
<pixelherodev> The problem with custom types in such a scenario is you can't guarantee their behavior
<pixelherodev> What if add() behaves differently from what you expect?
<ikskuh> this is a type i may want to use in my next embedded demo
jamii has joined #zig
<ikskuh> gonz_: yeah, that still doesn't change the fact that one has to write such a wrapper for primitive types
<jamii> Does anyone know how to pass '-fsanitize=fuzzer' to clang?
<gonz_> You can provide the interfaces for the types you can think of, people have the opportunity to rewrite them and provide the ones you don't
data-man has quit [Quit: Konversation terminated!]
<jamii> I tried `-mllvm -fsanitize=fuzzer` but it gives me `Unknown command line argument '-fsanitize=fuzzer'. Try: 'zig (LLVM option parsing) --help'`
<ikskuh> problem with the function pointer struct is probably that you cannot force-inline the functions?
<gonz_> I dunno, it doesn't seem reasonable to me to expect code generic over everything without the work being done somewhere, and the caller will always know more than you do about what's good anyway.
<pixelherodev> Inttteresting
<gonz_> So the caller is the person most qualified to supply the actual difference.
<gonz_> `comptime` ensures that it's a call like any other, at the very least.
<ikskuh> gonz_: i'm only taking about arithmetic types atm
<alexnask> Its passed as comptime everywhere so it should be inlinable
<gonz_> As in a fastcall
<gonz_> I checked the assembly for this program to ensure it
<gonz_> What you get is the same code you would as if it was written with whatever your type T was from the beginning
<alexnask> You can even use .always_inline with comptime fn type values
<ikskuh> ah right
<gonz_> There were issues with error sets, though.
<ikskuh> no problem in my case
<gonz_> it couldn't infer them, etc., so I ended up having to nail them down
<gonz_> If you had a bigger set of operations AFAIK you could extend this to return an interface as well
<gonz_> Though I'm not sure how much I'd use that.
<ikskuh> i can send you the list of the operations, if you want :D
<ikskuh> everything in here is of interest as long as it's arithmetic
<ikskuh> no "++", "**", "orelse", ".*", ".?", "and", "or", "!", "catch", "||"
<ikskuh> rest is in scope of the thing i'm thinking about
<gonz_> I guess the time is ripe for experimentation. Whatever you try out and how it looks, highlight me when you've checked it out.
<gonz_> I will always be a bit curious how people end up approaching generic code in Zig because the user base is likely very diverse in terms of languages used before.
<gonz_> I ended up doing this because it's basically first class modules from OCaml, or exactly what the Haskell compiler does when it passes type class dictionaries into generic functions with constraints/type classes.
<gonz_> `add :: Num a => a -> a -> a` will in reality be a function that takes a `Num` dictionary of numeric functions as a first argument, then the rest.
aerona has joined #zig
<gonz_> This all gets magically and massively inlined
<gonz_> https://www.youtube.com/playlist?list=PLEQTpgQ9eFCHaIFBIjB4NN_8rndMYuxmT <- A series of lectures by Simon Peyton-Jones about this, among other things.
wootehfoot has quit [Read error: Connection reset by peer]
<ikskuh> gonz_: basic idea was pretty much this: https://bpa.st/OLXA
satchmo has joined #zig
reductum has quit [Quit: WeeChat 2.8]
reductum has joined #zig
<hspak> Is there a way to force a `defer` to trigger at the end of the function instead of at the end of the block if it was called inside a while loop for instance?
<ikskuh> no
stripedpajamas has joined #zig
neceve has quit [Ping timeout: 240 seconds]
jamii has quit [Remote host closed the connection]
r4pr0n has quit [Ping timeout: 240 seconds]
alexnask has quit [Quit: Leaving]
st4ll1 has joined #zig
dimenus has quit [Quit: WeeChat 2.8]
_Vi has quit [Ping timeout: 246 seconds]
alexnask has joined #zig
stripedpajamas has quit [Quit: sleeping...]
frmdstryr has quit [Ping timeout: 272 seconds]
DpEpsilon_t has joined #zig
<gonz_> ikskuh: How does the call-site and function look?
<gonz_> s/function/function using this
klltkr has joined #zig
mokafolio has quit [Remote host closed the connection]