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]
Ichorio has quit [Ping timeout: 260 seconds]
<achambe> andrewrk: do you have an idea of what you want to base a package manager on?
<achambe> looking at buildbot at the moment for the less conventional platforms. Python support seems to be a common denominator.
<achambe> oh, the travis build servers are actually pretty beefy.
cenomla has joined #zig
cenomla has quit [Quit: cenomla]
<GitHub65> [zig] tgschultz opened pull request #939: DirectAllocator alignments > os.page_size on posix (master...large-alignment-directalloc) https://git.io/vpYj0
<alexnask> @andrewrk Is there any way to inline varargs into a function call?
<alexnask> Here is my usecase (this is a call function for DirectSound COM objects)
<alexnask> Otherwise I'll probably switch on the args.len and repeat the call with multiple versions using indexing on the varargs
davr0s has joined #zig
heakins has quit [Ping timeout: 260 seconds]
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<achambe> neat, the compiler builds on openbsd
davr0s has joined #zig
alexnask has quit [Ping timeout: 255 seconds]
qazo has quit [Read error: Connection reset by peer]
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<achambe> andrewrk: trying to work out how to do another build profile for openbsd
<achambe> since its nested inside linux on travis haha
<achambe> painfully slow in qemu, but I generate an image that can be used for CI either in a VM, or launched on something like amazon/google cloud. And have a script that also runs the build under qemu
alexnask has joined #zig
<GitHub108> [zig] BraedonWooding opened pull request #940: Functional Module: Map/Reduce/Filter (master...Functional) https://git.io/vpOkV
<achambe> heh, C++ build times are just terrible
<achambe> but i don't think it will timeout
<GitHub58> [zig] andrewchambers opened pull request #941: Openbsd ci (master...openbsd_ci) https://git.io/vpOLf
<achambe> yup, it times out haha
<achambe> andrewrk: I sent you an email, but I think I was mistaken in it
ofelas has quit [Quit: shutdown -h now]
davr0s has joined #zig
<alexnask> 2296 bytes for a fullscreen window + DirectSound initialization, things are getting pretty tight already :P
<alexnask> @andrewrk The symbols produced through .def files have an underscore prefixed and for each one of them a jmp to the actual function is generated
<alexnask> Actually, I'm pretty stupid, I guess this is expected with DLLs
Braedon has joined #zig
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
davr0s has joined #zig
Ichorio has joined #zig
<alexnask> Are there any thoguhts on standarizing an Iterator interface type?
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<alexnask> Here is an example of a mostly automated way to create interfaces once @riefy is available (with an example Iterator interface): https://gist.github.com/alexnask/e299728343571f54fbffcc7f07af78b0
<alexnask> Ir emoves the need for an interface implementation to include a vtable field
<alexnask> Instead, the interface type holds a reference to the object (this is interface-dependant, you could store the object inline or have some small buffer optimization + heap allocation)
<alexnask> + a pointer to the vtable which is automatically generated for each object type passed in
<alexnask> In this example, any type that has a 'fn next(&Self) ?T' method can be passed in to Iterator.init and have its vtable automatically generated at comptime.
<alexnask> While the 'fn reset(&Self) void' function is optional
<alexnask> method*
jjido has joined #zig
<alexnask> This is a great way to separate the implementation type from the interface/vtable type, all the user has to do is write an implementation with the functions the interface require and then pass it in to the interface's init method
<alexnask> (Also, the reverse, you can write an interface and have it accept types defined in other libraries, etc...)
davr0s has joined #zig
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
davr0s has joined #zig
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Braedon has quit [Ping timeout: 260 seconds]
lorde_kumamon[m] has quit [*.net *.split]
dtz has quit [*.net *.split]
raytracer[m] has quit [*.net *.split]
davr0s has joined #zig
<andrewrk> hi achambe
raytracer[m] has joined #zig
dtz has joined #zig
lorde_kumamon[m] has joined #zig
clebermatheus[m] has quit [Ping timeout: 240 seconds]
lorde_kumamon[m] has quit [Ping timeout: 256 seconds]
dtz has quit [Ping timeout: 256 seconds]
kammd[m] has quit [Ping timeout: 245 seconds]
raytracer[m] has quit [Ping timeout: 256 seconds]
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<GitHub69> [zig] andrewrk pushed 1 new commit to master: https://git.io/vpOBG
<GitHub69> zig/master a3e9ae8 Andrew Kelley: travis: use encrypted env vars for s3 credentials
davr0s has joined #zig
<GitHub90> [zig] andrewrk closed pull request #939: DirectAllocator alignments > os.page_size on posix (master...large-alignment-directalloc) https://git.io/vpYj0
<GitHub160> zig/master 3010668 Andrew Kelley: Merge pull request #939 from tgschultz/large-alignment-directalloc...
<GitHub160> zig/master a1083b0 tgschultz: Added DirectAllocator support for alignments > os.page_size on posix systems
<GitHub160> [zig] andrewrk pushed 2 new commits to master: https://git.io/vpOBd
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
davr0s has joined #zig
jjido has joined #zig
<MajorLag> andrewrk: alignment > page size came up for me recently because I'm writing an allocator and stealing a concept from rpmalloc: if you align your span headers to i.e. a 64kb boundary then you can find them from any slice passed to free with a single instrution.
<andrewrk> neat
<andrewrk> I'm about to merge your time PR. just playing around with aux vectors and seeing if I can get the vdso hooked up
<MajorLag> there's one more small thing I should do on that: change the Windows error checking to check for windows.FALSE instead of 0, just for clarity.
<andrewrk> I've merged your changes in a branch, can you show me the diff and I'll apply it locally?
<MajorLag> k, it's like, 3 lines changed it's a tiny thing
<andrewrk> hmm, one of the auxilery vectors is the os page size
<andrewrk> but I think it's pretty valuable having page size available as a comptime constant
<andrewrk> maybe we'll just assert that we didn't get it wrong
<MajorLag> yeah. once you start looking at page size at run time you're probably more interested in hugetables anyway.
<andrewrk> auxv comes with a random seed too, that's nifty
<andrewrk> we could potentially save a call to getrandom()
<andrewrk> thanks, applied locally
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<andrewrk> random thought: std.debug.warn can be made simultaneously thread-safe and better performance by using writev
jjido has joined #zig
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
jjido has joined #zig
jjido has quit [Client Quit]
SimonNa has joined #zig
kammd[m] has joined #zig
lorde_kumamon[m] has joined #zig
dtz has joined #zig
clebermatheus[m] has joined #zig
raytracer[m] has joined #zig
davr0s has joined #zig
minxomat has joined #zig
minxomat has quit [Client Quit]
<alexnask> Can I cast a slice from a type to another?
<alexnask> Or should I initialize a new slice and set .ptr and .len correctly?
hryx has joined #zig
<achambe> andrewrk: yeah, the qemu approach with ccache on travis sort of works haha. the bonus with how it is setup is that doing linux arm is probably really similar
<andrewrk> achambe, awesome
<achambe> the time limits on travis are the biggest risk, as it is currently it needs a few failed builds to warm that ccache cache
<andrewrk> I think your build bot idea is going to be the realistic answer here
<achambe> yeah
<andrewrk> another nice thing about this is that I can use your script to do OpenBSD development in qemu
<achambe> yeah, i know its not so easy for people who haven't installed it before.
<achambe> I have automated a freebsd install in the past too, but lost the code unfortunately
<achambe> i don't think it is urgent to merge or use it yet. but its a good reference for the future
<andrewrk> achambe, yeah, even if we close it for tidyness, we can link to it from the open issue for openbsd support
<achambe> openbsd is also slow changing enough i think the script will be valid in 1
<achambe> year or more
<hryx> Hello! Silly question: I'm having trouble initializing a two-dimensional array with the ** syntax. Is it possible to do so?
<andrewrk> hi hryx
<hryx> There are good examples of 1d arrays in the docs, but I didn't find much for 2d arrays
<andrewrk> questions are welcome here
<hryx> Fantastic~
<andrewrk> let me come up with an example
<andrewrk> one way to do it is to create an array of column, and multiply that by the row. like this: https://github.com/andrewrk/tetris/blob/master/src/main.zig#L106
<hryx> I see - you create and initialize the row first, then the columns in a separate statement
<hryx> I'll try that
<alexnask> @andrewrk Is casting a []T to a []V valid or am I doing something hacky?
<hryx> the Tetris snippet uses []T, but when I try [32]T it does not like it: https://hastebin.com/ikigejufay.md
<hryx> Does ** only work for slices?
Ichorio has quit [Ping timeout: 240 seconds]
<andrewrk> alexnask, you have to cast through []u8 first to avoid breaking strict aliasing rules
<alexnask> Right, I'm casting from []u8 so everything should be fine
<andrewrk> hryx, try removing the 'w'
<andrewrk> const empty_row = []u8{'a'} ** w;
<andrewrk> var grid = empty_row ** h;
<andrewrk> so you're making a [1]u8 and multiplying it by w to make a [w]u8
<andrewrk> then multiplying that by h to make a [h][w]u8
<andrewrk> alexnask, that inserts a runtime safety check to make sure your []u8 len is divisible evenly by @sizeOf(T)
<andrewrk> and then it adjusts the len property of the new slice for you
<hryx> Ah! ok, I'll try that
<hryx> Interesting, does the `for` construct only work on slices, not [x]T types?
<hryx> e.g. for (somearray) |thing| {...}
<hryx> By the way, my end goal here is to be able to address (and mutate) a 2d array: grid[x][y] = 'a'
<hryx> I'll study your Tetris code more closely
<andrewrk> hryx, for works on arrays as well as slices
<hryx> 👍
<andrewrk> the array syntax is admittedly a little clunky - we have a couple issues open to address it
<hryx> Got it working. Awesome help, thanks a big ol' basket
qazo has joined #zig
<andrewrk> np, happy hacking
<andrewrk> is your work open source?\
<andrewrk> MajorLag, I got the vdso working :) about to push
<hryx> Me? I'm just dipping my toes into Zig, so there's nothing to share yet :> But eventually, yeppp
<hryx> had a long-running C project which I'm thinking of porting to zig
<andrewrk> hryx, fun. if you push anything, feel free to drop a link here and I'll keep my eye on it
<hryx> will do sir!
<andrewrk> all aboard the merge train
<GitHub164> [zig] andrewrk closed pull request #933: Std.os.time (master...std.os.time) https://git.io/vpIjq
<GitHub27> [zig] andrewrk pushed 2 new commits to master: https://git.io/vpO6D
<GitHub27> zig/master 371a3ad Andrew Kelley: Merge branch 'tgschultz-std.os.time'
<GitHub27> zig/master 7af6ed3 Andrew Kelley: add alignment docs
qazo_ has joined #zig
qazo has quit [Ping timeout: 260 seconds]
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<MajorLag> Oh I see, you do the vDSO lookup in the bootstrap, that makes snese.
qazo has joined #zig
qazo_ has quit [Ping timeout: 248 seconds]
<andrewrk> MajorLag, not quite - we copy the aux vectors in the bootstrap which gives us the VDSO address, but then we do the lookup in the first clock_gettime call
<MajorLag> I guess I didn't read far enough.
<GitHub197> [zig] andrewrk closed pull request #891: Type Independent String Functions (master...StringUtils) https://git.io/vxMTV
<GitHub126> [zig] andrewrk closed pull request #940: Functional Module: Map/Reduce/Filter (master...Functional) https://git.io/vpOkV
<GitHub159> [zig] BraedonWooding opened pull request #944: Just a few std.mem changes (master...MemChanges) https://git.io/vpO1u
<hryx> Must all struct methods have a `self` parameter? The Vec3 example in the docs has a `pub fn init()` which doesn't. Is `init` a specially-recognized method name?
<MajorLag> no, init doesn't take a self parameter because it doesn't act on an existing struct instance, so it doesn't need one.
<MajorLag> these aren't really 'methods', they're just regular functions in the struct's namespace.
<hryx> Can any function inside a struct's namespace be defined either way, then (init isn't special)?
<hryx> i.e., if I supply a `self`, it's a method, and if I don't, it's not?
<MajorLag> there are no methods. As a convenience, you can call "instance.function()" and the instance will be passed as the first parameter implicitly, but otherwise they're all just regular functions
<hryx> I see. I think what I was missing is that the example calls `Vec3.init(...)`, where Vec3 is the type name, not an instance of Vec3
<MajorLag> there's some related info here: https://github.com/zig-lang/zig/issues/746
<hryx> Great, thanks MajorLag. I actually like the way it works, just got thrown off because the distinction between SomeType.func() and some_instance.func() wasn't too clear in the docs