ChanServ changed the topic of #zig to: zig programming language | ziglang.org | be excellent to each other | channel logs: https://irclog.whitequark.org/zig/
Ichorio has joined #zig
Ichorio has quit [Ping timeout: 268 seconds]
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
_whitelogger has joined #zig
darithorn has quit []
jfondren has joined #zig
<jfondren> is there a neater way to perform this trick in Zig? https://gist.github.com/jrfondren/705ea4119f44bc744c3abe353451709f (the only point is the 'elegance' of the solution, as that's how the C was presented)
porky11 has joined #zig
_whitelogger has joined #zig
_whitelogger has joined #zig
RagingDave has joined #zig
return0xe has quit [Remote host closed the connection]
davr0s has joined #zig
porky11 has quit [Read error: Connection reset by peer]
return0e has joined #zig
_whitelogger has joined #zig
Ichorio has joined #zig
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
davr0s has joined #zig
RagingDave has quit [Remote host closed the connection]
Triplefox[m] has quit [Ping timeout: 250 seconds]
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
davr0s has joined #zig
porky11 has joined #zig
_whitelogger has joined #zig
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
dbandstra has quit [Quit: Leaving]
davr0s has joined #zig
SimonNa has quit [Remote host closed the connection]
SimonNa has joined #zig
<andrewrk> jfondren, you could use an unknown length pointer to get a nearly identical port
<andrewrk> ah you are using an unknown length pointer. you can use pointer arithmetic
<andrewrk> oh you are using pointer arithmetic
<andrewrk> never mind. your code looks fine to me. I would argue that this code is not elegant, although it's not clear to me what it's trying to do
<andrewrk> e.g. you could just print a hard coded string which is the answer
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
tom1998 has joined #zig
<tom1998> Hey!
<andrewrk> hi tom1998
<tom1998> I'm trying to link with -framework Cocoa on OSX to link GLFW statically, but that seems to segfault the compiler
<tom1998> I'm linking dynamically just fine, but anyone else had issues with this?
<tom1998> Hey andrewrk, back with the questions;)
<andrewrk> the next step to troubleshoot this is for me to try to reproduce the problem on osx, or for you to use a debugger and provide a stack trace
<tom1998> I can run it through valgrind?
<tom1998> oh no wait, i don't even have that
<tom1998> not even sure valgrind is available on osx, i'll run it through gdb when i get back if that's an option(??)
<andrewrk> in my experience lldb works best on macos
<tom1998> That'll be the one then, never really used it!
<tom1998> Hey, whilst I'm here, how can I define a package?
<tom1998> It's not really documented anywhere AFAIK, but I want to be able to define a folder as a package and have it be importable from anywhere else
<tom1998> Seems(?) like the way to do this is to make it a 'package'?
<tom1998> Is it just, pkg-begin "pkg-name" "folder"?
<tom1998> Oh, for future reference, it's pkg-begin "pkg-name" "folder/index.zig", then pkg-end - why the need for the pkg-begin and pkg-end, what can i put in the middle here?
<andrewrk> more --pkg-begin arguments
<andrewrk> it's a tree structure. consider that your dependencies can have dependencies
<andrewrk> are you using zig build?
davr0s has joined #zig
<tom1998> no, just a makefile, i'll have a look
<tom1998> So, it builds a separate binary then links it? So i can have --library flags for that specific package?
<andrewrk> never mind. if you're using a makefile then use --pkg-begin / --pkg-end
<andrewrk> it's not "folder", it's "path to the root file of the package"
return0e has quit [Remote host closed the connection]
<tom1998> andrewrk: Any notion of a tuple, or construct that could be similarly useful?
<tom1998> whew, fast on that link, get asked that a lot?;)
<tom1998> I want to make an iterator that iterates over tuples
<tom1998> I can use an array of *u8 and just ptrcast, but that's pretty horrible as a commonly used API
<tom1998> I've looked at ArrayList.Iterator, and found it returns an ?T - you can then use while(iter.next()) |item| {}, which is cool
<tom1998> how does this work with named return types
<tom1998> Oh sorry, I didn't read far enough, I see the tuples proposal was accepted
tom1998 has quit [Quit: Lost terminal]
return0e has joined #zig
Ichorio has quit [Ping timeout: 252 seconds]
wink_ has quit [Quit: http://www.kiwiirc.com/ - A hand crafted IRC client]
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
lkurusa has joined #zig
davr0s has joined #zig
porky11 has quit [Quit: Leaving]
daurnimator has joined #zig
<daurnimator> Hi all, I just found zig; you seem to have made the same mis-steps as go and rust. From what I've read so far, it's actually usable as a systems programming language with the potential to replace C
<daurnimator> uh to ***not*** have made
<daurnimator> andrewrk:
<daurnimator> gah, sorry
<andrewrk> I was gonna say, damn you're coming in here and laying down the law
<andrewrk> hahaha
<daurnimator> andrewrk: I'm just reading through the manual now
<daurnimator> curious if you have builtins that provide details on bitfields?
<andrewrk> are you talking about reflection?
<andrewrk> ah yes bit fields are not documented yet: https://ziglang.org/documentation/master/#packed-struct
<daurnimator> not necessarily for a packed struct. e.g. what if I want to expose a bitfield directly to some C function. I'd love a way to pass along "this char* pointer; this shift; this mask"
<andrewrk> you want to pass that along to C?
<andrewrk> you can do that by using @typeInfo on a pointer type and then passing the data to a C function
<daurnimator> yeah. e.g. if you wanted to expose a bitfield to some other language via the C ABI.
<andrewrk> right now the bit field information is missing from @typeInfo but there's an issue to add it
<daurnimator> andrewrk: ah ha! I was scanning for it in https://ziglang.org/documentation/master/#typeInfo and didn't see it :)
<andrewrk> the type of a bit field pointer has extra metadata like this: `*align(2:3:2) const u32`
<daurnimator> FWIW I'm about half way through the manual and have seen the `test` syntax a lot; yet it hasn't been introduced. not sure if you want to bring it earlier in the manual? or at least link to it? (or maybe I just missed links)
<andrewrk> daurnimator, good point. I think the langref should mention it directly after Hello World
<daurnimator> infact values are introduced before structures/syntax. that's probably a good thing, but probably need to forward reference some things; and use a very limited subset of syntax while introducing values
<daurnimator> on the other hand, this is a reference manual. I'm probably incorrectly using it as a no-bullshit "getting started" guide
wirelyre has joined #zig
<andrewrk> it's intended to be both, but due to the nature of the changing language, it won't always succeed at both of those goals until the language is stabilized and I do a final audit
<wirelyre> I'd be interested in a small code sample with hyperlinks on each syntactic element to the appropriate section
<daurnimator> misc note: using "dot products" to define "dot syntax" is a little confusing.
<wirelyre> Just as a quick reference
<wirelyre> andrewrk: I found issue #1535, "create a linker" today and wanted to ask what the scope of that would be
<wirelyre> e.g. would *all* builds run that linker, or just debug incremental builds
<andrewrk> wirelyre, all
<daurnimator> :( no opt-in fall through in switch
<daurnimator> while as an expression returning values is odd... I've seen languages with it before (e.g. coffeescript) and it's usually ended up introducing bugs or slowness more than it's been helpful
<wirelyre> how would that interact with linker scripts? would this require a full implementation of them?
<andrewrk> wirelyre, yes it would\
<daurnimator> In the malloc bit of https://ziglang.org/documentation/master/#Optionals , when you add an extern for malloc, how do you know that 0 is null? Or is the 0 pointer unrepresentable?
<daurnimator> Where is truthyness defined? I'm not sure if `0` is considered false or true? -> is it narrowed to bool? That doesn't seem to match the implicit casts section....