ChanServ changed the topic of #zig to: zig programming language | ziglang.org | be excellent to each other | channel logs: https://irclog.whitequark.org/zig/
steveno_ has quit [Quit: Leaving]
Hejsil has quit [Ping timeout: 260 seconds]
noonien has quit [Quit: Connection closed for inactivity]
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<andrewrk>
got kernel threads working on windows, mac, and linux
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
davr0s has joined #zig
MajorLag has quit [Ping timeout: 240 seconds]
MajorLag has joined #zig
Ichorio has joined #zig
Hejsil has joined #zig
noonien has joined #zig
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
Dodo has joined #zig
<Dodo>
alexnask: , did you have the comptime Iterators working?
<alexnask>
@Dodo Nah sorry I didn't end up getting too much work done yesterday
<alexnask>
I'm finishing up a couple of things for typeInfo then I'll take a look :)
<Dodo>
oh okey haha, np
<alexnask>
I think it will be pretty difficult to achieve but I'll see what the roadblocks are
<Dodo>
why'd be difficult? if you for example know at compiletime you have a Range of 0 to 10, you should be able to do anything with it,
<alexnask>
Right, any valid zig code that doesn't call syscalls _should_ be comptime evaluatable
<Dodo>
because you know that the first item will be 0, then 1 etc...
<alexnask>
The issue is pointer casting, because the comptime implementation does not keep stuff in memory with the same layout as runtime
<Dodo>
mh, not sure how the ArrayList works with allocation, that might be the only issue
<alexnask>
For example, say you have a struct with 2 fields, in comptime you will create an array of 2 ConstExprValues which are basically tagged unions with some data inside
<alexnask>
You can't then just cast from a pointer to that struct to a pointer to u8
<alexnask>
I mean, there are probably ways to make it work but it's more involved than it sounds :P
<Dodo>
mhh haha, fair enough
<alexnask>
I'll take a look for sure though
<alexnask>
At worst we could probably detect comptime and change the iterface decl for comptime code or smth.
<alexnask>
But I think you need a ptrCast no matter what
<alexnask>
Even if the whole small buffer/heap allocation thing is patched out at comptime
<Dodo>
var array = [N]Item undefined; <-- is this legal?
<Dodo>
N is a comptime usize
<alexnask>
var array: [N]Item = undefined
<Dodo>
oh okey
<Dodo>
it'd be sound to just write into it?
<Dodo>
I dont want to fill it with 0's, Im just gonna loop, and set each index to what I desire
<alexnask>
Yes
<alexnask>
There are no issues writing and/or reading, it's just that it's filled with "random" data in the beginning.
<Dodo>
oh okey :)
<Dodo>
mhhhh I should probably make 'collect_array' return an ![N]Item
<alexnask>
@Dodo that array would have to be heap allocated
<Dodo>
why?
<alexnask>
I mean, if you initialize it in collect_array it will live in its stack frame
<alexnask>
Or rather if you declare/define it in collect_array
<Hejsil>
You can return [N]T
<Hejsil>
By value
<alexnask>
Oh right sorry mb
<alexnask>
![N]Item should work too then right?
<Hejsil>
Ye
<Hejsil>
Though [1000]T is probably a bit to much :)
<Dodo>
which does exactly the same, but it's just awkward there xD
<alexnask>
Rust macros wird me out
<alexnask>
weird*
<Dodo>
once pass by value is implemented, collect_array can be much more simple: 'var written = self.collect_slice(array[0..]); if written == N {return array} if written < N {return CollectError.Underflow} else {return CollectError.Overflow}'
<alexnask>
Why do you need pass by value for this?
<alexnask>
You should be fine to pass the slice byref, no?
<Dodo>
but collect_slice uses .map(),
<Dodo>
and when using .map(), the Items are passed in by value into the function
<alexnask>
Ah, right, collect_slice is the issue, gotcha
<alexnask>
That's a pretty clever way to write it btw.
<Dodo>
the nice parts of abstractions :)
<alexnask>
I have 41 '.special = ConstValSpecialStatic;' in my PR lol
<GitHub35>
zig/master f37e79e Andrew Kelley: Merge pull request #963 from zig-lang/atomic-stack-and-queue...
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
davr0s has joined #zig
<andrewrk>
alexnask, alright! today's the day - pointer reform
ofelas has joined #zig
alexnask has quit [Read error: Connection reset by peer]
alexnask has joined #zig
ofelas has quit [Quit: shutdown -h now]
ofelas has joined #zig
helloworld1234 has joined #zig
helloworld1234 has quit [Client Quit]
Dodo has joined #zig
<Dodo>
is there a function that copies one slice into another?
<Dodo>
or method,
<MajorLag>
std.mem.copy?
Hejsil has joined #zig
<Dodo>
oh yeah
<Dodo>
why isn't that memcpy? ;o
<Hejsil>
Well, it's in the mem part of std
<Hejsil>
That kinda implies it's memcpy
<Hejsil>
You would probably always call it through the mem namespace: mem.copy
<Dodo>
I mean in the implementation, it's a manual loop
<Hejsil>
The loop is safer, and if done correctly, the compiler should optimize the loop into @memcpy
<Dodo>
oh whoa
jfo has joined #zig
jfo has quit [Remote host closed the connection]
jfo has joined #zig
<Dodo>
alexnask, there also should be a library that does parallel iteration ^-^
<Dodo>
where it makes sense ofcourse, but there's a few things
<Dodo>
how do I compile a lib btw? lib\zig\std\special\bootstrap_lib.zig:6:5: error: expected 3 arguments, found 2 @export("_DllMainCRTStartup", _DllMainCRTStartup);