ChanServ changed the topic of #zig to: zig programming language | ziglang.org | be excellent to each other | channel logs: https://irclog.whitequark.org/zig/
<MajorLag> andrewrk, evidence that making `[]null const u8` the default and implicit casting to `&const u8` and `[]const u8` is the right move: I basically just implemented this behavior in a struct to make it smoother to talk to syscalls.
<jab> do you guys get a massive amount of warnings when building?
<jab> like: ld: warning: direct access in function 'llvm::OnDiskChainedHashTableGenerator...
<jab> woo! got builds working
<andrewrk> alright, done with day job
<andrewrk> zig time!
<andrewrk> MajorLag, noted
<andrewrk> MajorLag, that's a keen observation that the same kind of code that could give you non-null-terminated string literals if the default was null-terminated, could give you null-terminated if the default is non-. I hadn't considered that
<andrewrk> jab, yes I made libsoundio. I'm really just trying to make music, but I don't have a good enough language to build my digital audio workstation in yet ;)
<GitHub19> [zig] andrewrk closed pull request #865: skeleton stage 2 support for 'zig build' (master...zig-build-stage2) https://git.io/vxaGE
<GitHub133> [zig] andrewrk pushed 3 new commits to master: https://git.io/vxVT5
<GitHub133> zig/master 5627347 Andrew Kelley: Merge pull request #865 from bnoordhuis/zig-build-stage2...
<GitHub133> zig/master b60b01c Ben Noordhuis: skeleton stage 2 support for 'zig build'...
<GitHub133> zig/master db70b90 Ben Noordhuis: non-zero exit when build.zig cannot be created...
<MajorLag> andrewrk, or anyone, am I missing something obvious or is this a bug? https://paste.ubuntu.com/p/RtPn5J2csz/
<andrewrk> MajorLag, I think you need const FileDir = comptime DStr.literal("file/")
<MajorLag> oh, I would have thought that'd be implied by const.
<andrewrk> you can do: const foo = runtimeFunction();
<MajorLag> And I do. I guess that's what lead me to believe it would work with just `const`.
<MajorLag> hmmm: const FileSrc = `comptime DStr.literal(RealRootPath.str ++ FileDir.str);`
<MajorLag> whoops. meant to paste the erro
<MajorLag> `error: expected type '[]const u8', found '&const u8'`
<MajorLag> arrow points to the `++` operator, and the lhand should definitely be a []const u8
<andrewrk> that means the result of the ++ expression - the entire `a ++ b` was `&const u8` but DStr.literal expects []const u8
<andrewrk> self hosted parser uses a squiggly underline around the entire expression instead of a mere ^
<MajorLag> ok, but that still doesn't make sense to me. Shouldn't []const u8 ++ []const u8 => []const u8?
<andrewrk> hmm yeah that seems like a bug
<MajorLag> want an issue? I can work around this for now I think.
<andrewrk> this is probably easy to fix, I'll take a quick look
<andrewrk> this is why I have 2 git clones of zig :)
isd has quit [Quit: Leaving.]
<andrewrk> MajorLag, fixing now: https://github.com/zig-lang/zig/issues/866
<MajorLag> cool, thanks. The error in your issue doesn't match the code though.
<MajorLag> will be confusing to future computational historians
<andrewrk> oops
<andrewrk> fixed
cenomla has joined #zig
<GitHub152> [zig] andrewrk pushed 1 new commit to master: https://git.io/vxVYI
<GitHub152> zig/master 032fccf Andrew Kelley: fix compile time array concatenation for slices...
<andrewrk> MajorLag, ^
<MajorLag> Thanks. I'll circle back and un-workaround my code in the morning.
bbrittain has quit [Ping timeout: 248 seconds]
bbrittain has joined #zig
hobomatic has joined #zig
<andrewrk> argh. I'd have #821 solved except there's a bug in llvm's coroutine implementation
curtisf has joined #zig
return0e has joined #zig
hobomatic has quit [Quit: Leaving]
return0e has quit [Ping timeout: 246 seconds]
<curtisf> Other than https://ziglang.org/documentation/master/ is there documentation I should be looking at to learn how to use Zig?
<curtisf> At the moment I'm wondering if there are slice-of-structs literals
<andrewrk> curtisf, I think the docs you linked are the best thing we have so far
<andrewrk> you can cast array literals to []const T
hobomatic has joined #zig
<andrewrk> const slice_of_structs: []const T = []T{ T { }, T { }, T { } }
<andrewrk> where T is your struct name
<andrewrk> and you'll need to fill in the inner { } with fields
<andrewrk> if this syntax is cumbersome, you can use functions executed at comptime
<andrewrk> you can also do something like: const foo = comptime { };
<andrewrk> and then do any arbitrayr computation in the comptime block to come up with your static data
<curtisf> Thanks, that seems obvious now, it might be a bit too late
cenomla has quit [Quit: cenomla]
jdufault has joined #zig
curtisf has quit [Quit: Page closed]
jdufault has quit [Ping timeout: 256 seconds]
tiehuis has joined #zig
return0e has joined #zig
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
davr0s has joined #zig
Hejsil has joined #zig
tiehuis has quit [Quit: WeeChat 2.1]
return0e has quit [Read error: Connection reset by peer]
return0e has joined #zig
<Hejsil> andrewrk, The self hosted compiler is trying to lookup the stage 0 libs in {cmake_dir}/zig_cpp/{libname}.a, but my stage 0 build outputs the libs into {cmake_dir}
<Hejsil> Bug, or am I building stage 1 wrong?
<Hejsil> I see the program. I need to make install for it to work
<Hejsil> problem*
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<GitHub2> [zig] Hejsil pushed 1 new commit to master: https://git.io/vxV7e
<GitHub2> zig/master 9df2a6a Jimmi Holst Christensen: std.zig.parser can now parse top level test declarations
<walac> andrewrk: I see references for a parsegen tool in the docs but I could not find anything in sources, is this still valid?
<GitHub0> [zig] tiehuis opened pull request #867: Rewrite Rand functions (master...rand-overhaul) https://git.io/vxVAt
SimonNa has quit [Remote host closed the connection]
SimonNa has joined #zig
Hejsil has quit [Ping timeout: 260 seconds]
<andrewrk> walac, where do you see that?
SimonNa has quit [Remote host closed the connection]
SimonNa has joined #zig
Hejsil has joined #zig
Hejsil has quit [Quit: Page closed]
<andrewrk> walac, that comment is incorrect. Deleting it now
<walac> andrewrk: ok. Btw, any interest in converting the parser to a gen tool, like bison?
return0e has quit [Read error: Connection reset by peer]
return0e has joined #zig
<andrewrk> walac, nope. why?
<walac> andrewrk: well, I found use a parser generator makes easier to build a correct parser given the grammar, and the code becomes easier to understand (that part is a personal view). The downside is to learn a new tool syntax
<walac> I was thinking on making an experiment on converting the parser to bison and see how it goes
<andrewrk> I think it makes it difficult to have error messages exactly how you want them
<andrewrk> that also introduces another system dependency
<walac> That's a good point, but I believe the C++ implementation will be replaced by zig one in the near future, right?
<jab> This is beautiful: #define ICE_P(x) (sizeof(int) == sizeof(*(1 ? ((void *)((x)*0l)) : (int*)1))
<andrewrk> walac, correct - the self hosted parser in fact already exists and supports a subset of zig syntax
<andrewrk> it uses an arena allocator and no recursion
<andrewrk> the API is exactly what we want, no global variables, it integrates directly with the tokenizer
<andrewrk> it's kind of hard to want something else
<andrewrk> jab, I don't understand - it looks like it dereferences a void * which should be a compile error
<walac> andrewrk: for the zig implementation I think it justifies a hand-crafted parser, but for C++... that code will die anyway... Where is the zig implementation? Under src-self-hosted/ dir?
<andrewrk> walac, it's planned for the c++ code to never die: https://github.com/zig-lang/zig/issues/853
<walac> andrewrk: ah, so my mistake
<andrewrk> c++ implementation will forever be just good enough to build the latest self hosted compiler
<jab> andrewrk: it doesn't actualy deref in a sizeof
<jab> so it just gets the type void which is size 1
<andrewrk> void is size 1?
<jab> sizeof is "comptime"
<jab> yeah
<andrewrk> what does ICE_P stand for?
<jab> integer constant expression p?
<jab> p being predicate which is a lisp thing
<jab> so it tests for integer constant expressions
<jab> or something known at compile time, hence why x fails
<jab> (it's not const)
<jab> this basically tests if something can be used in an array expression
<jab> at runtime lol
btbytes has joined #zig
steveno_ has joined #zig
Ichorio has joined #zig
btbytes has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
btbytes has joined #zig
hobomatic has quit [Quit: Leaving]
davr0s has joined #zig
btbytes has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
btbytes has joined #zig
btbytes has quit [Client Quit]
btbytes has joined #zig
return0e_ has joined #zig
return0e_ has quit [Remote host closed the connection]
return0e has quit [Ping timeout: 240 seconds]
Hejsil has joined #zig
SimonNa has quit [Quit: Leaving]
btbytes has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
benaiah has quit [Quit: G'bye]
<GitHub196> [zig] andrewrk closed pull request #867: Rewrite Rand functions (master...rand-overhaul) https://git.io/vxVAt
<GitHub38> zig/master b80398b Andrew Kelley: Merge pull request #867 from zig-lang/rand-overhaul...
<GitHub38> [zig] andrewrk pushed 1 new commit to master: https://git.io/vxwi3
btbytes has joined #zig
steveno_ has quit [Quit: Leaving]
benaiah has joined #zig
curtisf has joined #zig
btbytes has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
return0e has joined #zig
btbytes has joined #zig
btbytes has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<jab> haha, i was thinking about doing that
<jab> glad my efforts weren't wasted
return0e has quit [Ping timeout: 248 seconds]
<andrewrk> tiehuis is a machine
jjido has joined #zig
cmwt has joined #zig
<cmwt> I just learned about Zig. I was wondering if there has been any discussion over having variables and objects be `const` by default? I am just curious.
<Hejsil> I don't think there is a default
<Hejsil> Pick 'var' if you want mutablility. Pick 'const' if you dont
<curtisf> does zig have "pointer to const", or does it behave more like Java's final / JavaScript's const where it only prevents modification of the value at the variable itself?
<Hejsil> Yes, zig have pointer to const.
<Hejsil> Taking pointer of a const, gives pointer to const. Taking pointer to var gives normal pointer. Normal pointer casts to const pointer, but not the other way around
<Hejsil> "Normal". Let's call them mutable pointers instead
<cmwt> @Hejsil, Thank you for telling me.
<curtisf> I'm assuming a holder of a pointer-to-const cannot assume that the pointed-to data doesn't change, it's just a restriction on syntactically being able to modify the object through that pointer. Is that right?
<Hejsil> Yes
<Hejsil> Const pointers are not safe from concurrency
<Hejsil> Also, const values can have fields that are mutable pointers
<Hejsil> const a = HaveMutPtr { .ptr = &some_value }; a.ptr
<Hejsil> *a.ptr = 3;
<Hejsil> is valid
<jjido> Does Zig have generators? They are also concerned with weak const-ness
<Hejsil> andrewrk is working on coroutines, but I don't know how useful they will be for generators
<Hejsil> I haven't played with them yet
<curtisf> I'm going to be asking a lot of questions, thanks in advance for being helpful. What is the nicest way to write a loop 0 to len - 1? I wanted to iterate over two slices of the same length
<jacobdufault> re coroutines, do the coroutines have an associated stack (ie, yielding in nested function calls)?
cmwt has quit [Quit: Page closed]
<Hejsil> jacobdufault, The tests on coroutines might answer your question: https://github.com/zig-lang/zig/blob/master/test/cases/coroutines.zig
<curtisf> ah, the for loop documentation doesn't mention also getting index, but I now see it being used in some other places
<Hejsil> Aka, I have no idea
<curtisf> oh, I lied, it's there
<jacobdufault> Hejsil: I was looking at the tests but did not see anything similar, so I'm assuming it is not supported. Just wanted to confirm
<Hejsil> When It's documented, we'll know :)
cenomla has joined #zig
<GitHub6> [zig] Hejsil pushed 1 new commit to master: https://git.io/vxwFF
<GitHub6> zig/master 530f795 Jimmi Holst Christensen: std.zig.parser now supports all infix operators
btbytes has joined #zig
btbytes has quit [Client Quit]
btbytes has joined #zig
btbytes has quit [Client Quit]
<GitHub68> [zig] Hejsil pushed 1 new commit to master: https://git.io/vxwbM
<GitHub68> zig/master 8ada030 Jimmi Holst Christensen: Fixed self hosted compiler compiler error from prev commit
btbytes has joined #zig
btbytes has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
btbytes has joined #zig
<Hejsil> curtisf, The compiler assumes the memory of a const pointer don't change. It should be marked as a volatile pointer, if it does
<curtisf> I will keep that in mind, thanks!
Ichorio has quit [Ping timeout: 248 seconds]
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<GitHub68> [zig] Hejsil pushed 1 new commit to master: https://git.io/vxrvL
<GitHub68> zig/master edca173 Jimmi Holst Christensen: std.zig.parser now parses call expr
davr0s has joined #zig
isd has joined #zig
btbytes has quit [Read error: Connection reset by peer]
<andrewrk> Quick note on volatile and memory reads/writes in general: there is no guarantee about load and store ordering unless you use atomics
<andrewrk> However volatile loads and stores are ordered according to each other
<andrewrk> But a good rule of thumb is: volatile is for memory mapped I/O and atomics are for kernel threading.
<andrewrk> Volatile mixed with kernel threads is almost certainly a bug
cenomla has quit [Quit: cenomla]
<jacobdufault> andrewrk: (see above) do coroutines have a stack associated with them?
hoppetosse has joined #zig
isd has quit [Quit: Leaving.]
Hejsil has quit [Quit: Page closed]
Hejsil has joined #zig
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
hoppetosse has quit [Remote host closed the connection]
hoppetosse has joined #zig
Hejsil has quit [Ping timeout: 260 seconds]
isd has joined #zig
davr0s has joined #zig
cenomla has joined #zig
cenomla has quit [Client Quit]
cenomla has joined #zig
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]