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/
<Kena> The lsb?
<Kena> I'm a beginner, I'm not aware of all the jargon.
ur5us_ has joined #zig
<ifreund> least significant bit
<Kena> fengb, I'm planning to watch your youtube video regarding to memory allocators. Do you think it's still relevant in spite of it was published several months ago?
<ifreund> yes it is
<Kena> Thanks ifreund
<Kena> The function now works but the initial goal was to learn alignment mechanism because I'm trying to read RISCV-V Assembly Language by Anthony J. Dos Reis. I regret nevertheless that Zig assumes the byte as the smallest addressable unit. It would have been nice to work with embedded devices and micro-controllers in Zig.
<ifreund> you totally can
<Kena> Verilog is C-syntax derived after all so Zig could have compete for a sort of backed for Hardware Description Language.
<Kena> Really?
<Kena> s/backed/back-end
<ifreund> anything c can do zig can (or will be able to) do
<Snektron> Kena: there are pointers to values which have bit offsets
<Snektron> packed structs would also get you quite far (if they worked)
<ifreund> they work great if you just fill them up with bools
<Snektron> anything that results in byte aligned units
<Kena> Allright :)
Kena has quit [Remote host closed the connection]
a92 has joined #zig
CodeSpelunker has joined #zig
earnestly has quit [Ping timeout: 246 seconds]
CodeSpelunker has quit [Quit: CodeSpelunker]
<teratorn_> hi all, anyone want to take a stab why my len variable is getting corrupted and printing a really big number? http://0x0.st/in3-.zig
<andrewrk> damn the CI is erroring again
<teratorn_> how can i find the asm code that corresponds to dereferencing out_len var? on godbolt.org??
<a92> Godbolt is one good way, yes
<g-w1> could it be returning 1 exit code because of the thing you added to fix the self-hosted compiler returning 0 if there were compile errors andrewrk?
<andrewrk> g-w1, in this case it would be printing a compile error as well
<g-w1> although it is weird that its only on sourcehut
<teratorn_> a92, but how to isolate that specific asm code?
<a92> I think Godbolt shows association; mouse over the assembly
<g-w1> it has -Dskip-compile-errors, could that be triggering it?
<andrewrk> g-w1, that skips the tests that cause compile errors and check the output; it does not silence stderr
<g-w1> ah that is what i though.
<travv0> teratorn_: the long series of letters and digits is your hexadecimal output from the while loop, not your length
<travv0> if you put a newline after your length output it'll show what you'd expect
<teratorn_> fugggggg
<teratorn_> travv0, good catch
<travv0> :P
<travv0> lol it took me a few to figure it out
osa1_ has joined #zig
<teratorn_> great help here lol
teratorn_ is now known as teratorn
<teratorn> want to just write my code for me it will go faster
<travv0> if it's an interesting enough project :P
osa1 has quit [Ping timeout: 264 seconds]
Guest85216 is now known as wilsonk
drefr3 has joined #zig
<drefr3> Hi. I want to ask why std.math.absCast use~@bitCast(Uint, x +% -1) instead of @bitCast(Uint, -%x) to get the abs of int?
zippoh has joined #zig
drefr3 has quit [Remote host closed the connection]
a92 has quit [Quit: My presence will now cease]
<daurnimator> drefr3: corner cases around i0/i1 IIRC.
drefr3 has joined #zig
drefr3 has quit [Remote host closed the connection]
<justin_smith> for example, for signed byte the range is -128,127, asking for the negation of -128 would be an error (or require upgrade to a larger bit count)
<justin_smith> absCast only takes ints, but I don't have that range memorized
<daurnimator> justin_smith: we do upgrade it
<daurnimator> justin_smith: absCast returns an unsigned integer with the same number of bits as the passed integer.
<justin_smith> 'm looking at old code, or misunderstanding the code, in that case...
<daurnimator> unsigned you get an extra bit :)
<justin_smith> but the math is done before the upgrade
<daurnimator> yes. but it's done with wraparound arithmetic; and then a bitcast
<daurnimator> The key reason it's written the way it is, is so that `@as(i1, -1)` becomes `@as(u1, 1)`
<justin_smith> daurnimator: right, wraparound arithmatic is safe, negation isn't
<justin_smith> where il is signed int and ul as unsigned int?
<daurnimator> justin_smith: yes.... that's what the `i` and `u` mean in zig
<justin_smith> daurnimator: I assumed the 'l' was long, which absCast can't process
<justin_smith> oh, I see "Integer" isn't a specific width, it's an integral value of any number of bits
xackus_ has joined #zig
xackus has quit [Ping timeout: 258 seconds]
dref3 has joined #zig
dref3 has quit [Remote host closed the connection]
drefr3 has joined #zig
<drefr3> thanks, daurnimator. But I notice that -%x still work while the type is i0/1: in the case of i1, -1, and -%(-1) = -1(1, in binary) after @bitCast to Uint, we get 1.
<drefr3> and tests still pass
drefr3 has quit [Remote host closed the connection]
drefr3 has joined #zig
<drefr3> in the case of i0, i0 can only represent 0, so if(x<0){...} won't be executed
drefr3 has quit [Remote host closed the connection]
Jeanne-Kamikaze has joined #zig
ur5us_ has quit [Ping timeout: 264 seconds]
Core3159 has joined #zig
Core3159 has quit [Read error: Connection reset by peer]
Core3159 has joined #zig
Core3159 has quit [Ping timeout: 265 seconds]
Core3159 has joined #zig
Core3159 has quit [Read error: Connection reset by peer]
marnix has joined #zig
<daurnimator> justin_smith: there was no l; you might need a font that makes it easier to disambiguate i,1,l,I :)
osa1_ has quit [Quit: osa1_]
osa1 has joined #zig
Jeanne-Kamikaze has quit [Ping timeout: 246 seconds]
Core3159 has joined #zig
Core3159 has quit [Remote host closed the connection]
waleee-cl has quit [Quit: Connection closed for inactivity]
lucid_0x80 has joined #zig
lltt has quit [Ping timeout: 246 seconds]
g-w1 has quit [Ping timeout: 265 seconds]
g-w1 has joined #zig
lucid_0x80 has quit [Ping timeout: 258 seconds]
sord937 has joined #zig
lltt has joined #zig
marnix has quit [Ping timeout: 240 seconds]
marnix has joined #zig
Ristovski has quit [Quit: 0]
[Ristovski] has joined #zig
cole-h has quit [Ping timeout: 240 seconds]
tane_ has joined #zig
Core3159 has joined #zig
<Core3159> daurnimator, how do you think about it? Please correct me if i am wrong
Core3159 has left #zig [#zig]
drefr3 has joined #zig
drefr3 has quit [Read error: Connection reset by peer]
Core3159 has joined #zig
<Core3159> em.. I'm drefr3
Core3159 has quit [Read error: Connection reset by peer]
plakband has quit [Quit: WeeChat 2.9]
earnestly has joined #zig
lucid_0x80 has joined #zig
lucid_0x80 has quit [Ping timeout: 240 seconds]
osa1 has quit [Remote host closed the connection]
osa1 has joined #zig
xackus_ has quit [Ping timeout: 265 seconds]
lucid_0x80 has joined #zig
dumenci has joined #zig
lucid_0x80 has quit [Ping timeout: 260 seconds]
dumenci has quit [Remote host closed the connection]
Ashpool has joined #zig
hnOsmium0001 has quit [Quit: Connection closed for inactivity]
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
klltkr has joined #zig
[Ristovski] is now known as Ristovski
leah2 has quit [Remote host closed the connection]
leah2 has joined #zig
omglasers2 has joined #zig
mmx870 has quit [Quit: Ping timeout (120 seconds)]
mmx870 has joined #zig
lltt has quit [Ping timeout: 272 seconds]
klltkr has quit [Quit: Textual IRC Client: www.textualapp.com]
nvmd has joined #zig
donniewest has joined #zig
swills has quit [Quit: swills]
swills has joined #zig
Ashpool has quit [Quit: Leaving]
wilsonk has quit [Quit: Leaving]
wilsonk_ has quit [Quit: Leaving]
wilsonk has joined #zig
waleee-cl has joined #zig
SimonNa has quit [Read error: Connection reset by peer]
SimonNa has joined #zig
xackus_ has joined #zig
GrooveStomp has joined #zig
lucid_0x80 has joined #zig
aerona has joined #zig
hnOsmium0001 has joined #zig
Kena has joined #zig
<Kena> Hello, when I try to build `const file = try std.fs.cwd().createFile("my_file.txt", .{ .read = true });` I got `error: expected type 'void', found 'std.fs.file.OpenError'`
<alexnask[m]> Your function does not return an error union, just void
<Kena> But OpenError is an Error set, how can I know the error value?
<alexnask[m]> Make it !void
<alexnask[m]> This is a confusing error message though I thought someone had fixed it a while ago :/ Probably just in specific circumstances
<Kena> Thank you!
<g-w1> it seems like the syntax should be correct, but both the self hosted parser and c++ parser flag it
TheLemonMan has joined #zig
<ifreund> g-w1: get rid of the first semicolon
<ifreund> if () foo else bar;
<ifreund> all one statement
<g-w1> ah, so its a statement, thanks
<marler8997__> I just commented on this issue: https://github.com/ziglang/zig/issues/6984 I think it can be closed if a maintainer wants to take a look
<hch> how to pass args from cli to my main function?
<marler8997__> grep for argsAllocator
<g-w1> std.process.argsAlloc
<hch> thanks
<g-w1> it seems std.process.args() is better if you just want to iterate through them
Kena has quit [Remote host closed the connection]
<hch> that was helpful. the WASI section actually has an example
Piraty has left #zig ["--"]
cole-h has joined #zig
<marler8997__> ifruend, it looks like kakoune doesn't work on windows?
lltt has joined #zig
<waleee-cl> marler8997__: not even the builtin-ui branch?
<waleee-cl> ah, right, "no native Windows version is planned"
notpiika has quit [Ping timeout: 256 seconds]
Mat5 has joined #zig
<yZ5vlALg86lP> is there somehow an example how to link some parts of a project into a static library and then link that static lib to one of the final executables? looking at build.zig, but its not immediately obvious
<yZ5vlALg86lP> s/somehow/somewhere/
<ikskuh> builder.addStaticLibrary
<ikskuh> exe.addLibrary(return_vaue_of_the_previous)
<yZ5vlALg86lP> oh. nice
<Nypsie[m]> Wouldn't it be better to directly use exe.addPackage() (If it's a Zig library)?
<yZ5vlALg86lP> no actually the static lib is made of .c files
<Nypsie[m]> Got it :)
<yZ5vlALg86lP> but i did not specify that in my original question.
<Nypsie[m]> Oh no worries. Now you know both ways if you'd create a Zig library :)
skuzzymiglet has joined #zig
<yZ5vlALg86lP> this leads me to the question how to pass a bunch of c files to this addstaticlibrary()?
<Nypsie[m]> lib.addCSourceFile()
<yZ5vlALg86lP> in which case lib is the object that is returned by addstaticlibrary?
<Nypsie[m]> Correct
notpiika has joined #zig
lucid_0x80 has quit [Ping timeout: 272 seconds]
<yZ5vlALg86lP> huh i get: > error: no member named 'addLibrary' in struct 'std.build.LibExeObjStep'
<g-w1> will there ever be a comptime debugger?
<g-w1> because right now gdb gets very confused when i try to use comptime stuff in it
<Nypsie[m]> Hmm don't think so?
<Nypsie[m]> Since the logic lives inside the compiler I guess
<g-w1> will the compiler ever support it, i guess my question was
<Nypsie[m]> Would be great, but I don't think it will
<Nypsie[m]> Using @compileLog/Error is quite limited, I agree :P
<Nypsie[m]> yZ5vlALg86lP: Use `exe.addObject(your_static_library_result_here)`
<Nypsie[m]> or `linkLibrary`
<Nypsie[m]> (which is being called by the above function)
<g-w1> my use case was trying to view comptime arguments to a function at runtime. maybe the compiler/debugger could be smart enough to fill in the comptime args in the debuginfo
<yZ5vlALg86lP> thx Nypsie[m] !
<Nypsie[m]> g-w1: Aaah I see. I do believe though, that Stage 2 emits its own Dwarf files (which DWARF already supports I believe). However, that would also mean gdb needs to update their dwarf stuff.
<Nypsie[m]> So maybe in stage2 that particular use case might just work
<alexnask[m]> Yes it should be possible
<g-w1> thats cool!
<TheLemonMan> andrewrk, did you like the @setScopeOptions proposal? *finger guns*
lucid_0x80 has joined #zig
lucid_0x80 has quit [Ping timeout: 246 seconds]
xackus_ has quit [Ping timeout: 260 seconds]
LanceThePants has quit [Read error: Connection reset by peer]
LanceThePants has joined #zig
LanceThePants has quit [Read error: Connection reset by peer]
LanceThePants has joined #zig
ur5us_ has joined #zig
GrooveStomp has quit [Remote host closed the connection]
amk has quit [Remote host closed the connection]
GrooveStomp has joined #zig
amk has joined #zig
<marler8997__> TheLemonMan, why was that issue closed?
<marler8997__> I mean PR
Mat5 has quit [Quit: Leaving]
<TheLemonMan> marler8997__, I fixed the unrolling problem in another PR
<marler8997__> ok
GrooveStomp_ has joined #zig
GrooveStomp has quit [Ping timeout: 260 seconds]
<hch> is there atoi or simiar?
<frmdstryr> std.fmt.charToDigit
<Nypsie[m]> `std.fmt.parseInt`
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
riba has joined #zig
marnix has quit [Ping timeout: 265 seconds]
a92 has joined #zig
<Ristovski> std docs still on 0.6.0 :(
<g-w1> iirc they have to manually be updated
<Ristovski> indeed, automation of that is on some todo iirc
<ikskuh> huh
<ikskuh> std.os.write triggers EFAUL
<ikskuh> *EFAULT which is marked unreachable
skuzzymiglet has quit [Ping timeout: 260 seconds]
Kena has joined #zig
<Kena> fengb I'm grateful for your "What's a memory allocator anyway?" video, you're brilliant dude.
sord937 has quit [Quit: sord937]
dimenus has joined #zig
<Kena> I hope you'll plan a round 2 or even an addendum to talk in more details about segments of memory on top/bottom of the buffer tactics, the benefits of using swapping into global space and the buffer overrun workaround consisting in writing in a additional buffer!
donniewest has quit [Quit: WeeChat 3.0]
<fengb> Thanks
<fengb> That talk was stretching my knowledge already :P
alexnask[m] has quit [Ping timeout: 260 seconds]
alexnask[m] has joined #zig
<Kena> You made me laugh when you declared that was a topic with which you're not particularly familiar with ^^ I wonder what your streams look like when you tame the topic.
<andrewrk> TheLemonMan, gonna have to get back to you on that, I'm moving today
<andrewrk> the good news is I'll be done and all set up with my own office by this weekend :)
<TheLemonMan> no problemo, good luck with the move heh
Core3159 has joined #zig
<Core3159> Hello. math.absCast use ~@bitCast(....., x+% -1). but I think @bitCast(.....x-%1) works too. am I wrong
<Core3159> sorry . I mean @bitCast(...,-%x)
Core3159 has quit [Read error: Connection reset by peer]
TheLemonMan has quit [Quit: "It's now safe to turn off your computer."]
tane_ has quit [Quit: Leaving]
<justin_smith> daurnimator: that reminds me of our convo yesterday - the case of 1 bit is the easiest example of what I was saying - the operation is done before the bitcast, x * -1 won't have the right answer for the minimum possible signed int (easiest to see the problem with 1 bit, but you get a similar problem with any bit count)
<fengb> I definitely did not know anything about allocators before Zig
<Kena> Did you implement randomizing pages for zee-aloc?
<Kena> My bad, you do use slab instead of pages, so there is no overlapping data segments.
<Kena> I wonder why did you stop its development, neither why nobody jumped in to help you as it is a public repository.
<fengb> I have a slab branch and it works
xmn11 has quit [Ping timeout: 260 seconds]
dimenus has quit [Quit: WeeChat 2.9]
xmn11 has joined #zig
<fengb> But it’s an extra 500 bytes in size so I haven’t merged it in yet
<fengb> Also haven’t run tests to prove it’s faster either
omglasers2 has quit [Read error: Connection reset by peer]
<Kena> Understood :) I hope you'll achieve some progress on your project, as WebAssembly could gain some traction if and/or when emscripten is stabilized.
a92 has quit [Quit: My presence will now cease]
SimonN has joined #zig
SimonNa has quit [Ping timeout: 264 seconds]
Kena has quit [Remote host closed the connection]
nvmd has quit [Quit: Later nerds.]
Kingsquee has joined #zig