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/
<Cadey> Xavi92: look up the bring your own OS support
dingenskirchen has quit [Remote host closed the connection]
dingenskirchen has joined #zig
doublex_ has quit [Ping timeout: 260 seconds]
doublex has joined #zig
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 quit [Ping timeout: 246 seconds]
doublex has quit [Read error: Connection reset by peer]
doublex has joined #zig
nephele has joined #zig
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
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
doublex_ has joined #zig
doublex has quit [Read error: Connection reset by peer]
doublex_ has quit [Read error: Connection reset by peer]
doublex has joined #zig
doublex has quit [Read error: Connection reset by peer]
ifreund has quit [Ping timeout: 265 seconds]
doublex has joined #zig
doublex has quit [Ping timeout: 272 seconds]
dingenskirchen1 has joined #zig
dingenskirchen has quit [Ping timeout: 260 seconds]
dingenskirchen1 is now known as dingenskirchen
aerona has joined #zig
doublex has joined #zig
_Vi has quit [Ping timeout: 246 seconds]
daex has quit [Ping timeout: 260 seconds]
daex has joined #zig
Xavi92 has quit [Quit: https://quassel-irc.org - Chat comfortably. Anywhere.]
dingenskirchen has quit [Remote host closed the connection]
dingenskirchen has joined #zig
fraktor has joined #zig
waleee-cl has quit [Quit: Connection closed for inactivity]
stripedpajamas has joined #zig
stripedpajamas has quit [Client Quit]
dddddd has quit [Ping timeout: 256 seconds]
_whitelogger has joined #zig
benjif has quit [Ping timeout: 246 seconds]
dingenskirchen has quit [Remote host closed the connection]
dingenskirchen has joined #zig
aerona has quit [Quit: Leaving]
_whitelogger has joined #zig
ur5us has joined #zig
ur5us has quit [Ping timeout: 246 seconds]
daex has quit [Ping timeout: 246 seconds]
daex_ has joined #zig
cole-h has quit [Quit: Goodbye]
<pixelherodev> andrewrk: you're brilliant
<pixelherodev> Context: using disassembler to verify codegen
<pixelherodev> *Genius*.
<pixelherodev> Modified my codegen to emit `.org` and `.byte RAW_MACHINE_CODE_HERE` for easy copy+paste debugging
xackus has joined #zig
ur5us has joined #zig
<scientes> wow, this is ridiculous, and this is even musl https://gist.github.com/shawnl/3b8694960f6537f480c11c387c9847ef
dddddd has joined #zig
ur5us has quit [Ping timeout: 260 seconds]
ifreund has joined #zig
neceve_ has joined #zig
<ifreund> ugh, i hate gui toolkits. Trying to add support for river to waybar and gtk is being a royal pain
<ifreund> i mean, mostly cause I don't know what I'm doing, but man this stuff is overcomplex
<ttmrichter> The history of every GUI toolkit ever: "This other crap is too complex. I'll make my own GUI toolkit, only with hookers and blow." "Huh, OK, this one thing I do over and over again is pretty verbose, so I'll add an API call for it." ← repeat previous a thousand times…per week…per developer… "This crap is too complex. …"
<ikskuh> sadly, it's not that easy
<ikskuh> gui is inherently massivly complex in itself
<ifreund> yeah, I do get that on some level but it's not gonna stop me from complaining :D
<scientes> gui also needs to be more MVC
<scientes> but the real problem is that most apps can't just use stock widgets
<scientes> they need something special
<scientes> and GUI programming is just boring
KoljaKube has joined #zig
<ifreund> aaaaaah my code was fine i just fucked up the CSS
<ifreund> and yeah i also find GUI programming boring as hell, but sometimes I want something done so I need to do it myself
<ifreund> well, nice waybar now shows river's tags
<KoljaKube> What's a river?
greenfork has joined #zig
<KoljaKube> Hm, if method parameters are const, are dot-functions not able to modify their subject?
<ifreund> KoljaKube: this is river https://github.com/ifreund/river
<ifreund> KoljaKube: they are if you pass by non-const pointer
<ifreund> e.g. fn do_something(self: *@This()) void { self.x += 1; }
frmdstryr has quit [Ping timeout: 260 seconds]
dermetfan has joined #zig
<KoljaKube> ifreund: I thought I had tried that, but I must have done something else wrong. Your solution works :-)
_Vi has joined #zig
craigo has quit [Ping timeout: 260 seconds]
ifreund has quit [Quit: WeeChat 2.8]
ifreund has joined #zig
KoljaKube has quit [Ping timeout: 260 seconds]
<iwq> can you read and write to a file at comptime in zig?
<ikskuh> no, there's no option for syscalls or I/O at comptime
<ikskuh> but you can get a buffer for a file with @embedFile
<iwq> interesting, I was thinking if something like F# Type Providers could be possible in Zig
<iwq> so you could turn a json file into a Zig type
<ikskuh> that sounds like a code generator job to me
<ikskuh> just write a program that does this ;)
dingenskirchen has quit [Quit: dingenskirchen]
dingenskirchen1 has joined #zig
benjif has joined #zig
dingenskirchen1 is now known as dingenskirchen
_Vi has quit [Ping timeout: 246 seconds]
<pmwhite> It would be nice if you could test multiple nullable values at once, like `if (a and b) |c, d| { ... }`
<ikskuh> you can do
<ikskuh> if(a != null and b != null)
<ikskuh> then just use a.? and b.?
<pmwhite> I suppose, but that's more lamer.
<ikskuh> nah, it's perfectly fine :D
<pmwhite> Okay, fine.
<ifreund> if (a) |c| if (b) |d| { } works
<pmwhite> Oh, that's not bad. I didn't think of that.
KoljaKube has joined #zig
Akuli has joined #zig
<KoljaKube> Is there a reason why the documentation does not use @This for dot functions? Should I not use it?
ask6155 has joined #zig
<ask6155> hey, how do I jump to definition? vim)
dingenskirchen has quit [Quit: dingenskirchen]
dingenskirchen has joined #zig
<ikskuh> ask6155: search for "NAME ="
<ikskuh> when you use zig fmt, you can be safe that "NAME =" is either definition or assignment
<ifreund> KoljaKube: I personally put a `const Self = @This();` at the top of most of my files and use that
<KoljaKube> Nice idea
<ifreund> not original, I stole it from the std :P
<KoljaKube> ask6155: Putting the lines from https://github.com/majutsushi/tagbar/wiki#zig into ~/.ctags.d/zig.ctags seems to work
<ifreund> neat, i never mananged to get ctags working. Have zls now though which is even nicer
<ask6155> I don't understand what your saying but I'd like to goto the definition of functions. like gd std.debug.warn
<KoljaKube> Heh, didn't know gd yet
<ifreund> ask6155: gd works through ctags usually
<ask6155> so do I just install ctags, run ctags in directory and
<ask6155> ??
<KoljaKube> Yeah, install universal ctags, run `ctags -R .`
<KoljaKube> You will need to re-run that occasionally, of course
<ifreund> alternatively, give zls a try https://github.com/zigtools/zls
<KoljaKube> Also allows jumping to function definitions via C-] across file boundaries and such
<ifreund> it's still young and has bugs/missing features, but I've found it quite useful
<leeward> For what it's worth, etags works fine with zig too.
<leeward> Though I hear emacs isn't cool.
<KoljaKube> Hm, zls master does not build
<ifreund> KoljaKube: you need master zig
<KoljaKube> Oh.
<ifreund> yeah, such is the cutting edge
dermetfan has quit [Ping timeout: 246 seconds]
<KoljaKube> Can't build that through Homebrew, and really don't like manually installing tarballs all the time :-/
<ifreund> leeward: vim isn't cool anymore either, gotta use a real hipster editor like Kakoune these days
<leeward> ifreund: way too cool for me
<ifreund> ah yeah mac package managment is kinda nasty
<KoljaKube> Damn, I need to switch editors again?
<KoljaKube> Well, it's just that one linker bug iirc
<KoljaKube> Homebrew can do source builds
<leeward> KoljaKube: I just have a local Zig repo. Zig is in so much flux that it doesn't make a ton of sense to use a package manager.
<ifreund> i mean my distro managed to package llvm in a non-broken way
<ifreund> i think most others did as well
<leeward> Mine too. I use the distro for Zig's dependencies.
<leeward> I thought we were talking about Zig from tarballs, not llvm.
<ifreund> yeah i don't use tarball zig either, though on mac you might need to since homebrew's llvm is causing bugs last I checked
<leeward> ah
<ask6155> so is zig written in c++?
<ifreund> the stage1 compiler is
<ask6155> and?
<leeward> And there's work being done on making it self hosted.
<ifreund> and the stage2 is written in zig?
<ifreund> there is also an open issue about porting stage1 to C in order to ease bootstrapping
<ask6155> and the binaries produced run on bare metal?
<ifreund> yes
<leeward> Bare metal or any supported OS
<ask6155> I think this is C better
<ask6155> would love a zig for C programmers page.
<leeward> ask6155: https://ziglang.org/documentation/master/ is relevant if you're a C programmer.
<ifreund> I mean, if you're like me and already had a good understanding of C jumping in shouldn't be too hard
<ifreund> skimming the docs leeward linked should be all you need to get started
ask6155 has quit [Quit: leaving]
<leeward> If you run into problems, there are some super helpful people in here too.
<leeward> whoops
<ifreund> heh
greenfork has quit [Quit: WeeChat 2.8]
<KoljaKube> The config setup flipped all slashes in my stdlib path, but other than that initial impressions of zls are indeed very shiny
<ifreund> heh, i think the main dev is on windows
<KoljaKube> That would explain it
aerona has joined #zig
<ifreund> i started using it before it had a setup tool, so i never had this problem :D
<KoljaKube> Before I need to go, is there a way to create type-safe aliases of simple types?
<KoljaKube> :D
<KoljaKube> Use case is having radians and degrees not being accidentally interchangeable
<scientes> ughh, c++ has way too many features
<leeward> KoljaKube: There may be a better way, but structs?
<leeward> That's not exactly what you want.
<leeward> Actually, there might be something with unions there.
<leeward> They put restrictions on how they're interpreted.
<KoljaKube> Sure, structs would work, but I was hoping to prevent having to access a member all the time
dddddd has quit [Ping timeout: 260 seconds]
<leeward> Yeah, I know. Unfortunately, type aliasing comes with some implicit casting.
<leeward> `const special = u32` works, but any u32 is a special.
<KoljaKube> If I understand correctly unions need comptime knowledge of the field, and tagged unions add a field containing the enum value, right?
<KoljaKube> leeward: Not only that, but `const boring = u32;` and every boring is special, which is what I want to avoid
<leeward> right
<KoljaKube> I guess structs it is, then. Nothing good has ever happened by throwing raw floats around ;-)
<leeward> If someone more informed were around, they'd probably point you to a proposal for a feature or something.
<KoljaKube> If someone more informed were to read this, please point, I will read the logs tomorrow ;-)
<KoljaKube> But now it's time to cook, thank you all for the helpful input!
<ifreund> KoljaKube: here's the proposal https://github.com/ziglang/zig/issues/1595
<KoljaKube> Thanks!
<ifreund> as mentioned in the comments, you could use non-exhaustive enums to do this
<ifreund> I haven't tried it personally so I can't really speak to the ergonomics of doing that
<leeward> Ooh, I like the proposal.
<leeward> Using enums to make types like this gives me the squicks.
waleee-cl has joined #zig
<ifreund> yeah same lol
<leeward> Yeah, enums aren't a solution and `const Vec2 = [2]f32;` could just as easily be a struct.
KoljaKube has quit [Ping timeout: 246 seconds]
<fengb> Wrapper structs actually feel less kludgy than enums
<demizer> Hey all. Does zig have a module level init() that runs on import like Go?
<ifreund> not too familiar with go, but I dont think so. Remember that files are sructs i zig
<ifreund> *in zig
<demizer> right, but no way I can find to run some setup code automatically in a struct
<ifreund> how would that work?
<ifreund> like `const foo = struct{ .. };` implicitly calls a magic function?
<demizer> for example, a logging library I use needs some setup, but when I am running "zig test blah.zig" and using this library I would have to call log.init() in the test while debugging.
<demizer> I don't believe a struct should initialize itself
<demizer> that's the problem
<fengb> No, there’s no auto init. That’d be considered hidden control flow
<ifreund> ok, one way you can do this is create a function that you call to import your type
<demizer> oh that's interesting
<ifreund> this function would return the type you want to import and before doing so preform your init thing
<demizer> i'll try that, thank you!
<ifreund> no problem
<ifreund> this doesn't work i think unless the thing you want to do can be done at comptime
doublex has quit [Ping timeout: 260 seconds]
doublex has joined #zig
doublex has quit [Ping timeout: 246 seconds]
factormystic has quit [Quit: The Lounge - https://thelounge.chat]
donpdonp_ has joined #zig
<donpdonp_> if (column.main.inError) "ERROR" else "" => expected type '*const [5:0]u8', found '*const [0:0]u8
<donpdonp_> i get that the size is part of the type and both arms of the if need to be the same type, i just dont know what to do instead.
<pixelherodev> donpdonp_: @as([]const u8) might help
<pixelherodev> If you treat the two sides as slices instead of arrays it should work
factormystic has joined #zig
doublex has joined #zig
<donpdonp_> pixelherodev: that makes the compiler happy - thx!
dermetfan has joined #zig
<pixelherodev> No problem :)
donpdonp_ has left #zig ["The Lounge - https://donp.org/thelounge"]
dermetfan has quit [Ping timeout: 246 seconds]
cole-h has joined #zig
doublex has quit [Ping timeout: 260 seconds]
dermetfan has joined #zig
<leeward> pixelherodev: I don't know if I ever mentioned it, but you were completely right about u16 doing what I wanted from a uint_least16_t or uint_fast16_t perspective. I was mixing optimizations into my thinking incorrectly.
dddddd has joined #zig
reductum has joined #zig
swills_ is now known as swills
doublex has joined #zig
jjido has joined #zig
doublex has quit [Read error: Connection reset by peer]
doublex has joined #zig
doublex_ has joined #zig
doublex has quit [Read error: Connection reset by peer]
dermetfan has quit [Ping timeout: 260 seconds]
oats is now known as oats3
_Vi has joined #zig
dermetfan has joined #zig
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<pixelherodev> leeward: :)
<ikskuh> pixelherodev: wanna try something? *grin*
jjido has joined #zig
dingenskirchen has quit [Remote host closed the connection]
dingenskirchen has joined #zig
alexnask has joined #zig
doublex_ has quit [Ping timeout: 246 seconds]
ur5us has joined #zig
xackus has quit [Quit: Leaving]
<leeward> Anyone know the magic incantation to get zig fmt to ignore a block? I can't seem to find it, but I have distinct memories of seeing it somewhere.
<leeward> Maybe that's rust fmt or go fmt.
xackus has joined #zig
reductum has quit [Quit: WeeChat 2.8]
<alexnask> I think its // zig fmt off
<alexnask> let me find some example
<alexnask> / zig fmt: off
<leeward> Hmm, it doesn't seem to respect it.
<alexnask> Seems to work with a simple example for me
<alexnask> Can you share some snippet where it isnt respected? (so I can repro)
<leeward> Yeah, I'm trying to make a smaller example and it's working correctly.
<leeward> ahah
<leeward> When I put the `zig fmt: off` block inside the function, it breaks. When it's outside the function, everything's happy.
<leeward> Oh, it has to be at the top level.
<alexnask> Ah, this is definitely surprising I would expect it to work anywhere as well
<leeward> Ok, I have an example.
<leeward> It certainly violates the principle of least surprise. I don't know if there's a spec anywhere though, so can't say it's a bug.
<alexnask> Ι τηινκ ιτ δεσερωεσ α γιτηθβ ισσθε
<alexnask> Oh shit sry
<alexnask> I think it deserves a github issue
<leeward> I was almost there.
<leeward> Stuck on deserves :P
dermetfan has quit [Ping timeout: 260 seconds]
<alexnask> :D
<leeward> Yeah, I'll open one.
dongcarl has quit [Read error: Connection reset by peer]
<leeward> bugged
dermetfan has joined #zig
doublex has joined #zig
dermetfan has quit [Ping timeout: 256 seconds]
neceve_ has quit [Ping timeout: 246 seconds]
Akuli has quit [Quit: Leaving]
doublex has quit [Ping timeout: 246 seconds]
doublex has joined #zig
oats3 is now known as oats
nycex- has joined #zig
nycex has quit [Ping timeout: 240 seconds]
dermetfan has joined #zig
doublex has quit [Ping timeout: 260 seconds]
craigo has joined #zig
drp_ has joined #zig
drp has quit [Ping timeout: 256 seconds]
doublex has joined #zig
<scientes> daurnimator, ?
ur5us has quit [Ping timeout: 256 seconds]
drp has joined #zig
drp_ has quit [Ping timeout: 246 seconds]
drp has quit [Ping timeout: 258 seconds]
daex_ has quit [Quit: /me 's znc kicks the bucket]
daex has joined #zig
drp has joined #zig
ur5us has joined #zig
drp_ has joined #zig
drp has quit [Ping timeout: 260 seconds]
xackus has quit [Ping timeout: 272 seconds]
drp has joined #zig
drp_ has quit [Ping timeout: 264 seconds]
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
craigo has quit [Quit: Leaving]
xackus has joined #zig
alexnask has quit [Quit: Leaving]
xackus has quit [Ping timeout: 260 seconds]
ur5us has quit [Ping timeout: 256 seconds]
_Vi has quit [Ping timeout: 246 seconds]