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/
<daurnimator> marijnfs_: yeah.... you can't just tell a piece of code to keep going when it threw an error...
rjtobin has quit [Ping timeout: 250 seconds]
<shakesoda> this isn't particularly unusual code, rhs is just offsetof
<daurnimator> `((ENetProtocolHeader *) 0) -> sentTime` isn't that a straight up null pointer dereference?
<shakesoda> it's `(size_t)&(t*)0->field)` is offsetof(t, field) heh
<shakesoda> s/it's//
<shakesoda> C is bizarre
<shakesoda> https://en.wikipedia.org/wiki/Offsetof <- even this mentions there's some debate about it
<shakesoda> but it doesn't actually access the memory
<shakesoda> i ended up building the library with vcpkg and linking that version for now
<daurnimator> huh. TIL the (old) implementation of offsetof
<shakesoda> Snektron: wonderful, this will be useful
<shakesoda> thanks
<Snektron> Its getting late here so i kinda cut corners after i wrote partialRadixSort
dermetfan has quit [Ping timeout: 256 seconds]
<Snektron> You can see it needs a temporary buffer to sort into, and a small amount of stack memory to keep the prefix sum
adamkowalski has quit [Quit: Lost terminal]
<Snektron> Cheeky test showed 14.7 seconds to sort 100M u32's with std.sort.sort, and only 3 with this
<shakesoda> I'll have to try that with my other sorts too
<Snektron> you need to do some tricks to make it work for signed integers though
<Snektron> I think you can also sort floats with it, if theyre normalized
<Snektron> I can update it later with the in-place variant added
diltsman has joined #zig
<diltsman> What are the rules for "self: *MyType" vs "self: MyType"?
<Snektron> Use *MyType if you want to write to self
<diltsman> So, drop the * when the function won't modify the object?
jwh is now known as jwh_
<marijnfs_> c and zig interaction is much nicer now
<fengb> diltsman: yep that’s true in general. Without the *, Zig can choose to pass by value or reference depending on which is faster
<diltsman> For this file: https://github.com/Diltsman/ZigLsp/blob/master/main.zig I am getting errors in stringify, starting with this error: error: expected type '*ExpandingBuffer', found '*const ExpandingBuffer'
<diltsman> As near as I can tell, the variable buffer shouldn't be const.
<daurnimator> diltsman: you don't implement a stream like that
<diltsman> Is there documentation on how to implement a stream somewhere?
<daurnimator> you use io.OutStream to get an out stream
<daurnimator> Also for an expanding buffer, see ArrayList and LinearFifo.\
<fengb> lol... the ArrayList version hasn’t been merged yet. I already recommended it :P
<daurnimator> oh wow; why hasn't it been merged
<daurnimator> oh lol, I forgot that *I* made that PR
<daurnimator> looks like there are merge conflicts; I should rebase
<diltsman> I accept that I need to rewrite to use io.OutStream. Is there something obvious that I did that causes it to think that the buffer is const?
<daurnimator> diltsman: parameters are const.
<diltsman> Are talking about the out_stream parameter for stringify()?
<daurnimator> yes
<diltsman> Thanks. New languages always have a bit of a learning curve.
<fengb> You’re doing it wrong™
jwh_ has left #zig [#zig]
<daurnimator> So..... anyone able to help me compile zig against a fresh llvm build?
<daurnimator> Is there a way to ask cmake for a list of build options?
<andrewrk> daurnimator, maybe this can help: https://github.com/ziglang/bootstrap/blob/master/build
<daurnimator> I'm trying to do it without a ~/local or other common "build" directory
<daurnimator> i.e. I want to invoke zig's cmake something like: `cmake -DLLVM_DIR=../../llvm-project/build ..`
ur5us has joined #zig
diltsman has quit [Remote host closed the connection]
<fengb> Is it spring cleaning time?
<mikdusan> daurnimator: when you invoke cmake's build, this option is where it finds llvm stuff: -DCMAKE_PREFIX_PATH=/opt/llvm-10.0.0
<mikdusan> correction; when you invoke zig's cmake build
<daurnimator> mikdusan: > I'm trying to do it without a ~/local or other common "build" directory
dermetfan has joined #zig
<mikdusan> ok so DCMAKE_PREFIX_PATH=../../llvm-project/build
<mikdusan> but i am not sure if an "uninstalled" llvm is usable
<daurnimator> mikdusan: it is... but paths returned by e.g. llvm-config aren't going to be correct
<mikdusan> is that the goal? build llvm and do not install, then build zig ?
marijnfs1 has joined #zig
marijnfs has quit [Ping timeout: 250 seconds]
<marijnfs_> are there some tricks to do closures?
marijnfs has joined #zig
marijnfs2 has joined #zig
marijnfs_ has quit [Ping timeout: 256 seconds]
dermetfan has quit [Ping timeout: 246 seconds]
nephele_ has joined #zig
dingenskirchen has quit [Remote host closed the connection]
dingenskirchen has joined #zig
marijnfs2 has quit [Client Quit]
marijnfs has quit [Quit: Lost terminal]
nephele has quit [Ping timeout: 256 seconds]
<daurnimator> mikdusan: yes
<shakesoda> are there any good examples for std.json
<shakesoda> the tests are kind of cryptic as examples
<daurnimator> andrewrk: thoughts on a packed bit array being created with: `[4]align(0) u2` ?
<daurnimator> shakesoda: the autojson facility?
<daurnimator> shakesoda: serialisation or deserialisation?
<shakesoda> deserialization
<daurnimator> shakesoda: the examples aren't that cryptic at all... `try parse(bool, &TokenStream.init("false"), ParseOptions{})` => parse the string "false" into a `bool`.
<shakesoda> well, i wasn't looking for the right thing it seems
<shakesoda> thanks
<daurnimator> I want to refactor it: get rid of the separate lexing and tokenisation. if you're parsing into a `bool` then if you see anything that isn't a 't' or an 'f' then you can immediately bail out
ur5us has quit [Ping timeout: 256 seconds]
r4pr0n has quit [Quit: r4pr0n]
hobomatic has joined #zig
hobomatic has quit [Quit: poof]
ky0ko_ has quit [Quit: http://quassel-irc.org - Chat comfortably. Anywhere.]
ky0ko_ has joined #zig
<yrashk> Is there a way for build.cfg to use a libc allocator?
<yrashk> err, build.zig :)
<junon> daurnimator: I tried doing what you're trying to do just the other day and couldn't get it to work (I'm not exactly 'bad' at cmake, either). I don't think llvm-config was handing out strange paths IIRC. I just ended up installing llvm system wide and building zig, but it would be nice to be able to do it how you're wanting to do it, too.
waleee-cl has quit [Quit: Connection closed for inactivity]
layneson has quit [Quit: Leaving]
mahmudov has quit [Ping timeout: 256 seconds]
mahmudov has joined #zig
dddddd has quit [Remote host closed the connection]
<daurnimator> andrewrk: 4665 rebased.
<mikdusan> daurnimator: I took a quick look at building against un-installed llvm+clang+lld build dir. While llvm-config may be quite clever, the include/ are not yet consolodated; for example clang would need includes from both that build/ and also from clang/ source tree. I suspect same for lld and maybe even llvm. libdir might be fairily straightfwd for archive.a
<daurnimator> mikdusan: yeah I ended up doing it all in a temporary directory for now :(
daex has quit [Ping timeout: 256 seconds]
daex has joined #zig
darithorn has quit [Quit: Leaving]
_whitelogger has joined #zig
_whitelogger has joined #zig
cole-h has quit [Quit: Goodbye]
_whitelogger has joined #zig
marmotini_ has joined #zig
marmotini_ has quit [Read error: Connection reset by peer]
ur5us has joined #zig
kenaryn has joined #zig
<kenaryn> andrewk: Does this pull request could help improve std.sort? It is based on GrailSort, another implementation of wikiSort based on the same research paper.
Cogitri has joined #zig
<Cogitri> Hello. I'm sure this has been asked too often in the last days, but is there an ETA for the next release? I'm currently bumping LLVM to 10.x on Alpine Linux and Zig isn't compatible with that as of now
<Cogitri> We do have multiple versions versions of LLVM in our repos for such cases, but we don't have that for clang and lld and I'm pretty sure that mixing major versions between llvm/clang/lld is a recipe for certain doom
<daurnimator> Cogitri: april 13
<daurnimator> Cogitri: dates in https://github.com/ziglang/zig/milestones should be considered accurate
<Cogitri> Ah, okay. I suppose there aren't some seperate patches for LLVM10, so how stable is git so we can use that in the meantime?
<Cogitri> We can't really wait until April 13 + testing to upgrade LLVM10 since Alpine 3.12 is due in May and I want more than 15 days for testing all of that
<Cogitri> (The change only affects Alpine Linux Edge, the stable 3.11 release will keep using zig 0.5 w/ LLVM9)
<daurnimator> Cogitri: LLVM 10 was merged into master just a few days ago
<daurnimator> git master is about as stable as the 0.5.0 was
<Cogitri> Alrighty, I guess we'll switch to that for the time being then. Thanks!
kenaryn has left #zig ["WeeChat 2.3"]
jjido has joined #zig
mps has joined #zig
dingenskirchen has quit [Quit: dingenskirchen]
dingenskirchen has joined #zig
ur5us has quit [Ping timeout: 240 seconds]
slowtyper has joined #zig
dermetfan has joined #zig
mahmudov has quit [Ping timeout: 265 seconds]
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
mahmudov has joined #zig
jjido has joined #zig
marijnfs has joined #zig
r4pr0n has joined #zig
SimonNa has joined #zig
_Vi has joined #zig
<mps> which git commit is safe enough to upgrade zig on alpine linux
marijnfs_ has joined #zig
marijnfs has quit [Ping timeout: 265 seconds]
dingenskirchen has quit [Remote host closed the connection]
dingenskirchen has joined #zig
<ifreund> mps: I believe master is trending towards stability, so probably just the most recent?
<ifreund> 0.6.0 is scheduled for april 13th
<mps> yes, I'm noted this morning about schedule for 0.6.0
<mps> but we need to build zig with llvm10 before alpine freeze, which will be soon
marmotini_ has joined #zig
marmotini_ has quit [Ping timeout: 258 seconds]
marijnfs has joined #zig
marijnfs_ has quit [Ping timeout: 258 seconds]
dddddd has joined #zig
mahmudov has quit [Ping timeout: 264 seconds]
marijnfs_ has joined #zig
marijnfs has quit [Ping timeout: 252 seconds]
<daurnimator> hmmm, no nice way to set errno in zig?
<daurnimator> `std.c._errno().* =` I guess...
<daurnimator> no mention of `noasync` in the manual
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
dermetfan has quit [Ping timeout: 252 seconds]
marijnfs has joined #zig
marijnfs_ has quit [Ping timeout: 256 seconds]
waleee-cl has joined #zig
daex has quit [Ping timeout: 256 seconds]
daex has joined #zig
marijnfs_ has joined #zig
daex_ has joined #zig
daex has quit [Ping timeout: 256 seconds]
marijnfs has quit [Ping timeout: 252 seconds]
mahmudov has joined #zig
dermetfan has joined #zig
Xatenev has joined #zig
marijnfs has joined #zig
marijnfs_ has quit [Ping timeout: 252 seconds]
<marijnfs> can i pass a switch statement to a function as an argument?
mahmudov has quit [Remote host closed the connection]
<ifreund> if you put it inside a function, sure
<ifreund> 3
<marijnfs> to make an anymous function it has to be defined in a struct right?
<marijnfs> like .{ fn bla() void {stuff}}.bla?
<fengb> Yeah
<fengb> struct { fn blah }.blah
<pmwhite> Aren't switch statements treated as expressions?
<fengb> They can be yes
<pmwhite> So couldn't you pass a switch statement directly as an argument to a function?
<fengb> You should be yes
<ifreund> i thought the goal was to apply the switch statement within the function
<pmwhite> you could be right that that was the question.
<mps> andrewrk: I'm preparing zig upgrade on alpine linux, is the fix-build.zig.patch (you posted to me some time ago) is still needed?
dermetfan has quit [Ping timeout: 252 seconds]
<ifreund> mps: I think that was fixed by https://github.com/ziglang/zig/pull/4832
<mps> ifreund: thanks for info, will test when the llvm10 build on alpine
<ifreund> cool, no problem
<marijnfs> pmwhite: what type should the argument be then?
<marijnfs> to pass a switch
<ifreund> you wouldn't be passing a switch, but the result of a switch. so what ever the switch breaks with
<pmwhite> yeah, ifreund is right. I misunderstood what you are asking.
<marijnfs> yeah i see, you can't use the switch as a function type or something and pass it
<pmwhite> for example, `f(switch(x) { else => 5 })` is equivalent to `f(5)`
<ifreund> not currently, though I think nicer anon functions are planned
<andrewrk> mps, can you try it with no patches and tell me if it works?
<mps> andrewrk: ofc, but waiting till llvm10 is built. when it finish I'll test and inform you
jjido has joined #zig
<andrewrk> my goal is no patches needed on any os
<mps> nice goal :)
nephele_ is now known as nephele
marijnfs has quit [Ping timeout: 252 seconds]
darithorn has joined #zig
marijnfs has joined #zig
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
_whitelogger has joined #zig
dermetfan has joined #zig
waleee-cl has quit [Quit: Connection closed for inactivity]
mahmudov has joined #zig
jjido has joined #zig
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
cole-h has joined #zig
frett27 has joined #zig
TheLemonMan has joined #zig
<shakesoda> Snektron: this radix sort is significantly faster than the one I wrote
<shakesoda> very nice
jjido has joined #zig
<Snektron> :) nice
<TheLemonMan> andrewrk, yo
<Snektron> Its such a nice algorithm too
<Snektron> I took a look at porting the GPU version, but it requires some intrinsics which i think are avx512
<andrewrk> yo
<Snektron> yeah you need a scatter operation, and those were only added in avx 512
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<Snektron> (even though the scatter would never cause memory problems)
<TheLemonMan> andrewrk, wrt #4840, should we just allow the user to index the sentinel as any other element?
<TheLemonMan> the comptime machinery doesn't reserve a slot for the len+1 element as it assumes the sentinel is there and is correct
<andrewrk> I was just about to look into that
<TheLemonMan> wunderbar, I'll jump to the next question then
<TheLemonMan> NetBSD libc requires us to use a few non-standard names (eg. fstat -> __fstat50), I did that for a few occurrences that happened to break the tests but I've discovered that there are many more
<TheLemonMan> I'm not sure if we can do something better than the status quo (select the symbol name with a switch and then call it with @field(sym_name)(args...)
<andrewrk> 2 things: (1) setting the sentinel to 0 manually should not be required; it is supposed to be set by the variable declaration. (2) maybe it should be allowed to "mutate" comptime memory, even if the pointer is const, when the value would not be changed?
<andrewrk> regarding weird names, could we perhaps put the extern name correctly in c.zig and then make an alias?
<TheLemonMan> hmm, thinking more about the sentinel issue, what does &array[sentinel_idx] return?
<TheLemonMan> hmm, we can put the versioned names in c/netbsd.zig (or whatever the path is) and then have std/c.zig pick those and define some aliases if the os is NetBSD
<andrewrk> yeah that makes sense to me
<TheLemonMan> lel, all the sentinels have the same address
<andrewrk> hmm that's a bug
<TheLemonMan> not really, llvm generates a different constant for each one
<TheLemonMan> but they have a completely different address
<andrewrk> the sentinel is supposed to be in memory adjacent to the rest of the array
<TheLemonMan> they're in .rodata or .bss or god knows where
<andrewrk> it would be legal for a zig program to ptrtoint and subtract to read data from the array before the sentinel
dddddd has quit [Ping timeout: 256 seconds]
<lunamn> andrewrk: is there a specific reason why std.net.Address.parseIp6 does not support alphanumerical scope IDs (e.g %wlp3s0)? I'm tracking down how to do it and it involves creating sockets and doing ioctls (how musl does it), but I'm not sure if that should be put in parseIp6...
<andrewrk> lunamn, hmm it seems like a code smell that parsing an addr would involve any syscalls. maybe that should be a different function called "resolveIp6" or something
<lunamn> andrewrk, would that be an okay change to do? I think we can still peek parseIp6, but guide everyone to using resolveIp6
<lunamn> s/peek/keep
<andrewrk> that sounds reasonable to me
<ifreund> hmm this feels a little weird, but i think it's actually a pretty clean way to do logging https://paste.rs/KmY
<TheLemonMan> ifreund, hm, iirc the enum to ordinal mapping is left unspecified for non extern enums
<ifreund> guess I should probably explictly set them then, it did seem to work as intended from brief testing though
<TheLemonMan> the compiler atm doesn't take advantage of none of those extra degrees of freedom
<ifreund> i quite like the syntax of `Log.Error.log("I messed up", .{});`
waleee-cl has joined #zig
<andrewrk> ifreund, you may be interested in https://github.com/ziglang/zig/issues/2586
<frett27> hi, i switched to llvm - 10, on master, i got an undefined reference at link : référence indéfinie vers « getPollyPluginInfo() , what may i missed ?
<frett27> andrewrk, ok thank's
<Sphax> Hello. I'm wondering if there's an easy way that I missed to get a enum value from its name
<mikdusan> std.meta.stringToEnum() ?
<frett27> works like a charm :-)
<mps> andrewrk: build log on alpine edge is here http://tpaste.us/yZXk
<mps> source is zig commit 86795c03f918dbcc0fc06811cc7c496d275deae1
<Sphax> mikdusan: thank you
<mps> oh, looks like lld is not yet upgraded
<mps> will check tomorrow again
TheLemonMan has quit [Quit: "It's now safe to turn off your computer."]
<ifreund> andrewrk: that looks pretty neat, are you hinting that I should implement it :D
ur5us has joined #zig
<junon> andrewrk: does the zig compiler have suggestive functionality/autocomplete to any degree? Would love to integrate it with ncm so I get hints inside my editor.
rjtobin has joined #zig
jjido has joined #zig
<Snektron> Since the zig parser is part of the standard library, i think you can implement autocomplete to a certain degree pretty easily
<Snektron> Although i guess the parser needs to be able to recover and im not sure if it can do that
<pmwhite> At the very least, it could autocomplete from the last successful parse, which is not useless at all.
* daurnimator frowns. I think I've rebased https://github.com/ziglang/zig/pull/4602 4 times now
<pixelherodev> Figured out why Zig wasn't building
<pixelherodev> Due to the tweaked ebuilds not installing correctly, I had to manually install the Clang libs
<pixelherodev> I forgot to rerun `ninja install` in the abi_64 folder
<pixelherodev> The only libs it was finding were the 32-bit ones :P
<pixelherodev> Got it built now :D
jonathon has quit [Quit: https://quassel-irc.org - Chat comfortably. Anywhere.]
jonathon has joined #zig
frett27 has quit [Ping timeout: 256 seconds]
reductum has joined #zig
<pixelherodev> There's a bit of overhead for the network parts, but overall it still makes compilation faster :D
<pixelherodev> Pushes `src/` and `build.zig` over, runs `zig $@`, pulls `zig-cache` back
<pixelherodev> Time for just the build locally is 5.216 seconds, time to do that is 4.062, so this actually helps
<afontain_> Did somebody try to use SDL from Zig?
<pixelherodev> Andrew did IIRC
<pixelherodev> In one of the streams
<afontain_> I think I hit one current limit of the C import logic
<afontain_> "Semantic Analysis [593/1011] zig-cache/o/Vqx3T6ZY-WyTESagrpdAPxsW2kJwausDklI4gTy1zoKM6cy_U8uRQDPPj0gaApmu/cimport.zig:12362:61: error: unable to evaluate constant expression"
<afontain_> It happens basically as soon as I call SDL_LoadBMP
adamkowalski has joined #zig
<afontain_> it appears to be working for simpler tasks, like coloured rectangles
<ikskuh> how do you call SDL_LoadBMP?
<afontain_> (the second line of the error message:) "pub inline fn SDL_LoadBMP(file: var) @TypeOf(SDL_LoadBMP_RW(SDL_RWFromFile(file, "rb"), 1)) {"
<adamkowalski> do we have anything in the standard library for reading csv
<ikskuh> adamkowalski: yes, std.mem.tokenize
<ikskuh> and std.mem.separate
<ikskuh> afontain_: ah looks like SDL_loadBMP is not a function, but a macro
<ikskuh> try calling the macro content by-hand
<afontain_> const loaded_surface = SDL_LoadBMP(path);
<afontain_> with `path: [*:0]const u8`
<ikskuh> SDL_oadBMP_RW(SDL_RWFromFile(path, "rb"), 1)
<adamkowalski> ikskuh: thanks! I'll use those, but I was hoping we had something that paved over all the weirdness of csv files haha
<afontain_> oh, that's quite smart
<afontain_> why didn't I thought of that
<afontain_> it appears to work
adamkowalski has quit [Quit: Lost terminal]
<ikskuh> yeah macro translation in zig is rough
<ikskuh> but it's better than nothing
<afontain_> is there an equivalent to returning a tuple (python) or a std::pair (C++) ?
<ikskuh> return a struct
<afontain_> if there isn't, I could just pass a pointer à la C
<ikskuh> afontain_: use structs
<ikskuh> it's just "not a pain"
<afontain_> hmm, structs can be anonymous
<ikskuh> fn multireturn() struct { a: i32, b : i32 } {
<ikskuh> return .{ .a = 10, .b = 20 };
<ikskuh> }
<oats> hmmm, regular tuples would be a nice feature
<oats> fn multireturn() (i32, i32) { return (10, 20); }
<oats> I get that there's other priorities though at the moment :P
<ikskuh> there's a proposal for that already
SimonNa has quit [Quit: Leaving]
<ikskuh> how do i fail a process with build.zig?
<ikskuh> should i just @panic or?
rjtobin has quit [Remote host closed the connection]
rjtobin has joined #zig
rjtobin has quit [Remote host closed the connection]
rjtobin has joined #zig
meraymond2 has joined #zig
meraymond2 has quit [Remote host closed the connection]
<pixelherodev> The one problem with my remote zig solution is that it's generating LLVM 10, and my parser is 9-only for now :(
r4pr0n has quit [Quit: r4pr0n]
afontain_ has quit [Ping timeout: 246 seconds]
<Snektron> Did llvm ir change a lot?
BaroqueLarouche has quit [Ping timeout: 246 seconds]
afontain_ has joined #zig
pmwhite has quit [Ping timeout: 246 seconds]
<pixelherodev> Nah, but there's now a willreturn function attribute :P
BaroqueLarouche has joined #zig
<pixelherodev> And I don't want to do partial lexer fixes
dermetfan has quit [Ping timeout: 240 seconds]
pmwhite has joined #zig
<yawniek> hi, im new to zig. trying to use it to compile mruby on macos. but i get fatal error: 'stdarg.h' file not found. isnt that included with zig?
<ikskuh> it is, but you have to use a libc
<ikskuh> what is your current target?
<mikdusan> yawniek: have you both recently upgraded xcode and used zig before that xcode upgrade?
<yawniek> mikdusan: i dont think so
<yawniek> i simply set CC to zig cc and nothing else so far
<mikdusan> one sec. i have mruby on my machine let me try
<yawniek> (actually i want to compile the h2o server but it failed at mruby and plain mruby does the same)
<mikdusan> try this first: rm ~/Library/Application\ Support/zig/stage1/native_libc.txt
jasom has joined #zig
<mikdusan> btw, mruby master worked for me: export CC and CXX with `zig cc` and `zig c++` respectively; note you will see warnings about "-MD" option don't worry about that for now
<yawniek> no luck. i dont have native_libc there (installed zig via homebrew)
<mikdusan> `zig version`
<yawniek> 0.5.0 (just installing head now)
<yawniek> failed :/
<mikdusan> just grab latest build of zig from website
<pixelherodev> There a way to force the progress output on a non-TTY?
marijnfs has quit [Quit: Lost terminal]
Xatenev has quit [Quit: Leaving.]
<yawniek> mikdusan seems to work with that one, thanks!
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ur5us has quit [Ping timeout: 240 seconds]