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/
_whitelogger has joined #zig
a92 has joined #zig
earnestly has quit [Ping timeout: 256 seconds]
washbear has joined #zig
washbear has joined #zig
ur5us has quit [Ping timeout: 260 seconds]
ryuukk__ has joined #zig
ryuukk_ has quit [Ping timeout: 246 seconds]
cole-h has quit [Ping timeout: 272 seconds]
ur5us has joined #zig
kristoff_it2 has quit [Ping timeout: 240 seconds]
ryuukk__ has quit [Quit: https://quassel-irc.org - Chat comfortably. Anywhere.]
ryuukk_ has joined #zig
casaca has joined #zig
AceNovo has quit [Quit: Konversation terminated!]
AceNovo has joined #zig
AceNovo has quit [Remote host closed the connection]
<DonnieWest[m]> Silly question here from a zig/C newbie. I'm trying to call this function zig-side https://github.com/graphql/libgraphqlparser/blob/master/c/GraphQLParser.h#L29-L30. The type of that in zig seems to be [*c][*c]const u8 . I'm missing how to create a corresponding zig variable to pass in of that type to hold the error. Anyone know what to do there?
<DonnieWest[m]> And perhaps more importantly, where could I read up on that?
jayschwa has joined #zig
a_chou has joined #zig
<ryuukk_> does anyone have good examples how to do interface? this is confusing
<jayschwa> DonnieWest: I'm just guessing, but have you tried something like this: var err: [*c]u8 = 0; the_function(text, &err);
<DonnieWest[m]> jayschwa: that does the trick. Thanks!
a92 has quit [Quit: Leaving]
semarie has quit [Ping timeout: 246 seconds]
CodeSpelunker has quit [Quit: CodeSpelunker]
semarie has joined #zig
DonnieWest[m] has left #zig ["User left"]
frmdstryr has quit [Ping timeout: 240 seconds]
<ryuukk_> i don't understand how can this be called "interface"
xackus_ has joined #zig
xackus has quit [Ping timeout: 256 seconds]
<ryuukk_> i feel like something zig is auto limiting itself to not add new syntax, the result to solve common problems become an unreadable and unmanageable mess
<ryuukk_> sometimes*
<justin_smith> ryuukk_: how do you define interface?
<ryuukk_> i would have expected to be as simple as GO at least
<justin_smith> so "how can this be called interface" wasn't a question, it was a complaint?
<ryuukk_> a little bit of both to be honest
<ryuukk_> compare with GO https://gobyexample.com/interfaces
<justin_smith> well "how do you define interface?" "I expect something simpler" - I have no follow up for that
radgeRayden has quit [Quit: No Ping reply in 180 seconds.]
<ryuukk_> that is what i expect from modern language, go or rust type interface
<ryuukk_> not all that confusing code in the zig interface link above
<ryuukk_> it just asks for bugs and hard to maintain code
radgeRayden has joined #zig
<ryuukk_> just like enum, i expect something in the same vein for interfaces
<ryuukk_> it feels like inconsistent, on one hand you have nice features that simplify your life, on other you do job of a compiler
<justin_smith> if I'm reading the zig and go examples correctly, in the go example you implement the functions at the top level of the file, in the zig version the functions are inside a data structure
<ryuukk_> i picked zig recently, maybe there are some things i don't understand and that doesn't clic yet, but it's becoming frustrating tbh
<jayschwa> The current interface pattern is not set in stone.
<justin_smith> jayschwa: but it's just a convention right? a struct with a member of a given name with a shared function signature
<justin_smith> you could do the same thing in c, scheme, whatever
<ryuukk_> no, in zig you have more code to time, duplicates, function pointers, @parentPtr thing, and u have to take the interface struct as reference from the struct
<jayschwa> Yep. There are some issues in GitHub for potentially improving the experience by adding feature(s) to the language though.
<ryuukk_> in go it is simple, u define the itnerface, and implement them for your struct
<ryuukk_> easy
<ryuukk_> what the final design will be?
<jayschwa> It hasn't been decided as far as I know.
<ryuukk_> i hope they take a look at GO
<ryuukk_> interface is super common and very helpfull, i find it weird that is not something that was thought earlier and implemented as language feature
<travv0> note that zig has generics which can fill a similar role a lot of the time
<travv0> here's the go example in zig without using an interface https://pastebin.com/hUGAXbWA
<justin_smith> travv0: right, both are methods of late binding, an interface makes the functions a posession of the object, generics make a new object parameterized by a type plus an instance
<justin_smith> if I understand correctly
Kingsquee has joined #zig
<ryuukk_> it's not the same travv0
<ryuukk_> i can't find information on interface not final desin on github
<ryuukk_> all interface disscussion are closed
<ryuukk_> i found this, but it's weird tbh https://github.com/ziglang/zig/issues/3620
Kuraitou has joined #zig
<travv0> what do you find weird about that? seems like exactly what you want
<ryuukk_> it's always more typing for nothing
<jayschwa> Ah, it looks like the status of some of the issues changed recently. My bad.
<ryuukk_> andrewrk: what is status of interface? do you think it's gonna be something like in GO?
<ryuukk_> is there more developpers of the language on the IRC we could ask?
a_chou has quit [Ping timeout: 258 seconds]
jayschwa has quit [Remote host closed the connection]
<ryuukk_> looks like it is a nope
<ryuukk_> hmm
<ryuukk_> i can't understand the official way to do interfaces will be this https://www.nmichaels.org/zig/interfaces.html
<ryuukk_> this is a deal breaker to be very honest
mmohammadi981266 has joined #zig
a_chou has joined #zig
marnix has joined #zig
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
ur5us has quit [Ping timeout: 260 seconds]
mmohammadi9812 has joined #zig
ur5us has joined #zig
mmohammadi9812 has quit [Quit: Quit]
mmohammadi9812 has joined #zig
mmohammadi981266 has quit [Quit: I quit (╯°□°)╯︵ ┻━┻]
<ryuukk_> maybe i just need to read more examples idk
mmohammadi9812 has quit [Ping timeout: 264 seconds]
mmohammadi9812 has joined #zig
mmohammadi9812 has quit [Ping timeout: 256 seconds]
ur5us has quit [Ping timeout: 260 seconds]
a_chou has quit [Quit: a_chou]
factormystic9 has joined #zig
factormystic has quit [Ping timeout: 256 seconds]
factormystic9 is now known as factormystic
cole-h has joined #zig
ask6155 has joined #zig
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
ask6155 has left #zig [#zig]
omglasers2 has joined #zig
xackus_ has quit [Ping timeout: 258 seconds]
decentpenguin has quit [Quit: ZNC crashed or something]
decentpenguin has joined #zig
daurnimator has joined #zig
<daurnimator> jayschwa, ryuukk_: you should never write [*c] in your own code
<daurnimator> we considered calling it `[*automatically_translated_from_c_if_you_wrote_this_its_a_bug]`
<ikskuh> someone broke my windows build again! :D
<ikskuh> andrewrk: did you change something in regard to window symbol generation?
wilsonk has joined #zig
marnix has quit [Ping timeout: 240 seconds]
marnix has joined #zig
ask6155 has joined #zig
wilsonk has left #zig [#zig]
DarkUranium has quit [Quit: ZNC 1.8.1 - https://znc.in]
DarkPlutonium has joined #zig
wilsonk_ has joined #zig
earnestly has joined #zig
<andrewrk> ikskuh, hm nope don't think so. this is a good week to get your project working in master with the release coming up
hnOsmium0001 has quit [Quit: Connection closed for inactivity]
cole-h has quit [Ping timeout: 240 seconds]
<wilsonk_> just testing a new irc client here...want to see if this statement word wraps properly. Sorry for the spam...and on a lighter note I did get a new Ryzen 3600xt system today that seems to be working nicely. Good upgrade from my old one anyways (I tend not to keep up with the cutting edge for my personal machines, because I can usually just use the servers downstairs for most things :) ).
<wilsonk_> seems to have worked properly in the chat window and input window ;)
<omglasers2> was thinking of getting a ryzen 3600 but the 5600x will be released next month so was thinking of waiting for it, though the 5600 would probably be a better choice if it releases
ask6155 has left #zig [#zig]
<omglasers2> on windows with zig master I get "error: unable to detect native libc: LibCRuntimeNotFound" for ".\zig libc"; any idea why?
ask6155 has joined #zig
ask6155 has left #zig [#zig]
<ikskuh> andrewrk: i was asking because i had a regression overnight in the cg-workbench CI
<wilsonk_> omglasers2: just built from scratch on windows and ./bin/zig libc works fine here. Do you have to be in the build dir and not the exe dir?
nycex- has joined #zig
nycex has quit [Ping timeout: 240 seconds]
<omglasers2> wilsonk_, well, I built zig using this https://github.com/ziglang/zig/wiki/Building-Zig-on-Windows and "bin\zig.exe libc" gives that error, same happens with the binary from the website; I actually tried "bin\zig.exe build test -Dskip-release" initially and I got that error after some tests , so I assumed zig libc will give the same error and mentioned that
demizer has quit [Ping timeout: 258 seconds]
ask6155 has joined #zig
marnix has quit [Ping timeout: 265 seconds]
marnix has joined #zig
Kingsquee has quit []
luismanfroni has joined #zig
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
demizer has joined #zig
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
kristoff_it2 has joined #zig
_whitelogger has joined #zig
Amun_Ra has quit [Ping timeout: 256 seconds]
Amun_Ra has joined #zig
frett27_ has joined #zig
frmdstryr has joined #zig
gazler has quit [Read error: Connection reset by peer]
gazler has joined #zig
gazler_ has joined #zig
gazler_ has quit [Remote host closed the connection]
gazler has quit [Read error: Connection reset by peer]
frmdstryr has quit [Ping timeout: 260 seconds]
donniewest has joined #zig
g-w1 has quit [Ping timeout: 265 seconds]
<Michcioperz> on 0.6.0 i can't use an array of packed enum(u2) in a packed struct, is this intentional?
<Michcioperz> (trying to describe a microcontroller register as a volatile pointer to a packed struct)
g-w1 has joined #zig
a_chou has joined #zig
<ikskuh> Michcioperz: you cannot use non-abi aligned types in arrays
<ikskuh> you can use packedintarray though
<Michcioperz> mmmmh too bad really
<Michcioperz> last time i had this problem i just manually unrolled the array
<Michcioperz> but that was avr and it had just 8 pins per register, this has 16 haha
<Michcioperz> i had to blink a led in c today and it was a terrifying experience frankly
<ryuukk_> processor.key_down.?(e.event.key_down.key); key_down is an optional, but it complains: attempt to use null value, doesn't the .? handle that case for me? or i misunderstood what .? is for ?
<ryuukk_> i don't know how it's called, and .? is hard to google
<Michcioperz> .? panics if value is null
<travv0> afaik .? is like rust's .unwrap(), it'll let you use the value if it's not null, but if it is null it'll crash
<Michcioperz> yes
<ryuukk_> oh i see, thanks
frmdstryr has joined #zig
marnix has quit [Read error: Connection reset by peer]
<Nypsie[m]> ryuukk_: .? is syntax sugar for `orelse unreachable`. This means in release-fast and release-small this will result in undefined behaviour. I think it will only crash in debug and release-safe.
marnix has joined #zig
<ifreund> well, it may crash if you're lucky. The behavior is truely undefined though
<ryuukk_> hmm
<ryuukk_> _ = processor.key_down(e.event.key_down.key) orelse false; it complains: error: expected function, found '?fn(i32) bool'
<ryuukk_> key_down is function that supposed to return a bool
<ryuukk_> i'm not sure how to solve this problem
<ryuukk_> processor is also an optional, but i handle that case already earlier
<Nypsie[m]> Is this coming from c?
<ryuukk_> no, it's in zig
<ifreund> if key_down is optional you can't call it directly
<Nypsie[m]> What's the signature of key_down? It looks like is an optional
<ryuukk_> full code of the function https://gist.github.com/ryuukk/24cec3574668e779d19848d90166fc2c, key_down is key_down: ?fn (key: i32) bool = null,
<ifreund> yes, so you cant do `key_down(key);`
<Nypsie[m]> key_down is an optional function. So either call it with process.key_down.?() or `const downFn = process.key_down orelse return false; downFn(key);`
<ifreund> you need to do e.g. `if (key_down) |kd| kd(key) else ...`
<Nypsie[m]> Or ^
hnOsmium0001 has joined #zig
luismanfroni has quit [Remote host closed the connection]
luismanfroni has joined #zig
gpanders[m] has joined #zig
<ryuukk_> ok it works thanks
a_chou has quit [Ping timeout: 260 seconds]
<ryuukk_> if(processor.key_down) |cb| _ = cb(e.event.key_down.key);
<ryuukk_> vs
<ryuukk_> _ = processor.key_down.?(e.event.key_down.key);
<ryuukk_> i find it's harder to read
<ryuukk_> is there no way to still use .? way but not crash if null instead return a false?
<ryuukk_> _ = processor.key_down.?(e.event.key_down.key) orself false; <= doesn't work
<ryuukk_> in c# it would be processor.key_down?.Invoke(e.event.key_down.key) ?? false;
<ryuukk_> the if methos i have to repeat the variable 3 times, in if, in || and then to use it cb()
<ikskuh> ryuukk_: .? is really an unsafe operation
<ikskuh> it will always crash or do undefined behaviour
a_chou has joined #zig
<ikskuh> i think "return if(key_down) |kd| kd(key) else false;" is quite readable
<ikskuh> but the if/capture-construct is unusual at first, true
<ikskuh> you can also do this:
<ryuukk_> if makes the switch body very noisy with repeated stuff
<ikskuh> if(key_down != null) return key_down.?(key);
<ryuukk_> it*
<ikskuh> switch is always noisy
<ryuukk_> with .? it's not noisy
<ryuukk_> i don't want return value
<ryuukk_> i will try the != method and see how it looks
<ikskuh> you can also ignore in all places ;)
<ryuukk_> wait nvm, it's longer
<ryuukk_> it's annoying
<ikskuh> why is it annoying?
<ryuukk_> having to type more, wich ends up convoluting the entire body
<ryuukk_> what supposed to be clean and simple method ends up noisy and hard to read
<ikskuh> hm
<ikskuh> i don't think "more text" is harder to read
<ifreund> what about const f = keydown orelse return; f();
<ikskuh> it's more to type, but that isn't a problem imho
<ikskuh> i usually type stuff only once
<ifreund> or what about finding a way to make this thing not optional in the first place
<ryuukk_> that is a good point
<ryuukk_> but that would mean rethinking the whole input system, wich i'm not ready to do right now, i just need to move on quickly to iterate faster
<ikskuh> why iterate faster?
<ryuukk_> because i don't have time to redo something that works
skuzzymiglet has joined #zig
<ryuukk_> if i explicitly check for not null, it should not crash .? should let me do something without crash
<travv0> but that's the whole point of .?
<ryuukk_> you told me i have to use if(processor.key_down) |cb| _ = cb(e.event.key_down.key);
<ryuukk_> _ = processor.key_down.?(e.event.key_down.key) orelse { false; };
<ryuukk_> this is more readable but doesn't work
<dutchie> orelse is an operator for unwrapping a ?T
<travv0> because that's not the syntax for safely unwrapping nulls
<dutchie> it doesn't usually make sense to use orelse and .? at the same time
<dutchie> if you know rust, .? is .unwrap(), and orelse is .unwrap_or()
<ryuukk_> why not, if not null do that, or else do that
<dutchie> you can do that
<dutchie> if (optional) |wrapped| { do_that();} else {do_something_else();}
<ryuukk_> i didn't go past 1st day with rust i don't like that language
<ryuukk_> cb?.Invoke() ?? false;
<ryuukk_> C#, they solve the problem clean
<travv0> c# has very different design goals compared to zig
<ryuukk_> less type, you see what null check it doesn and what else it does
<travv0> terseness is explicitly not a design goal of zig
<ryuukk_> that is another thing that held the language back, all that stackup end up with unreadable and noisy code
<ikskuh> ryuukk_: c# doesn't have optionals, c# has null propagation
<companion_cube> that's low level languages for you, ryuukk_
<ikskuh> looks similar, is a 100% different operator
<ryuukk_> low lever language mean nothing
<ikskuh> (cb orelse return)(e.event.key_down.key);
<ryuukk_> compiler and runtime makes it low level
<ryuukk_> language is syntax that help solve people's problem
<ifreund> heh, that's a nice one ikskuh
<ikskuh> you have to operate on the optional, not on the return value of your call
<companion_cube> well, having a GC makes a lot of things easier, ryuukk_
<ikskuh> ^= this
<ryuukk_> GC has nothing to do with it
<companion_cube> oh really.
<ryuukk_> ikskuh: i don't want return, can i replace with something like "break" ?
<companion_cube> for example, one thing GC makes much easier: closures.
<ifreund> ryuukk_: no, false isn't a function
<ikskuh> ryuukk_: yes, you can break
<ikskuh> blk: { (cb orelse break :blk)(…) }
<ifreund> oops I can't read
<ikskuh> const result = blk: { break :blk (cb orelse break :blk default_value)(…) };
<ikskuh> which is definitily way less readable than
<ikskuh> const result = if(cb) |c| c(key) else default_value;
<ikskuh> which i find perfectly fine
<ikskuh> as there is control flow happening
<ikskuh> if you want it or not ;)
<dutchie> yeah that is the way i'd do it ikskuh
<ikskuh> the second one?
<ikskuh> yeah, me too
<ikskuh> wonderfully readable imho
<ryuukk_> _ = (processor.key_down orelse break)(e.event.key_down.key);
<ryuukk_> it works
<ryuukk_> i prefer this solution
<ryuukk_> readable, without noise
<ryuukk_> you read it, you understand what it does, no if, no duplicate, no extra typing
<ryuukk_> perfect
<ikskuh> ryuukk_: it breaks your loop
<ikskuh> not the expression
Akuli has joined #zig
<ikskuh> break without block label will always break the enclosing loop
<ryuukk_> i don't understand
<ikskuh> so if you do that in your game main loop (which i assume you are coding), you will exit your game on keydown if no callback exists
<ryuukk_> it'll break the switch case?
<ikskuh> no
<ikskuh> you'll break the enclosing loop
<dutchie> looking back at the original function in https://gist.github.com/ryuukk/24cec3574668e779d19848d90166fc2c
<travv0> it'll break out of the while loop
<ikskuh> you will break while (i < self.processing_queue_C) : (i += 1) {
<ryuukk_> why is that??
<ikskuh> because break will break the enclosing loop.
<ryuukk_> i want break the switch
<dutchie> why not just `if (processor.key_down) |key_down| key_down(e.event.key_down.key)` with no eles
<travv0> zig switch statements don't have falltrough
<ikskuh> give the switch a name
<ikskuh> zig switches aren't breakable
<dutchie> else*
<ryuukk_> dutchie: because i have to type key_down 3 times, i don't want that
<dutchie> so give it a shorter name
<ikskuh> just name it "k" or "cb" or whatever
<dutchie> if (processor.key_down) |kd| kd(e.event.key_down.key)
<travv0> i think your goals and zigs goals are very different
<ryuukk_> it's the same dutchie, i have to type the thing 3 times keydown kd kd
<ryuukk_> it's noise
<ikskuh> then write a function
<ikskuh> which does it
<ikskuh> call_if(key_down, .{ event.foobla });
<ikskuh> one question:
<ikskuh> why does your callback has a return value if you don't use it?
<ryuukk_> i use it but not in EventQueue, the EventQueue is here to forward the events from GLFW callbacks so user can handle them properly
<ikskuh> okay
<ryuukk_> travv0: how can readable be against zig's readable goal?
<ikskuh> was just wondering
<travv0> i find zig very readable
<ikskuh> ryuukk_: i think we have different values of readable
<ikskuh> i dislike any operators that do more than trivial work
<ikskuh> .? is just "access the enclosed value, ignoring the possibility of null"
<travv0> i find terseness makes reading things harder. i have a hard time reading my own null propagation chains sometimes in c#
<ikskuh> ^= yeah, c# can get horribly unreadable in such cases
<dutchie> ikskuh: .? is more than that imo
<ikskuh> or even worse: linq stuff
<ikskuh> dutchie: it isn't
<dutchie> it's "i know this isn't null, just unwrap it"
<ikskuh> well, kinda
<ikskuh> it depends on your view
<ikskuh> it's "access the value"
<ryuukk_> "Hello, i am a humain, a humain on earth, a humain on earth with black hair", you can read it, but the intent is not "readable" repetition is noise
<ikskuh> for release-fast/small, it will just do that and crash
<travv0> human languages and programming languages are not comparable
<ikskuh> ryuukk_: did you mean "hello, i am maybe a human. if i'm a human, call me bob. Bob is now doing stuff."
<ryuukk_> ikskuh: no, null is not type, it to tell if you are here or not
<ryuukk_> "hello, i am here, i am here on earth, i am here on hearth with black hair"
<travv0> hello, i am human? call be bob?? i'm not real
<ikskuh> ryuukk_: "hello, i am here, here is london, london is nice"
<ryuukk_> Hello, is mike here? tell him to call mum or send him a message
<ikskuh> if(condition) |declaration| usage
<ikskuh> you are repeating the condition three times ;)
<ikskuh> afk
<dutchie> https://brpaste.xyz/qVe-jA < that was extremely not what i expected lol
<ifreund> I thought your goal was to "iterate quickly" but 30min later your still on the same line of code
<travv0> dutchie: lol
<ryuukk_> ifreund: that's what frustrate me
<ifreund> UB!
<companion_cube> ryuukk_: have you tried F#? I heard it's good for iterating quickly, and is terser than C# :p
<ryuukk_> i'd stick with C# if it compiled to native and without a GC
<companion_cube> but again, if you don't want a GC, some things become harder, at least in all the languages I've heard of
<travv0> if you don't want a gc then you're gonna have a hard time with terseness
<ifreund> ryuukk_: there's nothing wrong with most of the many solutions you've been shown over the past 30 min
<dutchie> * Focus on code rather than style.
<ryuukk_> ifreund: i know, but it makes things less readable, at least for me, wich is a problem for me
<Nypsie[m]> Would it be possible to restructure it so `key_down` is not an optional?
<ifreund> i suggested that 20min ago :D
<Nypsie[m]> Ah sorry, I'm only looking now and then at the chat.
<ifreund> ryuukk_: they don't make things less readable, incorrect code doesn't count
<travv0> but yeah, not having the function be nullable would be the cleanest solution for sure
<ryuukk_> ifreund: what is incorect code? having to use optionals?
<ifreund> ryuukk_: the foo.?(key) thing you started with
<ifreund> which I assume is what you're comparing against for readability
<ryuukk_> my understanding of that code was: if it is not null, call it
<dutchie> that part is correct
<ryuukk_> the else crash is hidden
<dutchie> no it isn't
<dutchie> it just crashes or gives UB
<Nypsie[m]> It's well defined :)
<ryuukk_> foo.?(key) else false; but it doesn't work
<travv0> and now we're back to where we started lol
<dutchie> .? is different to c# null-coalescing
<Nypsie[m]> Because that's syntatically incorrect
<ryuukk_> so what's the point of having .? ?
<travv0> i'm new to zig but i find it useful in tests
<Nypsie[m]> Shorthand of writing `orelse unreachable`
<ryuukk_> so i should be able to write, orelse false?
<ryuukk_> without using .?
<travv0> no, you can't call false
<travv0> the function is what's optional, not the result
<Nypsie[m]> You could read your example as `(foo orelse unreachable)(key)`
<ifreund> the best way to do this is if (foo) |f| f() else false;
<Nypsie[m]> ^
<Nypsie[m]> I find the structure a bit odd to be honest. You already know it's the key_down event. Why would the function be optional? (just curious btw)
<ryuukk_> if(foo) foo(), why is that not possible?
<Nypsie[m]> Because `foo` is still the optional, and not unwrapped
<ifreund> how about this, instead of making the function optional have a default that always returns false
<ifreund> then you can just call it directly
<ryuukk_> Nypsie[m]: user can register to specific events, so i only forward if he registered to that event type
<Nypsie[m]> Ah I see
<Nypsie[m]> So `key_down` is a callback function, defined by the user.
<Nypsie[m]> Got it :)
<ifreund> so use a default that always returns false if they don't define one
<ryuukk_> yes
<ifreund> then you don't have to deal with the optional
<Nypsie[m]> Yeah I think that's a great suggestion
<ryuukk_> what do you mean a default?
<Nypsie[m]> Define your own callback function that you set, then have it be overriden by the user's if they provide one.
<ryuukk_> oh i see
<ryuukk_> hmm
<ryuukk_> yeah that could work
<ryuukk_> i'll try and see how it goes
tane has joined #zig
donniewest has quit [Read error: Connection reset by peer]
ask6155 has left #zig [#zig]
donniewest has joined #zig
x2C25 has joined #zig
g-w1 has quit [Ping timeout: 256 seconds]
frmdstryr has quit [Remote host closed the connection]
xackus_ has joined #zig
skuzzymiglet has quit [Ping timeout: 260 seconds]
cole-h has joined #zig
frmdstryr has joined #zig
LanceThePants has quit [Read error: Connection reset by peer]
sawzall has joined #zig
sawzall has quit [Read error: Connection reset by peer]
sawzall has joined #zig
frmdstryr has quit [Ping timeout: 240 seconds]
frmdstryr has joined #zig
frmdstryr has quit [Ping timeout: 240 seconds]
g-w1 has joined #zig
luismanfroni has quit [Remote host closed the connection]
luismanfroni has joined #zig
siulManfroni has joined #zig
luismanfroni has quit [Ping timeout: 272 seconds]
frmdstryr has joined #zig
siul_ has joined #zig
g-w1 has quit [Ping timeout: 264 seconds]
siulManfroni has quit [Ping timeout: 264 seconds]
wootehfoot has joined #zig
siul_ has quit [Remote host closed the connection]
siul_ has joined #zig
ryuukk__ has joined #zig
siul_ has quit [Ping timeout: 246 seconds]
<dutchie> blargh, was feeling a bit low, thought i'd do something nice for the zig community and make a PR with the changes I had to make to get the sine example on the webpage working on recent compiler versions
<dutchie> but it got merged months ago! wah
ryuukk_ has quit [Ping timeout: 240 seconds]
<dutchie> ah well, maybe i should just go and do something that doesn't involve computers
luismanfroni has joined #zig
xackus_ has quit [Ping timeout: 256 seconds]
wilsonk_ has quit [Read error: Connection reset by peer]
xackus_ has joined #zig
moo has joined #zig
wootehfoot has quit [Ping timeout: 256 seconds]
frmdstryr has quit [Ping timeout: 260 seconds]
frmdstryr has joined #zig
frmdstryr has quit [Read error: No route to host]
frmdstryr has joined #zig
g-w1 has joined #zig
rx_ has joined #zig
skuzzymiglet has joined #zig
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
siulManfroni has joined #zig
luismanfroni has quit [Ping timeout: 258 seconds]
marnix has quit [Read error: Connection reset by peer]
a_chou has quit [Remote host closed the connection]
marnix has joined #zig
<ryuukk__> hmm
<ryuukk__> error: incompatible types: 'i32' and 'f32'
<ryuukk__> const deltaX: f32 = -self.engine.input.delta_x * self.degrees_per_pixel;
<ryuukk__> it points to the *
<ryuukk__> delta_x is i32
<ryuukk__> why does it complain here?
<ryuukk__> i tried to @floatCast delta_x but same issue
<ryuukk__> error: expected float type, found 'i32'
<x2C25> gotta use @intToFloat
<ryuukk__> thanks
<ryuukk__> return if (value > 0.0) 1 else (if (value < 0.0) -1 else 0);
<ryuukk__> it complain about 1 0 -1 being compttime_int, but i want to return i32
<ryuukk__> how can i make this clean?
<ryuukk__> i tried int cast, as, i32(1) none work
<ryuukk__> can't compiler figure out what i return from the function return type??
<ryuukk__> pub inline fn sign(value: f32) i32
<ikskuh> you have to coerce the first value
<ikskuh> return if(value > 0) @as(i32, 1) else if(value < 0) -1 else 0;
<ikskuh> this should work
<ryuukk__> that's another annoying thing..
<ryuukk__> it stacks up
<ikskuh> hm? comptime_int?
<ikskuh> *shrug*
<ryuukk__> yes, and having to do that to fix the issue
<ikskuh> isn't really a problem if you change your code a bit
<ryuukk__> originally it should look like as simple as this: return v > 0.0 ? 1 : (v < 0.0 ? -1 : 0);
<ikskuh> you kinda hit the only special case
<ryuukk__> had to convert to if else
<ryuukk__> and now add @as
<ikskuh> it doesn't look simple
<ikskuh> not at all
<ikskuh> hard to read
<ryuukk__> @as(i32) for 1st but not all, what abou this?
<ikskuh> you give the statement a type
<ikskuh> which will trigger type coercion
<ryuukk__> ? : is readable
<ikskuh> which will then make your if runtime-viable
<ikskuh> nah, definitly not
<ryuukk__> ? is if, and : is else
<ikskuh> your example is a perfect example for unreadable :D
<ryuukk__> that's math
<ryuukk__> anyways, ok for if else
<ryuukk__> but why i has to @as the 1st and not all?
<ikskuh> because type coercion
<ikskuh> it makes the expression i32, not comptime_int
<ryuukk__> why? pub inline fn sign(value: f32) i32 ask for i32, not competime_int
<ryuukk__> if i return 1; it should be i32
<ikskuh> doesn't work for return afaik
<ikskuh> might be be design, might be a todo in the compiler
<ryuukk__> if that is by design,then it is another inconfistency
<g-w1> I think I heard this somewhere as a todo in the compiler
<ryuukk__> how can such basic thing stay as todo?
<ikskuh> it isn't basic
<ikskuh> type coercion is hard
<ikskuh> super-hard
commander has quit [Ping timeout: 256 seconds]
<ryuukk__> if i use language, all i care about is it works as intended, naturally, people doesn't know what being the scene, if i didn't chat with you, i'd be left with a confused mind
<g-w1> this language is not 1.0 yet
<ryuukk__> that's valid point
<ikskuh> you always have to keep in mind that you're still using an alpha product
<ryuukk__> are you sure it is todo btw?
<ikskuh> unfinished software
<g-w1> im not sure
marnix has quit [Ping timeout: 260 seconds]
ur5us has joined #zig
commander has joined #zig
commander has quit [Remote host closed the connection]
<ryuukk__> it took me multiple minutes to do a simple multiplication
<ryuukk__> ..
<ikskuh> you sure your rounding is correct?
<ryuukk__> i already don't want to touch that part of code anymore
<ikskuh> but is it correct?
<ryuukk__> the original code works yes
<ryuukk__> i ported it from my c++ code
<ikskuh> doesn't mean it was correct there
<ikskuh> is truncation the correct rounding mode?
<ryuukk__> truncation?
<ikskuh> you're converting a float to an integer
<ikskuh> with non-integer scaling
<ikskuh> (otherwise you wouldn't need a float here)
<ryuukk__> i know, i wanted to highlight the amount of noise @ adds
<ryuukk__> in comparison: https://i.imgur.com/JEALvYL.png
<ikskuh> so you get numbers like 3.14 or -2.718
<ikskuh> which can be cast to:
<ikskuh> towards-zero: 3, -2
<ikskuh> towards-inf: 4, -3
<ryuukk__> ??
<ikskuh> floor: 3, -3
<ikskuh> ceil: 4, -2
<ikskuh> which are all correct float-to-int conversion
<ikskuh> which one do you want?
<ryuukk__> so you are telling me this is not casting?
<ryuukk__> how you would translate my c++ code above?
<ryuukk__> in zig
<ikskuh> i don't know ;)
ky0ko has quit [Ping timeout: 265 seconds]
<ikskuh> it probably uses towards-zero/float truncation
<ikskuh> which is what @floatToInt also does (it cuts of the parts after the comma)
<ryuukk__> i have no idea, all i want is to replicate the old behavior
<ikskuh> but is that correct for your code?
<ryuukk__> (float) my_int
<ryuukk__> how do you translate that from c++ to zig?
<ryuukk__> so zig matches c++ behavior
<companion_cube> @as(f32, my_int) I think?
<ikskuh> @intToFloat(f32, my_int)
<ikskuh> also, that isn't good c++ code, it's C code
<ikskuh> c++ would be static_cast<float>(my_int)
<ryuukk__> that is what i used, why tell me it's wrong then?
<companion_cube> ikskuh: oops my bad
<ryuukk__> or there is something you want to tell me that i don't understand?
<ikskuh> ryuukk__: i'm talking about @floatToInt
<ikskuh> so your (int)(…) code
<ryuukk__> oh
<ryuukk__> so how you would do (int) my_float in zig?
<ikskuh> what rounding mode do you want? (i listed them above)
<companion_cube> it's been answered above
<ryuukk__> i want same behavior as the C code
<ikskuh> okay
<ryuukk__> it's not anwsered, he keep telling me i do the wrong thing
<ikskuh> ryuukk__: companion_cube was talking to me
ky0ko has joined #zig
<ryuukk__> oh ok
<ryuukk__> so i do nothing wrong here?
<ryuukk__> i'm confused
<ryuukk__> there should be a @c_cast()
<ikskuh> floating-point to integer implicit conversion and casts (always towards zero)
<ikskuh> i found it
<ryuukk__> so i'm not confused into picking X different things
<ikskuh> use @floatToInt(…)
<ikskuh> looks like it's correct
<ikskuh> does the same as C
<ryuukk__> ok thanks
<ikskuh> ryuukk__: zig is about correctness. C just does a thing implicitly, but zig tells you that there might be a problem when you convert float to int
<ikskuh> as (as explained above) the conversion is ambigious
<ikskuh> and has four modes that can be used which might be correct in all ways
<ikskuh> oh, there's also mathematical rounding
<ikskuh> which rounds to the closest integer part
<ikskuh> and if that is ambigious, rounds towards the next even number
<companion_cube> rounding modes are such a nightmare
<ikskuh> ↑
<ikskuh> ryuukk__: if you want to learn more: https://en.wikipedia.org/wiki/Rounding#Rounding_to_integer
<ikskuh> float to integer conversion is complex
moo has quit [Read error: Connection reset by peer]
wilsonk has joined #zig
<fengb> You can write your own c_cast helper
skuzzymiglet has quit [Ping timeout: 256 seconds]
nycex- has quit [Ping timeout: 240 seconds]
nycex has joined #zig
rx__ has joined #zig
rx_ has quit [Ping timeout: 260 seconds]
rx__ has quit [Client Quit]
<ryuukk__> https://i.imgur.com/ZALreIl.mp4 finally got input working
<ryuukk__> thanks for help
nycex has quit [Remote host closed the connection]
nycex has joined #zig
frmdstryr has quit [Read error: Connection reset by peer]
tane has quit [Quit: Leaving]
frmdstryr has joined #zig
ryuukk__ has quit [Read error: Connection reset by peer]
ryuukk_ has joined #zig
oats has quit [Quit: until later, my friends]
oats has joined #zig
donniewest has quit [Quit: WeeChat 2.9]
<ryuukk_> now textures and model loading and port is complete
<ryuukk_> and animations
radgeRayden has joined #zig
frmdstryr has quit [Read error: No route to host]
frmdstryr has joined #zig
frmdstryr has quit [Ping timeout: 260 seconds]
<ryuukk_> fengb: can i create custom global functions like this @ ?
<ifreund> ryuukk_: no, those are compiler builtins
<ryuukk_> oh ok
<ikskuh> ryuukk_: compiler builtins aren't functions in a "function" sense
<ikskuh> that's why they have the @ prefixed
frmdstryr has joined #zig
<ikskuh> most builtins either map to CPU instructions or map to no runtime code at all
<ikskuh> best example: @intToFloat and @field
<ryuukk_> ok so it's like __traits in D
frmdstryr has quit [Ping timeout: 260 seconds]
Akuli has quit [Quit: Leaving]
omglasers2 has quit [Read error: Connection reset by peer]
data-man has joined #zig
frmdstryr has joined #zig
<data-man> ryuukk_: But you can create functions like @"anyname". E.g. fn @"+="(v: f32) :)
<ryuukk_> hmm interesting, data-man
<ryuukk_> how can you call it?
<ryuukk_> with @"+="(5.0) like that?
frmdstryr has quit [Ping timeout: 256 seconds]
frmdstryr has joined #zig
data-man has quit [Quit: Konversation terminated!]
kristoff_it2 has quit [Ping timeout: 256 seconds]
ryuukk__ has joined #zig
ryuukk_ has quit [Read error: Connection reset by peer]
a92 has joined #zig
earnestly has quit [Ping timeout: 260 seconds]