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 has joined #zig
MajorLag has quit [Ping timeout: 245 seconds]
wink_ has quit [Ping timeout: 252 seconds]
wink_ has joined #zig
mnoronha has quit [Ping timeout: 252 seconds]
mnoronha has joined #zig
darithorn has quit []
jjman has joined #zig
jjman has quit [Quit: WeeChat 1.6]
mnoronha has quit [Ping timeout: 246 seconds]
bheads has quit [*.net *.split]
bheads has joined #zig
ManDeJan has joined #zig
jjido has joined #zig
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
walac has quit [Ping timeout: 250 seconds]
walac has joined #zig
allochi has joined #zig
walac has quit [Ping timeout: 252 seconds]
<euantor> Awesome, thanks tiehuis. I did have the compiler building but then failing tests, but I'm now not even getting that far
<euantor> I'm getting `Unable to create builtin.zig: invalid format` when trying to run `./zig build --build-file ../build.zig test -Dskip-release-small`, which seems to be another CPP problem
walac has joined #zig
kmelva has joined #zig
walac has quit [Ping timeout: 260 seconds]
walac has joined #zig
davr0s has joined #zig
walac has quit [Ping timeout: 252 seconds]
walac has joined #zig
allochi has quit [Remote host closed the connection]
allochi has joined #zig
allochi has quit [Ping timeout: 252 seconds]
allochi has joined #zig
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
tiehuis has joined #zig
<tiehuis> halosghost: i actually have a big rational implementation here: https://github.com/tiehuis/zig-bn/blob/master/rational.zig
<tiehuis> the only thing that needs to be done for an initial version is to change the paramater passing to fit that of big.Int in std
<tiehuis> and to fix a bug in big.Int (which i have been meaning to file or solve for months) in the division code
tiehuis has quit [Client Quit]
allochi has quit [Remote host closed the connection]
very-mediocre_ has joined #zig
allochi has joined #zig
allochi has quit [Ping timeout: 264 seconds]
davr0s has joined #zig
very-mediocre_ has quit [Ping timeout: 256 seconds]
DutchGh0st has joined #zig
<DutchGh0st> export fn printing(noalias buf: [*]const u8, len: usize) void <--- this does not compile?
<DutchGh0st> or well, compilation hangs
<DutchGh0st> oh, it finished, that took some time?
ManDeJan has quit [Ping timeout: 246 seconds]
allochi has joined #zig
DutchGh0st has quit [Quit: http://www.kiwiirc.com/ - A hand crafted IRC client]
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
mnoronha has joined #zig
mnoronha has quit [Ping timeout: 260 seconds]
mnoronha has joined #zig
davr0s has joined #zig
allochi has quit [Remote host closed the connection]
allochi has joined #zig
allochi has quit [Ping timeout: 252 seconds]
halosghost has joined #zig
<andrewrk> DutchGh0st, are you sure that wasn't rust/cargo?
DutchGh0st has joined #zig
<DutchGh0st> nope, that was just 'zig-0.3.exe build-lib hello.zig'
<DutchGh0st> Not sure why it hung that one time, now its just fast
redj has quit [Ping timeout: 252 seconds]
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
davr0s has joined #zig
mnoronha has quit [Ping timeout: 250 seconds]
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
davr0s has joined #zig
DutchGh0st has quit [Quit: http://www.kiwiirc.com/ - A hand crafted IRC client]
very-mediocre has joined #zig
very-mediocre has quit [Ping timeout: 256 seconds]
unique_id has left #zig ["Konversation terminated!"]
wink_ has quit [Quit: http://www.kiwiirc.com/ - A hand crafted IRC client]
wink_ has joined #zig
very-mediocre has joined #zig
very-mediocre has quit [Ping timeout: 256 seconds]
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
Ichorio has joined #zig
davr0s has joined #zig
darithorn has joined #zig
return0xe has quit [Ping timeout: 245 seconds]
<andrewrk> if I pull of this coroutine rewrite as planned, zig will support stackless heapless functions
Jenz has joined #zig
<Jenz> What does the * in the c string type: `[*]const u8` mean?
<andrewrk> Jenz, it means: at the address pointed to, there are an unknown number of contiguous items
<Jenz> andrewrk: Ok, thanks; makes sense
<andrewrk> after https://github.com/ziglang/zig/issues/265 is implemented, the type would be `[*]null const u8` which means: at the address pointed to, there are a number of contiguous items. After the last one, there is a sentinel u8(0)
<Jenz> I like that better :D
<bheads> how would stackless work?
<andrewrk> bheads, status quo coroutines are stackless
<bheads> right, but they get memory from some allocator right?
<andrewrk> right
<bheads> which is either stack or heap memory...
<bheads> so you said coros without any memory
<andrewrk> fair, that's a bit misleading. the memory has to go somewhere
<Jenz> andrewrk: Some projects has things like "good first issue"s, anything similar for newcomers in zig?
<Jenz> Personally; Im terrible at C++, new to zig; and not really sure if there's any way at all I can help out ATM
<andrewrk> bheads, but in the rewrite, coroutines are not coupled to allocators - you pass a pointer to the frame when you async call a function
<bheads> ah so you can just pass the frame
<andrewrk> I think it's going to be a big deal, if I can only figure out how to make async function pointers work
<andrewrk> ...which is the same problem as how to make regular function pointers work with https://github.com/ziglang/zig/issues/157
<andrewrk> Jenz, one of the best things you can do is to simply have a project in zig that you're working on
<andrewrk> and then report bugs and use cases that zig doesn't handle very well
<Jenz> Yeah ok, thanks again :)
<Jenz> Then I'll just keep doing what Im doing
<andrewrk> :)
<bheads> humm... recurrsion is really hard to solve... I can think of ideas for the simple cases but the hidden recursion sucks
<andrewrk> bheads, yeah. I've solved recursion when the function being called is not a pointer (when the compiler knows what function you're calling at compile time)
<andrewrk> but recursion + async + function pointers is a tough nut to crack
<bheads> would if detect more complex recursion
<bheads> like a-> b->c ->d ->(a or b)
<bheads> stuff like this?
<andrewrk> yeah it would just detect a call graph cycle and force you to use stackless functions (coroutines) for the recursion
<bheads> okay cool
<andrewrk> but I haven't solved recursion + function pointers
<andrewrk> my first thought was that you could jsut annotate the set of functions that a pointer *migth* be
<bheads> for fn pointers I think you have to detect the cycle in runtime
<andrewrk> but that defeats the point of e.g. an Allocator interface or OutStream interface
<andrewrk> oh that's interesting. I hadn't considered that
<andrewrk> so the compiler would know there is a potential cycle, and insert a safety check
<bheads> in debug mode you can mark each stack frame
<andrewrk> we'd have a way to anotate how many cycles were allowed
<andrewrk> so that the compiler could count that in its stack size consideration
<andrewrk> and then going beyond that trips a runtime safety check
<bheads> that would be really cool
DutchGh0st has joined #zig
<bheads> and turn it all off in release mode
<andrewrk> of course
<andrewrk> on in ReleaseSafe mode though!
<DutchGh0st> how does `some_number / comptime_int` work?
<bheads> lol
<DutchGh0st> because Im trying divExact, divTrunc, but somehow something seems to go wrong
<bheads> I think all constant numbers are comptime_
<bheads> and the compiler does the casting checks
<andrewrk> DutchGh0st, do you have a code example that is giving unexpected results?
<DutchGh0st> it might be I screwed up, but 2 seconds, Ill push it
<DutchGh0st> dont look at itoa_u64, it forwards to itoa(),
<DutchGh0st> the numbers 1, 0, 0 should be written into `buf` in the test, but I screwed up something I guess?
<andrewrk> DutchGh0st, itoa_u64(n, buf[0..].ptr, 3), this could better be written itoa_u64(n, &buf, buf.len)
<DutchGh0st> ah yeah
<bheads> or just passed as a slice
<DutchGh0st> [*]T also takes slices?
<bheads> []T is a slice
<DutchGh0st> but I have a star in the braces,
<bheads> if you know the length its safer to use a slice
<DutchGh0st> but that is not C compatible
<andrewrk> the code is calling an extern function
<bheads> ah your making a c interface
<bheads> god I hate
<bheads> C
<DutchGh0st> the idea was to make 1 generic function for converting numbers into a sequence of bytes, and then verry quickly write like 'itoa_u64', 'itoa_u32' etc
<andrewrk> DutchGh0st, I haven't figured anything out, but have you tried using @compileLog to debug your comptime code?
<DutchGh0st> @compileLog, I FORGOT ABOUT THAT
<DutchGh0st> thanks :)
<DutchGh0st> @divExact does not modify the numbers you put in, right?
<andrewrk> DutchGh0st, correct
<Jenz> Is there a way to programaticalyl get the type of os.args() ?
<andrewrk> Jenz, I don't understand the question, can you elaborate on what you're trying to do?
<Jenz> Hehe, very -- what should I say... -- hotelesque way of putting it :P
<Jenz> Nvm. Im just a bit of an idiot
<Jenz> (I know "hotelesque" is not at all a word)
<DutchGh0st> while(n != 0) ({n -= 1;}) {} <-- does that check the condition, subtracts 1, and THEN does the body?
<DutchGh0st> or, check, body, substract?
Jenz has left #zig [#zig]
<andrewrk> DutchGh0st, check condition, body, subtract one, repeat
<andrewrk> consider that the point of the expression is that `continue` will execute it
<DutchGh0st> Im a dummy
<DutchGh0st> you know what I tested?
<DutchGh0st> bytes in the form as a charcter, representing a diget
<DutchGh0st> vs a raw number
<DutchGh0st> and 0 in ascii is 48
<DutchGh0st> xD
<andrewrk> ahhh
<DutchGh0st> and not 0
<DutchGh0st> still my loop condition was wrong
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<DutchGh0st> yeahhh exactly
redj has joined #zig
mnoronha has joined #zig
<DutchGh0st> Finally
<DutchGh0st> fixed it
darithorn has quit []
<DutchGh0st> cant convert a bytes-slice into a ' [*]u8' ?
mnoronha has quit [Ping timeout: 240 seconds]
davr0s has joined #zig
<andrewrk> DutchGh0st, slice.ptr
<DutchGh0st> but from an array you can go directly to [*]u8 ?
<DutchGh0st> that is, an array of u8's
<andrewrk> you can implicit cast from *[N]T to [*]T
<andrewrk> pointer to an array to an unknown length pointer
return0xe has joined #zig
<DutchGh0st> how do you do powers of 10 of a usize?
<DutchGh0st> I want to write `10 ^ 4`
<DutchGh0st> 10 to the fourth
<andrewrk> std.math.pow
<andrewrk> hmm we only have floating point pow functions
<andrewrk> I think we're missing an integer pow function
<DutchGh0st> :(
<andrewrk> you can implement it like this
jjido has joined #zig
<DutchGh0st> comptime N; type, num: N, pow: usize -> N
<andrewrk> fn pow(base: usize, exp: usize) usize { var x: usize = base; var i: usize = 0; while (i < exp) : (i += 1) x *= exp; return x; }
<andrewrk> that's at least correct. maybe there's a better implementation
<andrewrk> oops, this is wrong, but you get the idea
<andrewrk> I'm not sure there's actually an O(1) solution
<andrewrk> that's pretty O(1)
<andrewrk> technically my code is too if you consider that exp can't really be > 64
<halosghost> I wish O(1) space-complexity data structures were more common
DutchGh0st has quit [Quit: http://www.kiwiirc.com/ - A hand crafted IRC client]
<jfondren> https://gist.github.com/jrfondren/390e9deaeb2de731e835c855a63d3f65 <- so zig *does* have ML-style datatypes. You have to synthesize them with union(enums) of structs, but they behave just like you'd want.
<jfondren> f.e., you add a payment method later on, and zig tells you about all the switches you have to update to handle the new payment.
<andrewrk> jfondren, ah, yes. apologies if I mislead you before
<andrewrk> what is ML? Machine Learning? Mat-Lab?
<jfondren> nobody mislead me :) first time I'm mentioning it. I just thought they weren't in the language since there wasn't mention of them
<jfondren> Robert Milner's language ML. like Standard ML, OCaml. Although lots languages have these kind of types
<jfondren> it's how FP langs implement optional types, usually.
<jfondren> in ML they compile to structs (or ints, when there are no arguments) with an int field that says which constructor you have, which is what gets switched on at runtime
<jfondren> I imagine this Zig code is compiled to something a little different, but that's not as important
<andrewrk> jfondren, not that it matters too much but you can replace union(Payments) with union(enum) and have the tag type inferred
<jfondren> cool, ty
<jfondren> *Robin Milner
tobbez has joined #zig
halosghost has quit [Quit: WeeChat 2.2]
<andrewrk> ok here's a crazy idea
<andrewrk> calling a function pointer requires special syntax
<andrewrk> one does not simply call a function pointer
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<andrewrk> when you call a function pointer, use @fnPtrCall(comptime required_stack_bytes_upper_bound: usize, function: var, args: ...)
<andrewrk> runtime safety checks to make sure that the actual function called, its stack requirements do not exceed the value
mnoronha has joined #zig
Ichorio has quit [Ping timeout: 245 seconds]
mnoronha has quit [Ping timeout: 252 seconds]
mnoronha has joined #zig
mnoronha has quit [Ping timeout: 246 seconds]
mnoronha has joined #zig
mnoronha has quit [Read error: Connection reset by peer]
mnoronha has joined #zig