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/
notzmv has quit [Remote host closed the connection]
v0idify has quit [Remote host closed the connection]
zags has quit [Ping timeout: 256 seconds]
v0idify has joined #zig
nycex- has quit [Remote host closed the connection]
nycex has joined #zig
brzg has joined #zig
midgard has quit [Ping timeout: 246 seconds]
Kiori_ has joined #zig
Kiori has quit [Ping timeout: 272 seconds]
midgard has joined #zig
a_chou has joined #zig
xackus_ has quit [Ping timeout: 264 seconds]
<v0idify> I just properly understood how async works in zig and... it's so simple yet powerful! :)
gazler__ has quit [Remote host closed the connection]
gazler__ has joined #zig
midgard_ has joined #zig
midgard has quit [Ping timeout: 240 seconds]
dongcarl8 has joined #zig
dongcarl has quit [Ping timeout: 265 seconds]
dongcarl8 is now known as dongcarl
dyeplexer has joined #zig
brzg has quit [Quit: leaving]
a_chou has quit [Quit: a_chou]
earnestly has quit [Ping timeout: 240 seconds]
<andrewrk> :)
<andrewrk> evented I/O mode is still experimental, but I think the core design is solid
geemili has quit [Ping timeout: 258 seconds]
reductum has quit [Quit: WeeChat 3.0]
cole-h has quit [Quit: Goodbye]
cole-h has joined #zig
cole-h has quit [Client Quit]
cole-h has joined #zig
cole-h has quit [Client Quit]
leon-p has quit [Quit: leaving]
<daurnimator> andrewrk: I'm not sure about that
<daurnimator> I'd like to have about the discussion of it in a library context
<daurnimator> god my language parser is broken
<daurnimator> I'd like to have a discussion about it in a library context
<motiejus> andrewrk: I see you solved the compilation problem by ignoring the `-c` flag, and now output is incompatible if I use plain clang vs `zig cc` (zig cc produces non-stripped binary, even though if `-c` is requested). It's OK for me, but something to keep in mind for `zig cc` users
<andrewrk> motiejus, this is a missing feature of zig's linking abilities, to honor the request to strip
<andrewrk> it will come in time
notzmv has joined #zig
<motiejus> understood. so `zig build-obj` cannot build stripped libraries too? I am trying to find a workaround (compile object file and then link it as a separate step)
<andrewrk> you can't build a stripped object; that is a contradictory request
<motiejus> I mean, link it
<motiejus> i.e. during the linking step
<motiejus> unless `build-obj` is not a linker? (sorry I am new to this)
_whitelogger has joined #zig
<andrewrk> daurnimator, I'm available for that
<andrewrk> motiejus, generally one compiles into objects, and links into executables
<andrewrk> build-obj is more of an advanced use case
<andrewrk> stripping is something one does after linking (or during linking) removing some redundant information from the final binary
<andrewrk> it's an optional step
<motiejus> Yeah, that's what I tried - create an object file (`zig cc -o`) and then link+strip with ld equivalent (I assumed build-obj). Nevermind, the non-stripped binary is already smaller to the official stripped one, so I'm good with this
<motiejus> Thanks for quick turnaround
cole-h has joined #zig
cole-h has quit [Client Quit]
squeek502 has quit [Remote host closed the connection]
squeek502 has joined #zig
jukan has quit [Read error: Connection reset by peer]
jukan has joined #zig
cole-h has joined #zig
waleee-cl has quit [Quit: Connection closed for inactivity]
cole-h has quit [Client Quit]
sord937 has joined #zig
cole-h has joined #zig
GreaseMonkey has quit [Remote host closed the connection]
decentpenguin has quit [Read error: Connection reset by peer]
decentpenguin has joined #zig
cole-h has quit [Quit: Goodbye]
cole-h has joined #zig
tnorth has joined #zig
<marler8997> the first PR to win32metadata from the Zig community: https://github.com/microsoft/win32metadata/pull/212 I feel proud to be apart of this community that fixes other people's upstream projects
<daurnimator> andrewrk: I'm around now if you still are.
zags has joined #zig
hnOsmium0001 has quit [Quit: Connection closed for inactivity]
earnestly has joined #zig
gazler__ has quit [Ping timeout: 272 seconds]
gazler has joined #zig
cole-h has quit [Ping timeout: 256 seconds]
Snetry has quit [Ping timeout: 264 seconds]
<ifreund> andrewrk: working on switches now :)
<zags> ifreund: damn, what kind of espresso are you on? :D
<ifreund> I find poking at the ast kind fun, and I'm very motivated to get andrew unblocked on this so stage2 can move forward and I can someday never have to use stage1 again :D
<ifreund> plus, this is my way of procrastinating other things
<zags> haha :D
<Piraty> marler8997: if i'd be that upstream, i'd require you to give that commit a descriptive text
<Piraty> mainly so people can read on the intention / change context without opening a browser to read #211 (and who knows if that issue will be online in N years)
<ifreund> tbh a microsoft repo is not the place I'd worry about that
<ifreund> I do very consciously avoid depending on github issues/PR descriptions for my own stuff and projects like zig thoughu
<Piraty> that is wise to do
<Piraty> and why not teach M$ how to properly git
<daurnimator> I use `git-bug` to get a local copy of issues/pullrequests
<ifreund> from their readme: "doesn't pollute your project: no files are added in your project"
<ifreund> how does it work then?
<earnestly> It pollutes^Wembeds in your .git directory
<zags> maybe Fossil was right all along, every repo is also an issues tracker/wiki :)
<earnestly> I appreciate though that the architecture for git allows for this sort of experimentation
<earnestly> for/of
<ifreund> indeed, I also take advantage of it with random .git/todo files
<daurnimator> ifreund: yeah it essentially makes a heap of git objects with the bugs
layneson has joined #zig
layneson has quit [Client Quit]
betawaffle has quit [Ping timeout: 240 seconds]
gonz_ has quit [Read error: Connection reset by peer]
yrashk has quit [Ping timeout: 246 seconds]
shurane has quit [Ping timeout: 264 seconds]
dch has quit [Read error: Connection reset by peer]
euantorano has quit [Read error: Connection reset by peer]
rtpg has quit [Ping timeout: 272 seconds]
jzelinskie has quit [Write error: Connection reset by peer]
ovf has quit [Ping timeout: 260 seconds]
lukego has quit [Read error: Connection reset by peer]
bitmapper has quit [Read error: Connection reset by peer]
eddyb[legacy] has quit [Read error: Connection reset by peer]
r0bby has quit [Read error: Connection reset by peer]
kwilczynski has quit [Read error: Connection reset by peer]
dch has joined #zig
betawaffle has joined #zig
gonz_ has joined #zig
euantorano has joined #zig
eddyb[legacy] has joined #zig
lukego has joined #zig
yrashk has joined #zig
kwilczynski has joined #zig
midgard_ has quit [Ping timeout: 264 seconds]
ovf has joined #zig
jzelinskie has joined #zig
r0bby has joined #zig
rtpg has joined #zig
midgard has joined #zig
bitmapper has joined #zig
bsrd has quit [Quit: WeeChat 3.0]
bsrd has joined #zig
xackus_ has joined #zig
shurane has joined #zig
Snetry has joined #zig
<zags> is there a syntax to get an instance of the default value of a given type? Useful in generic code. In C++ you'd do T{} or T()
<g-w1> const s: S = .{};
<zags> zero-initialization basically
<ifreund> T{} works if you define default values for your type's fields
<g-w1> there is only that if you specify default
<zags> type 'u64' does not support array initialization
<zags> need to support primitives
<g-w1> why not just 0?
<ifreund> yeah, .{} only works for structs that have a default value for every field
<zags> g-w1: because it's a generic function
<zags> type can be struct or primitive
<ifreund> there's std.mem.zeros if you really want to init everything to zero
<ifreund> this is considered an antipattern in zig though
<zags> ifreund: but how do I declare the variable?
<zags> it needs to be initialized
<zags> or zig says no
<ifreund> std.mem.zeros returns a value
<g-w1> var m: T = std.mem.zeroes(T);
<zags> oh I see
<zags> that's exactly what I need, thanks guys
kchambers has joined #zig
<zags> ifreund: I don't see why zero-init would be an anti-pattern, quite common in C++ tempalte code at least
<zags> template*
<ifreund> being similar to C++ template code is not a goal
<zags> but being able to do the same things is
<ifreund> in idiomatic zig you either use undefined or a value that actually has meaning
<zags> it's well-defined what var x: T = .{} means if would also zero-init primitives
<zags> or some other general syntax
<ifreund> but is zero a meaningful default value in all case? I think not
<zags> in many cases it is
<zags> and you'd explicitely ask for it
<zags> now i have to resort to mem.zeroes
<ifreund> mem.zeroes exists so there's no need for new language syntax/semantics
<zags> always good to have an anti-pattern in the tool belt
<ifreund> it's in the std primarily for use when interfacing with C code that expects zero init
<ifreund> note the doc comment
<zags> this is so I can spring a variable in a generic into existence
<ifreund> you can also do var m: T = undefined
<zags> yeah, true
donniewest1 has joined #zig
leon-p has joined #zig
<ifreund> andrewrk: switches done, I'm going to take a break working on zig fmt and go back to river for a bit now :)
<fengb> Handmade Seattle has a podcast where Andrew explains why not zero init
<zags> I jumped to the Zero Is Initialization segment, but the host didn't let andrew speak, so I closed the tab
<zags> there's a small number of generic cases where I find it useful, but mem.zeroes exists and that'll do
<zags> (in all other cases, I agree undefined is of course the right thing to do)
<zags> hm, being able to attach catch to a block would be really convenient at times, e.g {many(); related(); things(); } catch |err| switch (err) {}
<g-w1> with #1717 you could probably make an anon function with a funch of tries and then do 1 catch on it
<zags> yeah that gets close
<fengb> zags: looks like exceptions to me :P
waleee-cl has joined #zig
<ifreund> TLDR you already can but the ergonomics suck
<ifreund> and using an anon function isn't a great solution as you'd have to pass everything in as arguments
hnOsmium0001 has joined #zig
<v0idify> how do I see if a frame is done?
<v0idify> ex. it has returned, without blocking
xackus_ has quit [Read error: Connection reset by peer]
xackus__ has joined #zig
<zags> fengb: yeah it does, but error propagation is already a sort of exceptions :) I would use the block/catch rarely, but sometimes it makes a lot of sense
<zags> ifreund: thanks, good issue
<zags> having switch |err| as sugar for catch |err| switch (err) would also be helpful to me, but that's already been rejected iirc
<zags> which is strange given that the language tries to optimize for making error handling smooth
tnorth has quit [Ping timeout: 258 seconds]
<v0idify> are string literals null terminated by default?
<mikdusan> yes
<fengb> Yes, only literals though
<ifreund> string literals are pointers to null-terminated arrayrs
<mikdusan> wait wait I can do better. string literals are const pointers to null-terminated arrays
<dutchie> on the other hand, a "string" is normally a slice of u8 (i.e. a fat pointer with a length field)
<DarkUranium> mikdusan, string literals in C are non-const pointers to const null-terminated arrays.
<dutchie> (and not in general null-terminated)
<DarkUranium> (type of a string literal in C is `char[n]`, not `const char[n]`)
<fengb> We're not talking about C
amk has quit [Remote host closed the connection]
amk has joined #zig
<zags> #1717 expression can be immediately evaluates right? as in fn() bool {...}()
<zags> evaluated*
<Snektron> probably but you can always just use `blk: { ... break :blk value; }`
Kiori_ has quit [Ping timeout: 240 seconds]
<ifreund> zags: your code in the comment you posted should work with the current proposal, but without the try keyword
<zags> your original comment has multiple try's inside
<ifreund> though you probably want try on your explode(), sleep(), and run() calls
<zags> that's what my comment changes :)
<ifreund> ew now please lets not do that
<zags> why not
<ifreund> that's implicit control flow
<zags> try is that already
<zags> it returns
<ifreund> the keyword makes it explict
<ifreund> implict would be the possiblity for a function call to cause a return *without* a keyword prefixing it
<ifreund> which is what your suggestion does
<zags> the try in front of fn makes it clear what will happen
<ifreund> imagine the case in which the anon function is much longer and has non-trivial control flow
<ifreund> and some functions called from within it return errors and some don
<ifreund> t
<zags> comment gone, I need to think it through haha
<ifreund> heh, it would be completely contradictory to the core principles of zig IMO :P
<companion_cube> zags: `fn() {…}()` is an abomination that only exists in languages that don't have blocks-returning-values
<companion_cube> (namely, js and go)
<ifreund> zags: really, I think #5610 is what you want
<zags> well, I'm making a stream-like interface and Zig makes it real hard to make it fluent, so just trying out various ideas
<companion_cube> stream, like map/filter stuff
<companion_cube> ?
<zags> yeah, the {}catch thing is what I came up with independently
<zags> companion_cube: yeah
<ifreund> I seem to recall that andrew isn't really a fan of such APIs specifically because they conflict with robust and explict error handling
<companion_cube> without closures that' ll be hard
<zags> ifreund: i'll make it anyway because I'm a huge fan of it
<ifreund> I for one am very curious to see where your library ends up :)
<zags> companion_cube: yeah it sucks, but a large number of common freestanding functions you can plug in (lt,gt,mul,div, etc) will help
<companion_cube> oh, like as function pointers?
<zags> ifreund: raw loops suck too, i tend to use <algorithms> and Stream type apis where available. Very readable and easy to refactor.
<zags> companion_cube: yeah, wrapped in applicatives
<zags> var result = try intStream.from(&ages).filter(lessThan(min)).map(u64, asFloat64).reduce(1, mul);
<zags> this works in the prototype
<zags> nice thing is you can lazily build a type safe pipelines of operations, and it doesn't do anything until you want to do the terminating operation
<zags> should be possible to make parallell streams as well
<zags> and stuff like zipping, skipping, limiting, flat-mapping, sorting, averaging and other tasty things
<companion_cube> the language will fight you
<zags> sure, it already does - anyway, good way to learn zig even if nobody will ever use it :)
<zags> but so far it looks better than I expected actually
<zags> like the zip (non-streamy so far) was actually quite nice thanks to comptime
<zags> quite readable
<fengb> It's all fun and games until you realize the secret memory usage
<zags> what do you mean?
<zags> streams are very good at not using memory
<fengb> Oh I see
<companion_cube> seems to work ok in rust, I'd say
notzmv has quit [Read error: Connection reset by peer]
cole-h has joined #zig
<justin_smith> my experience is that the common programming error with streams is that they can make resource lifetimes and reliance of external state break
<zags> in what language? never had the issue
<justin_smith> the "secret memory usage" that comes up in haskell (which effectively streams implicitly) is because of all the resources a stream might keep alive
<justin_smith> zags: in clojure where more ~half of stdlib is lazy
<zags> yikes, yeah
<companion_cube> it's only in haskell
<companion_cube> otherwise streams are consumed on demand
<justin_smith> for example, someone creates a code block that consumes a FD - two mistakes are possible here - returning the streaming op while closing the fd (using an expired fd) or leaving an fd open (didn't finalize the stream)
<zags> yup
<zags> i've never done anything remotely like that, and i use streams like 10 times per day lol
<justin_smith> companion_cube: as a real world example: I used a clojure lib that provided a lazy API over a tagsoup style xml api
<justin_smith> companion_cube: I had a huge memory leak as it "helpfully" held off closing the input stream until end of stream is reached
<companion_cube> the bugs caused by evaluating lazy stuff too late is real
<companion_cube> are real*
<companion_cube> ahaha damn
<justin_smith> (while one point of a tag soup is you can just stop consuming...)
<companion_cube> I'd expect it to not leak, but fail if you consume stuff too late as the underlying source is not present anymore
<companion_cube> it's a tradeoff
<justin_smith> companion_cube: right - but it's an intrinsic one with the streaming model
<zags> i love lisp and hated clojure despite its neat persistent data structures
<zags> the jvm marriage is disgusting
<zags> convenient of course
<justin_smith> zags: haha, it's the kind of disgusting that ensures I can use a lispy language at an "enterprise" type company
<zags> lol right :D
<justin_smith> zags: in fact, I think what it shares with zig is providing uncomplicated access to the substrate
<justin_smith> in clj that's the vm, in zig that's the hardware
<zags> give me a scheme with a good stdlib and good C interop instead
<justin_smith> for values of "uncomplicated" approximating "only the complexity of the thing offered"
<justin_smith> zags: good luck pitching that to a startup :D
<zags> yeah I get the problem :)
<zags> fortunately I'm the one deciding in my comp :D
<zags> which means Zig will get used way before it should hehe
dyeplexer has quit [Remote host closed the connection]
notzmv has joined #zig
ifreund has quit [Read error: Connection reset by peer]
ifreund1 has joined #zig
ifreund1 is now known as ifreund
Akuli has joined #zig
<v0idify> *y = slot.advance.y >> 6; // why is this wrong? "invalid left-hand side to assignment"
<fengb> y.* =
<v0idify> oh
<v0idify> feels weird but makes sense
<zags> I bet a few here qualify :D
<zags> dafuq, tweet said something else, it's an admin position LOL
<ifreund> heh, I was confused
<ifreund> I also don't live in california :D
* zags will click on link before sharing next time >.<
<zags> I went ahead and shared internally that zig is production ready in about two years. No pressure.
SebastianM has joined #zig
SebastianM has quit [Quit: Lost terminal]
SebastianM has joined #zig
jzelinskie has quit [Ping timeout: 240 seconds]
ovf has quit [Read error: Connection reset by peer]
jzelinskie has joined #zig
ovf has joined #zig
SebastianM has left #zig [#zig]
<fengb> It's "2 years from stable" for about 3 years now
<zags> Yes, I didn't pick the amount of years randomly :D
<ifreund> so much progress in the last three years of zig though
<zags> hm, the wikipedia page doesn't do it justice
<zags> needs a rework
<ifreund> it's got the old logo too
<Gliptic> hm, logo seems up to date to me?
<Gliptic> ah
<zags> not quite
<Gliptic> yeah, slanted gaps
<zags> yeah, took me a while too :D
<ifreund> better font too
<fengb> smh, they're copying all the best parts of Zig
<zags> whoever made the logo is good, the rectangle sides has the golden ratio, so it's pleasant to look at
<Gliptic> fengb: what do you mean?
<Gliptic> is the zig software foundation the only good part of zig? :P
<fengb> Rust Foundation is clearly a reaction from ZSF
<fengb> Oh haha
<companion_cube> fengb: I think it predates the ZSF, but you're funny nonetheless
<Gliptic> rust foundation is very recent, so I don't know
<Gliptic> but it's mostly a reaction to rust layouts at mozilla
<Gliptic> *layoffs
cole-h_ has joined #zig
cole-h has quit [Ping timeout: 240 seconds]
<companion_cube> they've discussed the foundation for a long time though
<fengb> Nah, totally a reaction
<Gliptic> sure, but became more urgent lately I guess
<companion_cube> I mean, both are copies of the ocaml software foundation, let's be realistic
<companion_cube> https://ocaml-sf.org/about-us/ ;-) ;-)
cole-h_ is now known as cole-h
ifreund has quit [Ping timeout: 272 seconds]
ifreund has joined #zig
earnestly has quit [Quit: WeeChat 3.1-dev]
ifreund has quit [Quit: WeeChat 3.0]
ifreund has joined #zig
tnorth has joined #zig
ur5us has joined #zig
sord937 has quit [Quit: sord937]
tnorth has quit [Ping timeout: 256 seconds]
ur5us has quit [Ping timeout: 260 seconds]
ur5us has joined #zig
lucus16 has quit [Quit: WeeChat 2.8]
<v0idify> i'm allocating memory for a pixel map. each pixel has 4 8-bit channels. should I allocate u32 or u8 for performance?
<ikskuh> v0idify: you can always bitcast between one or the other :)
<v0idify> ikskuh, yes but won't that affect performance theorically?
<ikskuh> not at all
<ikskuh> bitcast on that size is completly free on every 32 bit arch
<ikskuh> it just depends on your access pattern :)
<ikskuh> there should be no performance penalty at all if you chose either one
<ikskuh> they are both 4 byte large types
<v0idify> i'll stay on u32. @bitCast is very useful! i was masking and then intCast-ing to do the same
<fengb> bitcast is always free
<ikskuh> v0idify: see here :https://zig.godbolt.org/z/hjGfY5
geemili has joined #zig
<v0idify> oh wait i still need intCast if i want to turn it into an u8. it's fine though
<ikskuh> @truncate(u8)
<ikskuh> :D
<ikskuh> if yu don't care for overflow :)
donniewest1 has quit [Remote host closed the connection]
<v0idify> oh that's perfect, thanks
<v0idify> finally got what i wanted
donniewest1 has joined #zig
<ikskuh> heh
<ikskuh> i usually use the Color struct
<ikskuh> but as aransentin pointed out: using u32 is probably smarter
<v0idify> what is the Color struct?
<ikskuh> see the godbolt link
<fengb> Why is u32 smarter?
<ikskuh> because r8g8b8x8 is as valid as r10g10b10x2
<zags> is there anything in std to do saturation arithmetic?
<ikskuh> no, not really
<fengb> Depends on the underlying impl, and u32 hides that structure
<fengb> Although u10 would be broken af 🤔
<ikskuh> why? ;)
<v0idify> how do I make the compiler output assembly? I wanna see what's happening
<ikskuh> aransentin has a 10bit HDR screen
<ikskuh> v0idify: i'd just push it back into objdump ;
<fengb> And I'd prefer if the types were Color / HdrColor or something more obvious what's going on
<fengb> Instead of a generic u32 that may be correct
<ikskuh> Color = union { hdr: packed struct { r: u10, … }, ldr: extern struct { r: u8 … }, raw: u32 }
<fengb> may accidentally be incorrect*
<fengb> But those aren't losslessly transformable
Kiori has joined #zig
<fengb> If you set hdr, and use ldr, you're in for a world of hurt
<fengb> Hmm... we could introduce some really trippy graphics
<fengb> New art genre?
<zags> glitch art
<waleee-cl> zags: have you checked out janet? https://github.com/janet-lang/janet
* waleee-cl checked the logs
<waleee-cl> there's also carp, but lisp + borrow-checker seems like a potential match mad -in hell
<ifreund> janet is sweet :)
<waleee-cl> ifreund: yeah, that recommendation should have had an attribution (saw you mention it there)
<ifreund> there == #river?
<waleee-cl> ah. yeah :)
<ifreund> :)
craigo has joined #zig
craigo has quit [Remote host closed the connection]
<v0idify> how do I check for an overflow without actually saving the result
<v0idify> like if overflow { this value } else { just use the result }
<g-w1> if i +% 1 = 0 ?
<g-w1> *==
<v0idify> well yeah but i'm not just using 1
<ikskuh> v0idify: @addWithOverflow
Akuli has quit [Quit: Leaving]
<v0idify> i already looked into that but for some reason it was no good. i'll check again
<ikskuh> you have to have a result location for it
<ikskuh> but you can just use a temporary
<zags> waleee-cl: not yet! Swift, Rust, Julia, Nim and now Zig has already been enough for my "try new languages" list the past couple of months
<v0idify> i33 to fit a u32 feels very wrong
<ikskuh> v0idify, can you post the code snippet in question?
<ikskuh> maybe there's an easy solution
<ifreund> zags: which one of those did you like the most? (and why is it zig? :P)
<v0idify> ikskuh, dw i'm just having serious issues with middle school math
<ikskuh> hm?
<v0idify> addition and substraction lol
<zags> ifreund: It is Zig :) I liked Nim a great deal, but the low quality of the 3rd party modules I had to rely on was a show stopper.
<zags> That's why I was bitching about a peer-reviewed, community driven boost-like initiative for Zig, and boy did I get crushed :D
<companion_cube> boost doesn't cover that much, does it?
<companion_cube> compared to the stdlib of non C++ languages
<zags> i does, it's a life saver
<zags> starting with ASIO
<companion_cube> what kind of things do you use it for?
<zags> boost?
<ikskuh> companion_cube: c++11 adopted a lot of boost into c++ s td
<zags> yep
<zags> i would like a similar initiative for Zig, but not the monolithic style. Small-language communities always get low quality, unmaintained libraries. Nim is great proof too.
<v0idify> essentially the problem i'm having is i want to (u32 - c_int) and if that would result in < 0 (underflow) just set to 0
<v0idify> but it seems i need to convert to i33 to do the math
<zags> waleee-cl: thanks for that link, it looks like a great lisp dialect
<v0idify> zags, you're forgetting that zig is aiming for total world domination :P
<companion_cube> ikskuh: but that's my point
<v0idify> i like the idea
<companion_cube> there still isn't that much in C++'s stdlib
ur5us_ has joined #zig
<companion_cube> in a modern language most of that should already be in the stdlib, not in 3rd party libs
riba has joined #zig
<ikskuh> v0idify: std.math.add(t, a, b) orelse 0
ur5us has quit [Ping timeout: 264 seconds]
<v0idify> that doesn't solve my "problem", t needs to be i33
<ikskuh> ah
<v0idify> although it it useful, i'm doing what that function does manually :)
<ikskuh> what guarantees do you have?
remby has joined #zig
<v0idify> well, c_int comes from freetype
<v0idify> it's the offset of a character
<ikskuh> and you add that to?
<ikskuh> a pixel coordinate?
<v0idify> yes
<ikskuh> you can also cast both to i32
<ikskuh> because your result might be negative
<v0idify> u32 can't be casted into i32
<v0idify> it needs to be i33
<v0idify> but also i don't care about the negative result (if i get that, i set to 0)
<v0idify> so i need to go from u32 and i32 to i33 and i33 to u32 again
<ikskuh> @intCast exists ;)
<ikskuh> it cannot be coerced into i32, but it can be casted
<v0idify> fair enough, i doubt the coordinate will be the limit of u32 ^^
<ifreund> I don't follow, what are the two endpoints you are trying to convert between?
<ikskuh> u32-c_int
<ifreund> you could just use u31
<v0idify> well i would have to set everything to use u32 coordinates
<v0idify> 31*
<v0idify> (y: u32) - (bitmap_top: c_int). i care if bitmap_top is negative but not if the result is negative (if it is, i set to 0)
<v0idify> i guess i will intCast the y to i32
<ifreund> hrm can I use @fieldParentPtr() a pointer to the payload of an optional field?
<ifreund> that would certainly be convienent right now
<ifreund> also, can I set an optional field to undefined but non-null?
<ikskuh> ifreund:
<ikskuh> var x: ?u32 = @as(u32, undefined);
<ifreund> that makes sense
<ikskuh> yes, you can optional-pointer fieldParentPtr afaik
<ifreund> I have a pointer to the payload not the struct field though
<ifreund> it feels like it's probably UB but it could theoretically be allowed
<ifreund> maybe spexguy can help me
<v0idify> expected type '[*c]const u8', found '[]const u8' what am I supposed to do?
<ifreund> ikskuh: it doesn't compile :(
<ikskuh> sad :(
<ifreund> /tmp/foo.zig:11:50: error: expected type '*const ?u32', found '*const u32'
<ifreund> yeah...
<zags> Zig says no
<ifreund> a @optionalParent() builtin would be possible to implement
<ikskuh> ifreund: you can probably just ptrcast?
<ifreund> that's gotta be UB right?
<ikskuh> nah, the address isn't changing
<ifreund> you sure? I thought optionals don't have a well defined memory layout
<ikskuh> optionals for non-allowzero pointers have the same memory layout as a pointer
<ifreund> the payload isn't a pointer though, it's a struct
<ikskuh> v0idify: []const u8 is a slice (so ptr+len), but [*c]const u8 is a C pointer
<ikskuh> ifreund: ah dang
<v0idify> ikskuh, but can't it downgrade to a pointer?
<ikskuh> v0idify: so solution would be: find out what pointer C expects there
<v0idify> i ptrCast'd
<ikskuh> you can probably just use slice.ptr
<ikskuh> instead of slice
Kiori has quit [Read error: Connection reset by peer]
<v0idify> oh! i didn't know that
<ifreund> unless C wants a null terminated pointer...
xackus__ has quit [Ping timeout: 256 seconds]
<ikskuh> note that if it's a C string, you might want to use [:0]const u8 (zero-terminated slice with runtime check for terminator)
<v0idify> oh that's cool
<v0idify> thanks
jukan_ has joined #zig
<v0idify> time to add harfbuzz into the mix
jukan has quit [Ping timeout: 256 seconds]
<ikskuh> time to go to bed! o/
<v0idify> o/
euantorano has quit [Read error: Connection reset by peer]
shurane has quit [Read error: Connection reset by peer]
euantorano has joined #zig
shurane has joined #zig
<ifreund> ah, found a way to work around my problems by refactoring :)
<ifreund> still some inefficiency due to lack of @optonalParentPtr() though
riba has quit [Ping timeout: 265 seconds]
donniewest1 has quit [Quit: WeeChat 3.0.1]
nvmd has quit [Quit: Later nerds.]
<andrewrk> ifreund, really appreciate your help! I took a break this weekend so as to not burn out but now I'm back at it :)
ky0ko has quit [Remote host closed the connection]
ur5us_ has quit [Ping timeout: 264 seconds]
<ifreund> no problem! not burning out is very important :)
<ifreund> I'm taking a break right now too to work on river, though I've got a PR up for switches and stuff
<ifreund> andrewrk: I actually did try the @as(*[1]Node.Index, foo) but it didn't compile for whatever reason
<andrewrk> ah
<andrewrk> probably not enough magic smoke in your computer
<ifreund> :D
<ifreund> I've noticed that coercion between the branches of if statements is funky before
midgard has quit [Read error: Connection reset by peer]
<andrewrk> oh yeah. good news is that I solved it really cleanly in self-hosted
nycex has quit [Remote host closed the connection]
nycex has joined #zig
midgard has joined #zig
<ifreund> I can't wait :)
remby has quit [Quit: Connection closed]
<ifreund> hence my motivation to get the zig fmt refactor done so you can get back to the rest of stage2
<ifreund> plus futzing around with the ast is kind fun
<andrewrk> :)
<andrewrk> btw you know how people always say it's too hard to do cleanup right because it's a rarely tested codepath?
<andrewrk> each of those parser_test.zig cases get run with every possible allocation failing and makes sure the returned error is OutOfMemory with no leaks