ChanServ changed the topic of #zig to: zig programming language | ziglang.org | be excellent to each other | channel logs: https://irclog.whitequark.org/zig/
isd has quit [Quit: Leaving.]
zesterer has quit [Quit: zesterer]
zesterer has joined #zig
zesterer has quit [Quit: zesterer]
<MajorLag> something is weird about the stack in Windows debug mode.
heakins has joined #zig
heakins has quit [Client Quit]
<MajorLag> Is debug mode on windows by chance just handling the exception and continuing execution?
<MajorLag> because that would explain it.
cenomla has quit [Quit: cenomla]
relatingdata has joined #zig
<andrewrk> MajorLag: I know that I didn't intentionally put that in. Would you mind opening an issue for this mystery? I think it's worth figuring out what's going on.
Tobba has quit [Ping timeout: 256 seconds]
Tobba has joined #zig
cenomla has joined #zig
heakins has joined #zig
<relatingdata> has anybody looked at an actor type model for protecting data during concurrency? Pony look like they have it right but the syntax seem to make my brain hurt! P# from microsoft has some nice Manuals/Doco
<relatingdata> did anyone get a chance to look at "the with no trivial copy-assignment; use copy-initialization instead [-Werror=class-memaccess]" error from gcc version 8.0.1 in deps/lld/COFF/SymbolTable.cpp ?
return0e has quit [Ping timeout: 240 seconds]
return0e has joined #zig
MajorLag has quit [Ping timeout: 276 seconds]
MajorLag has joined #zig
hryx has joined #zig
return0e_ has joined #zig
return0e has quit [Ping timeout: 240 seconds]
hryx has quit [Quit: Leaving]
aiwakura has quit [Ping timeout: 240 seconds]
aiwakura has joined #zig
aiwakura has quit [Quit: Ping timeout (120 seconds)]
aiwakura has joined #zig
hoppetosse has joined #zig
cenomla has quit [Quit: cenomla]
profan has joined #zig
hoppetosse has quit [Ping timeout: 260 seconds]
return0e_ has quit [Ping timeout: 255 seconds]
return0e has joined #zig
return0e has quit [Ping timeout: 245 seconds]
return0e has joined #zig
<GitHub45> [zig] tiehuis opened pull request #900: Add common hash/checksum functions (master...hash-and-checksums) https://git.io/vx9YG
hoppetosse has joined #zig
hoppetosse has quit [Ping timeout: 255 seconds]
hoppetosse has joined #zig
hopppetosse has joined #zig
hoppetosse has quit [Ping timeout: 240 seconds]
hopppetosse has quit [Ping timeout: 264 seconds]
hinst has quit [Quit: No Ping reply in 180 seconds.]
hinst has joined #zig
hinst has quit [Client Quit]
hinst has joined #zig
hinst has quit [Quit: No Ping reply in 180 seconds.]
hinst has joined #zig
hinst has quit [Client Quit]
hinst has joined #zig
<man213> Hello guys. Does anybody have tried to build a dynamic library under windows and successfully call a function from it? When I'm trying to do that, I recieve 0xC000007B error ("The application was unable to start correctly").
<GitHub59> [zig] andrewrk closed pull request #900: Add common hash/checksum functions (master...hash-and-checksums) https://git.io/vx9YG
<GitHub6> [zig] andrewrk pushed 1 new commit to master: https://git.io/vx9Rr
<GitHub6> zig/master 7186e92 Andrew Kelley: Merge pull request #900 from zig-lang/hash-and-checksums...
noonien has joined #zig
man213 has quit [Quit: Page closed]
man213 has joined #zig
<andrewrk> relatingdata, we now have linux x86_64 master branch builds available on https://ziglang.org/download/
<andrewrk> if you're trying to contribute to the c++ compiler, I think we just need to add -Wno-class-memaccess to the LLD building flags
<andrewrk> or maybe disable -Werror for LLD
<andrewrk> man213, I'll have a look at this tonight
MajorLag2 has joined #zig
Dodo has joined #zig
MajorLag has quit [Ping timeout: 276 seconds]
<Dodo> is it possible to create a new project by saying like 'zig new <projectname>' or whatever?
<andrewrk> Dodo, zig build --init
<andrewrk> I should update this to create a fully working project
<Dodo> huh, thats nice
<Dodo> I've a simple hello world setup,
<Dodo> but I seem to get an error at "const std = @import("std");", error: invalid carriage return, only '\n' line endings are supported
<andrewrk> Dodo, pretty soon 'zig fmt' will fix that issue
<Dodo> sounds like 'cargo fmt' haha
<andrewrk> for now you'll have to configure your editor to use unix newlines
<andrewrk> rather than windows
<Dodo> oowww I see
<Dodo> meaning if I use the ubuntu shell, it should work?
<andrewrk> is that the Windows Subsystem for Linux?
<Dodo> yess
<andrewrk> I mean, zig supports windows - it seems like you would want to use it natively
<Dodo> I wrote the file with visual code, maybe visuel code uses weird newlines?
<andrewrk> are you using the zig extension to vscode?
<Dodo> not yet..
<Dodo> I just downloaded the compiler...5 minits ago
<andrewrk> I believe that will fix the newline issue
<andrewrk> I hope
<Dodo> installing it :)
<Dodo> still getting the error..
<Dodo> Im trying to compile using this command: "..\zig-0.2.0\zig.exe build-exe .\hello.zig" , thats why?..
<raytracer[m]> Do you see a "CRLF" symbol in the bottom right corner?
<Dodo> I do
<Dodo> oh what do you know
<Dodo> LF fixes it
<andrewrk> Dodo, idea here is to get everybody on the same page. Source code is cross platform and therefore we need cross-platform standards for newlines
<Dodo> ah yeah, makes sense
<Dodo> quick question, you can do *anything* at comptime?
<andrewrk> Dodo, no- you cannot do unsafe things such as call an external library, or make syscalls
<andrewrk> right now @ptrCast does not work at comptime but I have a plan to make that work
<andrewrk> you can't crash the compiler at comptime
<andrewrk> well, you certainly can :) but it's always a bug in the compiler when you do
<Dodo> But still, that's quite alot of power
<andrewrk> MajorLag and Hejsil probably had a seizure when I made the statement "you can't crash the compiler at comptime"
<andrewrk> (between the two of them they've reported dozens of bugs in the comptime evaluation code)
<Dodo> can I 'warn' (print??) a number that I got from a comptime?
<MajorLag2> Dodo: yes, but you have to explicitly cast it to a type first. `warn("{}\n", isize(comptime_num));`
<Dodo> ohh
<MajorLag2> andrewrk: indeed, "you can't crash the compiler at comptime" is a statement I'd have to disagree with. "you shouldn't be able to crash the compiler at comptime" is correct though.
<andrewrk> indeed
<Dodo> but I define the variable to hold the result in the 'comptime' block,
<MajorLag2> oh, then you want to print it at comptime?
<andrewrk> there's an issue for printing number literals
Ichorio has joined #zig
<Dodo> well, calculate the number at compile time, then print at runtime?
<MajorLag2> then you're storing it somewhere
<Dodo> or can I say like 'const whatever = comptime { //expression };' ?
<andrewrk> yep
<MajorLag2> you can totally say that
<Dodo> why didn't I try that yet :3
<MajorLag2> It can take a little while to form a good mental model of comptime, but it is worth it. I built my entire interpolation collection in a mere 178 lines thanks to comptime.
<Dodo> var fib_15 = comptime { fib(15) }; <---- expected token ';', found '}'
<MajorLag2> fib(15);
<andrewrk> var fib_15 = comptime fib(15);
<andrewrk> hmm I don't have a good place in the docs to link to which explains labeled blocks
<MajorLag2> there's that aray initialization
<Dodo> comptime {fib(15);}; complained about not being able to print a void type
<andrewrk> yeah that works. Dodo have a look at https://ziglang.org/documentation/master/#Arrays specifically "fancy_array" initializaton
<Dodo> which makes sense, because the expression returns void
<andrewrk> this is just to show you labeled block and labeled break
<MajorLag2> yeah, either don't use the block or use a labeled break expression
<Dodo> yes
<Dodo> but it worked! :D
<Dodo> oh this is amazing \o/
<Dodo> it's pretty fast calculating fib(90) recursivly! guess thats the optimizer doings its work \o/
<Dodo> Im comming from Rust, hope they get comptime one day as well
<andrewrk> I think it's inevitable
MajorLag has joined #zig
MajorLag2 has quit [Ping timeout: 276 seconds]
<Dodo> it is, they now 'support' it, but its really just constant expressions, no if-else, looping, or other stuff
isd has joined #zig
<Dodo> can I make the '<' and '>' operator work for my own structs?
<Dodo> is it a .cmp() function I need to create ?
<andrewrk> there is no operator overloading
<Dodo> so for as far as I understand, operator overloading is 'hidden territory', and the prefered way is to be explicit?
<Dodo> but...wouldn't people come up with their own function names for operatoroverloading then?... I think that 'if (struct < struct) {//do something}' is pretty clear about what it does
<MajorLag> but what if `<` does an allocation? That's very non-obvious.
<Dodo> ?
<Dodo> oh you mean function that '<' would call?
<MajorLag> yes.
<Dodo> well, that is non-ovious, true
<MajorLag> there's also the problem of error handling semantics.
<Dodo> however, comparing doesnt really require allocs I think
<MajorLag> admittedly an extreme example
<Dodo> honestly I love the way Rust does these things,
<andrewrk> one of the features of C that I do not want to give up, is that, aside from the preprocessor, you can look at code and always know exactly what the control flow is doing, without looking anywhere else
<koomi> '<' is not an obvious operation at all for non-trivial structs
<Dodo> there you can implement Eq, PartialEq, Ord, PartialOrd etc, and you know exactly what '<' and '>' do
<andrewrk> with operator overloading, you would have to potentially look somewhere other than the code you're reading to find out the control flow of the code you're reading
<koomi> starting with the problem that there can be many ways to define an order
<Dodo> true
Dodo has quit [Quit: Page closed]
Dodo has joined #zig
isd has quit [Ping timeout: 265 seconds]
man213_ has joined #zig
<Dodo> btw, to get back to the conversation about overloading,
<Dodo> the point was made that you should be able to read the programm, and know what is does, but if sombody makes functions to represent the operators, than..how do you know what's going on in that function?
<Dodo> do unions have generic support?
isd has joined #zig
Ichorio_ has joined #zig
<Dodo> huh, you can make a Some(T)/None union \o/
Ichorio has quit [Ping timeout: 265 seconds]
<MajorLag> Dodo, did you just reinvent a nullable?
<Dodo> maybe?
<Dodo> in Rust there is the type "Option<T>", which is an enum having 2 variants: Some(T), and None
<MajorLag> Yeah, that's a nullable. We do that in zig with ?T
<Dodo> where None is just a variant, not really 'null'
<Dodo> ah I see
<Dodo> guess I first should read docs ^^
<MajorLag> We have nice semantics for dealing with them. Comes in real handy for interacting with C.
<Dodo> ah yeah
<Dodo> I came up with this: 'fn Option(comptime T: type) type { return union { Some: T, None: void, }; }'
<MajorLag> You might also be interested in the section on Errors: https://ziglang.org/documentation/master/#Errors which work in a similar way.
<Dodo> but I cant really accesss the fields I think
<MajorLag> In a nullable? you have to unwrap it first.
<MajorLag> Depending on context there are a few ways to do that.
Ichorio has joined #zig
<MajorLag> var x =returnsANullable() ?? <what to do or assign if the result was a null>;
<MajorLag> in that case x would be assigned to either the unwrapped nullable or whatever the expression after ?? is.
Ichorio_ has quit [Ping timeout: 240 seconds]
<MajorLag> but sometimes, in for loops for instance, we use the payload operator: for(arrayOfNullables) | x | { <stuff to do if item was not null> } else { <stuff to do if it was> };
<Dodo> oh that's the same as in rust, there it's like 'let x = returns_option().unwrap_or(value)', or 'let x = returns_option().unwrap_or_else(|| //closure)'
Ichorio has quit [Ping timeout: 256 seconds]
isd has quit [Ping timeout: 240 seconds]
<Dodo> how.. do I 'warn' an enum?
<andrewrk> PR welcome which adds printing enum support to std.fmt.format
Ichorio has joined #zig
isd has joined #zig
Ichorio has quit [Read error: Connection reset by peer]
<MajorLag> that reminds me I should probably do a PR for these additions to std.os.linux. Adds a couple dozen syscalls and related constants and macros. if desired, also a errnoToError function.
Ichorio has joined #zig
<andrewrk> that would be welcome. the reason we don't have errnoToError currently is that it's useful to constrain the error set to the actual error set possible from the syscall
<Dodo> so '??nullable' only unwraps?
<andrewrk> ??nullable is syntactic sugar for: nullable ?? unreachable
man213_ has quit [Ping timeout: 260 seconds]
Ichorio has quit [Read error: Connection reset by peer]
Ichorio has joined #zig
<MajorLag> I thought as much, but for me errnoToError was useful to minimize boilerplate around a bunch of syscalls.
<Dodo> is there a way to loop over a range of numbers?
<Dodo> without using 'while' ?
<andrewrk> no
Ichorio has quit [Read error: Connection reset by peer]
Ichorio has joined #zig
<Dodo> how do I go from u8 to char?
<Dodo> sure, a char can be seen as a u8, but I'd like to print text to my terminal, and not raw bytes
<MajorLag> warn("{c}\n", u8('a'));
<Dodo> I know I ask many question, but what about reading a file at runtime?
<andrewrk> std.os.File
<andrewrk> Dodo, here's some example code: https://github.com/zig-lang/zig/blob/master/std/io_test.zig
<andrewrk> questions are always welcome
<andrewrk> some day I will be able to respond to every question with a link to documentation
<Dodo> yeah:D
<Dodo> got to say that using '@embedFile' is much more easy than..that
Ichorio has quit [Read error: Connection reset by peer]
Dodo has quit [Quit: Page closed]
Ichorio has joined #zig
<andrewrk> Dodo, ah, but that's at comptime
<andrewrk> comptime code is easy. you just emit a compile error if something doesn't work
<andrewrk> runtime code is hard. you have to handle errors appropriately
<andrewrk> oh, and you have free unlimited memory at comptime
Ichorio has quit [Read error: Connection reset by peer]
Ichorio has joined #zig
Ichorio has quit [Read error: Connection reset by peer]
Ichorio has joined #zig
Ichorio has quit [Read error: Connection reset by peer]
Ichorio has joined #zig
<alexnask> @andrewrk What is the recommended allocator to use at comptime for std functions that require one?
<andrewrk> FixedBufferAllocator
<andrewrk> I haven't personally tried this use case. you may run into a problem. if you do, feel free to open an issue
<alexnask> Will do :) I assume the DirectAllocator would not work, or is the compiler able to execute syscalls etc in comptime contexts?
Ichorio has quit [Read error: Connection reset by peer]
Ichorio has joined #zig
<andrewrk> syscalls are not allowed at comptime
<andrewrk> right so that's why the direct allocator will not work
<andrewrk> there could be a concept of a comptime allocator. I'm still thinking about what that might look like
Ichorio has quit [Read error: Connection reset by peer]
Ichorio has joined #zig
man213_ has joined #zig
cenomla has joined #zig
Ichorio has quit [Read error: Connection reset by peer]
Ichorio has joined #zig
Ichorio has quit [Read error: Connection reset by peer]
Ichorio has joined #zig
Ichorio has quit [Read error: Connection reset by peer]
Ichorio has joined #zig
Ichorio has quit [Ping timeout: 264 seconds]
cenomla has quit [Ping timeout: 255 seconds]
cenomla has joined #zig
cenomla has quit [Client Quit]
cenomla has joined #zig