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").
<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
<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>
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)'
<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?