ChanServ changed the topic of #zig to: zig programming language | https://ziglang.org | be excellent to each other | channel logs: https://irclog.whitequark.org/zig/
<Shucks> @ikskuh, zpm didn't built for me btw. `.\src\main.zig:726:16: error: no member named 'kv' in struct 'std.hash_map.GetOrPutResult'`
<ikskuh> oh yeah
<ikskuh> i didn't maintain it for some while
<ikskuh> you might need to patch it up to the new hashmap api :D
<Shucks> some day maybe ;D
<ikskuh> :D
<ikskuh> yeah, same here ^^
<Shucks> std.os.windows isn't complete yet huh?
<ikskuh> i need vacation to patch up all projects
Shucks has quit [Quit: Leaving]
frmdstryr has quit [Ping timeout: 256 seconds]
layneson has joined #zig
<shcv> why is zig assuming that my []const u8 is 128bits long?
<shcv> or is that the length of the pointer, as 2x usize?
<daurnimator> shcv: how did you get it?
<daurnimator> `someptr[0..128/8]` will actually give you a `*[16]T`
layneson has quit [Ping timeout: 272 seconds]
<shcv> I'm creating a data structure with comptime K = [] const u8, and calling a function with parameter key: var via a method in that structure, passing in "key". The function gets the size of the key it's passed with @bitSizeOf(@TypeOf(key)). I realized it probably isn't getting the right size, since that's actually a runtime value; so is it giving the size of the representation of a slice?
<shcv> er, to make that a little clearer, passing "key" -> method(K) -> function(key: var) -> @bitSizeOf(@typeOf(key))
<fengb> Yeah @sizeOf([]const u8) is always 2x usize
<fengb> What you want in this case is slice.len * @sizeOf(u8)
<shcv> suppose my slice is less than usize long; how can I copy it into a usize?
<shcv> @bitCast doesn't work because the sizes don't match
<fengb> You can convert the usize into bytes. Something like std.mem.copy(u8, std.mem.asBytes(&num), slice)
<fengb> Requires a memcopy because the size doesn’t match
<shcv> and going the other way?
<shcv> oh
<shcv> I see I think
<shcv> making it an as-bytes pointer?
<fengb> asBytes converts any pointer into a byte slice so you can copy raw bytes into existing memory
<fengb> You’ll probably want to initialize the usize to 0 as well
<shcv> yep
<shcv> ok, I think that worked; thanks
<ifreund> the github repo now has exactly 6k stars
_Vi has quit [Ping timeout: 272 seconds]
bastienleonard has quit [Ping timeout: 272 seconds]
adamkowalski has joined #zig
<adamkowalski> How do you create a ArrayList from a array literal?
<adamkowalski> For example a std.ArrayList([]const u8)
<adamkowalski> Can I create it from something like .{"hello", "world"}
<shakesoda> i'm pretty sure you have to copy into it if you want to do that
<oats> adamkowalski: I don't see any functions that directly copy that and make a new one
<oats> but you could use the insertSlice method on ArrayList
<oats> might be better to just make your own convenience function
<adamkowalski> the goal is just to make my unit tests cleaner and so I don't want to create the array list and then append the elements one by one
<adamkowalski> I was hoping to just declaratively write out the data structure and then compare them for equality
<adamkowalski> Can I do something like ArrayList([]const u8).fromOwnedSlice(allocator, .{"foo", "bar"})
<oats> fromOwnedSlice requires that the slice was allocated by that allocator, unfortunately
<adamkowalski> okay well is there something in that vain that I can do? If the tests contain that much procedural logic it distracts from the point of the test.
<adamkowalski> In c++ I would just write std::vector<int>{1, 2, 3};
<adamkowalski> or in rust I could write vec![1, 2, 3]
<adamkowalski> Theres nothing like that for zig?
<ikskuh> adamkowalski: .init(), appendSlice()
<adamkowalski> Why doesn't this work?
<adamkowalski>
<adamkowalski> var foos = std.ArrayList([]const u8).init(&leak_count.allocator);
<adamkowalski> try foos.appendSlice(&[_][]u8{"foo"});
craigo has quit [Ping timeout: 256 seconds]
<oats> adamkowalski: what doesn't work about it?
xackus has quit [Ping timeout: 240 seconds]
shcv has quit [Read error: Connection reset by peer]
<adamkowalski>
<adamkowalski> try foos.appendSlice(&[_][]u8{"foo"});
<adamkowalski> ./tests/tokenizer_tests.zig:24:35: error: expected type '[]u8', found '*const [3:0]u8'
craigo has joined #zig
<oats> adamkowalski: try replacing '[]u8' with '.'
<oats> .{"foo"}
<adamkowalski>
<adamkowalski> ./tests/tokenizer_tests.zig:24:26: error: inferred array size invalid here
<adamkowalski> try foos.appendSlice([_].{"foo"});
<oats> try foos.appendSlice(&[_].{"foo"});
<oats> slice literal syntax is a bit unwieldy, I wish there were some sugar
<adamkowalski> Same compile error
<adamkowalski> yeah I might write a generic function which reflects on the type of thing passed in, iterates over the members of the anonymous struct and appends each to an array list, then returns it
<adamkowalski> but it seems a bit strange there isn't an easy way of just saying give me a vec given an allocator and some literals
<oats> try foos.appendSlice(&[_][]const u8{"foo"});
<oats> just spitballing here
<adamkowalski> Hey that worked!
<adamkowalski> Thanks a lot :)
<oats> yay, sure
<oats> I wonder why it wouldn't take the anonymous array
stripedpajamas has joined #zig
<oats> ArrayList([]const u8).from(alloc, .{"foo", "bar"})
<oats> I don't think I see a reason that couldn't be written
* oats will poke around a bit
<fengb> Tuples can’t coerce into slices right now, only arrays
<oats> right
<oats> but that would be kinda like std.debug.warn, right? taking a var parameter and doing some struct reflection magic
<fengb> There’s a bit of work trying to get &.{foo, bar} to work but it gets tricky internally
<fengb> That’s possible but it actually generates a function per tuple len. So probably not ideal
<adamkowalski> How come something like this won't work
<adamkowalski>
<adamkowalski> fn arrayListFromSlice(allocator: *std.mem.Allocator, slice: [][]const u8) !std.ArrayList([]const u8) {
<adamkowalski> var arrayList = std.ArrayList([]const u8).init(&leak_count.allocator);
<adamkowalski> try arrayList.appendSlice(slice);
<adamkowalski> return arrayList;
<adamkowalski> }
<adamkowalski> Sorry I'll start posting onto some sort of gist site
<oats> again, error please? :P
<adamkowalski>
<adamkowalski> ./tests/tokenizer_tests.zig:15:74: error: expected type '[][]const u8', found '*const [1][]const u8'
<adamkowalski> const foos = arrayListFromSlice(&leak_count.allocator, &[_][]const u8{"foo"});
<fengb> You need []const []const u8
<fengb> This creates a slice from implicit, which is a const in Zig: &[_][]const u8{"foo"}
<adamkowalski> thanks! the nested const works
<adamkowalski> If I make it take in a comptime T: type to make it work across different types of slices how much is my compile time going to be effected?
<adamkowalski> Will that only generate one function per type? So it would be the same slow as if I had actually wrote each of those functions myself?
<adamkowalski> Also how does errdefer interact with panics? If something panics, does stack unwinding happen and then all your errdefers run and clean up your resources?
<oats> I do not believe panics will run errdefers
<adamkowalski> Or if you get a stack overflow, or a out of bounds error with an array, does everything leak
<oats> nor regular defers
<adamkowalski> Okay, so non recoverable errors leak. I figured but I wanted to know if there is a magic solution
<adamkowalski> Also is it like Erlang where you if you have multiple processes, and one panics, does that kill everything. Or can the rest of the processes run and recover
<fengb> Yeah panics are unrecoverable
<adamkowalski> Okay so how are decisions made about what is recoverable/unrecoverable errors?
<fengb> Typically unreachable / panic means dev error
<fengb> Error return is an application error
<adamkowalski> so it's for invariants which you want to hold and if they are ever invalidated you must terminate
<fengb> Um... I don’t quite understand type theory
<oats> adamkowalski: basically yeah. "this shouldn't happen. send an angry email to the dev"-type situation
<adamkowalski> Sounds good, thanks for all the help
<oats> thanks for flying zig air
<adamkowalski> fengb: I pretty much just meant it's your contract/precondition/assertion you must hold before you call a particular function
<fengb> Yeah sounds about right
pangey has quit [Ping timeout: 264 seconds]
pangey has joined #zig
aerona has quit [Remote host closed the connection]
adamkowalski has left #zig ["ERC (IRC client for Emacs 28.0.50)"]
stripedpajamas has quit [Quit: sleeping...]
stripedpajamas has joined #zig
<companion_cube> well done on the 501c3, must not have been easy
adamkowalski has joined #zig
<adamkowalski> Is there some documentation for the zig build system?
<adamkowalski> I'm finding unit testing pretty confusing, if I run zig test filename then things seem to work
<adamkowalski> However, I need to use relative paths for things to be found
<adamkowalski> If I use the build system I can say b.addTest("filename.zig")
<adamkowalski> then do .addPackage(.{.name = "name", .path= "filename"})
<adamkowalski> now I can refer to the package like what the standard library does
<adamkowalski> now I can run all my tests, but how do I get --test-filter working again?
discipulus has joined #zig
Mulugruntz has joined #zig
adamkowalski has quit [Remote host closed the connection]
stripedpajamas has quit [Quit: sleeping...]
adamkowalski has joined #zig
Mulugruntz has quit [Ping timeout: 256 seconds]
Mulugruntz has joined #zig
<pixelherodev> Oh they leeft
<pixelherodev> left*
<pixelherodev> I was going to point out that I'm literally adding support for a platform which C doesn't target right now :P
<dch> mmm was the stream recorded yesterday anywhere? so far i found a weird pasta "recipe", cabbage references (not in pasta thankfully), and a pre-show.
discipulus has quit [Ping timeout: 245 seconds]
<pixelherodev> lol
<pixelherodev> It'll probably be uploaded soonish
<dch> patience grasshopper then
<pixelherodev> Yeah, exactly
<pixelherodev> All the previous ones have been recorded, I can't imagine this one wasn't
<pixelherodev> andrewrk: didn't want to bring this up pre-showtime because I figured you had more important things on your mind; I opened a PR to alter CBE per our earlier discussion (C becomes an ObjectFormat, alongside ELF, WASM, etc, instead of a special cased bool in {link,main,module}.zig)
<pixelherodev> The test case internally uses a bool, as it currently doesn't have a method of specifying object format, but eventually I'll probably patch it to support those too
<pixelherodev> Anywho, going to sleep now; I plan on finishing 16-bit ELF support tomorrow, then taking a few days off from Zig to finish off Ikiru and Scas so that I'll have fewer obligations competing for my time :)
discipulus has joined #zig
<discipulus> Why does the emacs zig-mode run test in ReleaseFast mode?
<dch> ^5
adamkowalski has quit [Ping timeout: 246 seconds]
<andrewrk> squeek502, you really confused me at the beginning of the show, haha
<squeek502> me?
<andrewrk> oh I'm so sorry, I got you mixed up with ryan worl
<squeek502> haha :)
<andrewrk> my mental hash table of user names to real names had a hash collision :)
<squeek502> the ryan conglomerate
<andrewrk> yeah, understandable, coming from the Andrew conglomerate. honestly I've never met an Andrew I didn't get along with
adamkowalski has joined #zig
adamkowalski has quit [Ping timeout: 256 seconds]
gruebite has quit [Ping timeout: 244 seconds]
dermetfan has joined #zig
<daurnimator> andrewrk: 0 length slices seem to not set .ptr?
cole-h has quit [Quit: Goodbye]
Shucks has joined #zig
<Shucks> Heya
<Shucks> is there something to get a string representation of a type in zig?
_whitelogger has joined #zig
<daurnimator> Shucks: @typeName
<Shucks> That answers my question but thats not exactly what im looking for. I basically wan't to print a string representation of any zig variable.
<Shucks> Like nim's ´repr` https://nim-lang.org/docs/system.html#repr%2CT
discipulus has quit [Ping timeout: 245 seconds]
<squeek502> Shucks, maybe std.fmt.bufPrint or std.fmt.allocPrint?
<squeek502> std.fmt.bufPrint(buf, "{}", .{your_value});
<squeek502> that'll give you a string representation using std.fmt.format: https://ziglang.org/documentation/master/std/#std;fmt.format
<squeek502> those docs aren't updated actually, here's the latest: https://github.com/ziglang/zig/blob/e1a5e061ca7897ce6e08b724d517a83ae439bf41/lib/std/fmt.zig#L36-L77
frett27_ has quit [Ping timeout: 265 seconds]
drewr has quit [Ping timeout: 260 seconds]
drewr has joined #zig
<squeek502> if instead you just want to print it out, then std.debug.print("{}", .{your_value}); will do the same thing
<squeek502> (this is for latest master, if you're on 0.6.0 the API might be different)
<Shucks> Thats what im trying but I guess I just get the type and the memory location of it. https://paste.sh/kvmVDhJf#CdTsrnb_Ea2953_3OPhNLb3X
<squeek502> ah yeah thats how it prints slices/arrays, not sure if there's a way to get it to print the elements
<Shucks> Aye, it works for structs
adamkowalski has joined #zig
<Shucks> So the next newbie question I'm wondering: Would I be able to cast t into Vec2? https://paste.sh/Zq4LPmQc#jRZhKGB2uitnSmPFvpmBUqmC
<squeek502> my guess would be no, or possibly 'not easily'
<squeek502> but i dont know much about packed structs
adamkowalski has quit [Ping timeout: 272 seconds]
<daurnimator> Shucks: hmm. I think @bitCast will work for that example
<lemmi> you can probably get away with a memcpy, but i'd rather do the manual assignments and have the compiler/optimizer figure out the rest
<squeek502> Shucks, @bitCast does work: https://paste.sh/yruE3uKR#eFz8qWy2BkODm7Pt0Kwq_o-w
<squeek502> prints Vec2{ .x = 5.0e+00, .y = 4.0e+00 }
<Shucks> perfect. So zig fits for my purposes.
wootehfoot has joined #zig
<ifreund> shachaf: thought you might be curious what it was: calling c._exit(0) instead of std.os.exit(0) fixed it.
<ifreund> now I need to figure out why :D
craigo has quit [Ping timeout: 240 seconds]
xackus has joined #zig
gpanders has quit [Quit: ZNC - https://znc.in]
gpanders has joined #zig
<shachaf> ifreund: That's interesting. Not sure what else std.os.exit does. Some atexit cleanup?
<ifreund> yeah that's what the man page says
<ifreund> I couldn't reproduce in a minimal program so I think libwayland might cause some atexit things to happen
discipulus has joined #zig
Shucks has quit [Ping timeout: 256 seconds]
<ikskuh> awww yiss! Rename 'var' type to 'anytype' #5846 merged into master!
<ikskuh> Thanks, Vexu!
xackus has quit [Ping timeout: 258 seconds]
azarus has joined #zig
<azarus> Is there documentation for std.debug.warn, for its formatting parameters?
<azarus> I currently want to format floating point numbers and want to print them to stdout.
<ikskuh> std.debug.warn is deprecated
<ikskuh> it's now std.debug.print or std.log.{err,crit,warn,notice,…}
discipulus has quit [Ping timeout: 245 seconds]
<ikskuh> otherwise, look at the documentation comment of std.fmt.format
<ikskuh> it's the root of all formatting in zig
<azarus> ikskuh: ah, alright then. Are there docs for std.debug.print? I can't seem to find any at https://ziglang.org/documentation/master/std
<ikskuh> no, that doc is horrible outdated
<ikskuh> read the source!
<ikskuh> use ZLS!
<azarus> oh heh alright then
<ikskuh> std.debug.print is pretty much only "output this to stdout and ignore all errors"
waleee-cl has quit [Quit: Connection closed for inactivity]
dingenskirchen has quit [Quit: dingenskirchen]
dingenskirchen has joined #zig
_Vi has joined #zig
<ikskuh> pixelherodev: i finally wrote my answer to #3786
<ikskuh> got longer than i expected
<ikskuh> _Vi, you were discussion ABI as well: https://github.com/ziglang/zig/issues/3786#issuecomment-657209764
<_Vi> ikskuh, What is Zig community and developers' stance on dynamic linking in general? If they were building a Zig-centered operating system, would it primarily use shared objects like typical today's operating systems?
<azarus> Once Zig matures a bit, having an exercism track for it might be nice.
<ikskuh> _Vi: I'm strongly against dynamic linking if not necessary (think plugins)
<ikskuh> it just makes deployment harder, your program bigger and your code less optimized
<_Vi> ikskuh, Is it because of typical RAM got orders of magnitude bigger the dynamic linking starting to fall out of favour for new developments?
shakesoda has quit [Quit: Connection closed for inactivity]
<ikskuh> nah
<ikskuh> dynamic linking has some pros (you could update libs without recompiling)
<ikskuh> it makes some licencing stuff easier
<ikskuh> but in general, i think dynamic linking was never really about saving RAM
<ikskuh> my strongest argument against dynamic linking is imho the space you save when not linking dynamically
<ikskuh> imagine you link against a huge library, but only use one function
<ikskuh> with zig/static linking, you only get this function in your app, probably inlined even
<_Vi> (replied in the issue)
<ikskuh> with dynamic library, you drag in *all* 99% other functions as well
<_Vi> Is the idea of supporting Swift ABI in Zig a good one?
<ikskuh> i haven't looked at it
<ikskuh> but it should be possible imho
<ikskuh> > But that performance hit is only expected to be around the ABI surface, not around private functions.
<ikskuh> Have you read my argumentation with struct layouts?
<_Vi> As far as I understand, you don't have to be Switch to use Swift ABI (like with "C ABI"). And although there are some peculiarities in it, it is considered a good engineering work by some article (even abstracting away from Apple world).
<_Vi> ikskuh, "Have you read my argumentation with struct layouts?" -> No, but I think I know what to expect there. Structs mentioned in exported functions are also counted as "around ABI surface".
<ikskuh> yes
<ikskuh> but structs in zig are special
<ikskuh> really special
<ikskuh> "you don't read from a field? → don't emit that field in the binary"
<ikskuh> zig allow reordering structs to have maximum perf
<ikskuh> all of this would be gone with an ABI
<ikskuh> we have extern structs already which follow the C ABI
<_Vi> ikskuh, In Swift ABI, structures are dynamically laid out by default (there are hidden fields that point to what is stored where). There is special "frozen" attribute to make them faster (and laid out simpler), but making changes to it not semver-compatible.
<ikskuh> > Can Zig ever be a "main system programming language for a shared libraries-based platform" without such ABI?
<ikskuh> Yes, by using C Abi
<ikskuh> which is the sane way for *any* new language
<ikskuh> (or any old, anyways)
<ikskuh> C++ suffers heavily from this
<_Vi> In any case a document that describes Swift ABI is worth reading prior to thinking about defining some new ABI for a high-level-ish language.
<ikskuh> zig is not high-level-ish :D
<ikskuh> can you link me the swift abi specification?
<_Vi> I don't know where is the specification, but the article I read is this: https://gankra.github.io/blah/swift-abi/
<ikskuh> no specification → i'm not even considering it a "good" or even an "ABI" :D
<_Vi> "I don't know where" != "no".
<_Vi> (I haven't programmed any Swift)
<ikskuh> yeah but i couldn't find any yet ;)
<_Vi> Maybe it's a work in progress.
<_Vi> On of main points of Swift ABI compared to C ABI is that you can add things to public structures and preserve ABI compatibility for ahead of time compiled code.
<ikskuh> you can do that in C as well
riba has joined #zig
<_Vi> (Obviously, at the cost of additional indirection and special associated metadata stored in the library)
<ikskuh> no
<ikskuh> additional metadata being "size"
<ikskuh> wonderful example:
<ikskuh> WinAPI
<ikskuh> It has several versions of the same struct with the same C function
<_Vi> ikskuh, What is your vision of Zig-based operating system userland? Will there be a "main system library"? Will it have raw syscalls as primary stable interface? How would security updates in crypto libraries be rolled out? Will there be high-performance plugins (e.g. for audio effects) or apps would be expected to e.g. use WebAssembly for plugins?
<ikskuh> i don't see how a "zig based operating" system does require *ANY* ABI definitions
<ikskuh> you *always* communicate with the kernel via syscalls
<ikskuh> also: do you really want an operating system only zig programs can run on?
<_Vi> ikskuh, For dynamic libraries, obviously. If no dynamic libraries then other questions need to be answered.
<ikskuh> that's utterly madness
<ikskuh> also here:
<ikskuh> why having a Zig ABI ruling out *all other languages exsiting*?
<ikskuh> "oh, you can't use C on that operating system, you cannot load the standard libraries"
<_Vi> ikskuh, Don't understand those last lines.
<ikskuh> yeah, i figured
<ikskuh> that's why you're still discussing :D
<ikskuh> programs on CPU arches have a "common ABI" as i explained to you
<_Vi> ikskuh, The general question is about though experiment about writing an operating system + some apps without any legacy baggage (such as existing C code).
<ikskuh> i know
<ikskuh> but that doesn't change a thing
<ikskuh> when you have an ABI for zig specifics
<ikskuh> people will use slices in all functions
<ikskuh> C doesn't have slices
<ikskuh> ruling out all C programs on that OS
<ikskuh> ruling out all C# programs
<ikskuh> all python
<ikskuh> all Rust
<ikskuh> …
<_Vi> ikskuh, So would you then define a "Common ABI" and use if for shared libs? Or would you avoid shared libs entirely?
<ikskuh> i would use the common abi ALREADY DEFINED
<ikskuh> because it's the sane thing to do not breaking with all existing infrastructure we already have
<ikskuh> which would happen if your shared objects use an ABI with zig types in it
<_Vi> ikskuh, "already defined", "existing infrastructure" -> It's not a question about practical things. It's more about dreaming than about doing. Imagine you have create your own CPU arch from scratch. It happens to have kernel mode and user mode. It happens to have protected memory for user mode. How would you design software part of the picture.
<ikskuh> <_Vi> Imagine you have create your own CPU arch from scratch. It happens to have kernel mode and user mode. It happens to have protected memory for user mode. How would you design software part of the picture.
<ikskuh> i already did that and i'm working on the software parts
<ikskuh> so i know what i'm talking about
<ikskuh> the point is: "zig abi" isn't really a nice thing to have, sticking to a smaller ABI surface is way more sane
<ikskuh> even if it means more work
<_Vi> ikskuh, Can there be a smaller ABI surface that is nonetheless bigger than C ABI?
<_Vi> (not full Zig abi, but still enables many niceties)
<ikskuh> not really
<_Vi> I see "slices" mentioned multiple times above. How do they affect ABI? Aren't they just equivalent to a pair of arguments: pointer + size?
<_Vi> So there can be, for example, ".CWithSlices" ABI that is like ".C" ABI, but slice-typed function arguments automatically lowered into a pair of arguments.
<ifreund> an abi is only useful if you can get people to speak it. Everyone already speaks c abi, breaking from this would lead to greatly reduced reusibility and interopreability of your software.
<ikskuh> we could define just slices on C ABI as structs
<ifreund> get everyone to start writing C code with struct { char *ptr; size_t len; } char_slice;
blinghound has joined #zig
<blinghound> I want to wrap a simd vector/matrix c library into a zig library for open source use, what's the best way to alias a c function?
<blinghound> should I just use inline functions?
<_Vi> There are multiple ways to pass a slice using C ABI: two arguments vs one argument to a struct. Pointer first or length first. "C-with-slices" ABI is supposed to formally bless one of those ways, making nicer to use from Zig code and nudge other languages and libraries to also start using that specific way of passing a slice.
blinghound has quit [Remote host closed the connection]
<ikskuh> _Vi: to my knowledge, there's not even a differene between those two :D
<gonz_> Do we have any venues through which to get Zig swag like mugs and stuff, potentially contributing to the foundation?
<ikskuh> for the C abi/x86, it's the same code that gets emitted :D
<ikskuh> gonz_, there's a inofficial store for merch
<gonz_> Oh, right, I found it now. The Teespring one?
craigo has joined #zig
layneson has joined #zig
xackus has joined #zig
layneson has quit [Ping timeout: 272 seconds]
layneson has joined #zig
xackus has quit [Ping timeout: 264 seconds]
xackus has joined #zig
Shucks has joined #zig
<Shucks> Im trying to wrap some stuff from the win api. How would I define a null terminated char array string? https://paste.sh/1lfjfhDr#g6x95K0qK0amlGgacoc0giuT
epmills has joined #zig
<ikskuh> you can use a sentinelled pointer:
<ikskuh> [*:0]const u8 // pointer to const u8 which is terminated by 0
<epmills> hey, everyone. what's the idiomatic way to read characters from the terminal without echoing (e.g. to read a password)?
<ikskuh> epmills: there's no way to currently do that
<ikskuh> at least no standard way
<Shucks> mh, that gives me a empty result
<ikskuh> you have to change your terminal emulator mode
<ikskuh> hm?
blinghound has joined #zig
<Shucks> Guess im using it wrong because I actually define that struct to undefined. Not sure tho
<blinghound> error: unable to resolve typedef child typepub const __m256 = @compileError("unable to resolve typedef child type"); // C:\Portable Apps\zig\lib\zig\include\avxintrin.h:34:15
<epmills> thanks, ikskuh. saw this in the 0.6 release notes ("nofmal added a basic Linux termios implementation") but wasn't sure how to apply.
<blinghound> trying to compile against a c library that uses simd instructions and I'm getting this error when trying to use a function from it
<epmills> was translating from rust using termion crate. maybe i can look the crate's src and figure out.
forgot-password has joined #zig
<ikskuh> you can look here for reference non-echong on windows and linux
forgot-password has quit [Client Quit]
<epmills> cheers, ikskuh - much appreciated
shcv has joined #zig
<shcv> g
<shcv> how does one use doc comments?
<ikskuh> write ///
<ikskuh> :D
<ikskuh> doc comments always comment the object after the doc comment
<shcv> but how do I view them? or test that they worked they way I wanted?
<shcv> I'm also curious how one might add a doc comment to a whole module
<shcv> or file I guess
<shcv> I could make a struct in the file containing all of the functions, and add a doc comment to that, but that would add an extra layer of names... unless I import the namespace?
<ifreund> /!
<ifreund> oops, //!
<ifreund> see e.g. std.log
<shcv> interesting
<Shucks> where can I read about that `?` and `!` before type definition?
layneson has quit [Ping timeout: 272 seconds]
layneson has joined #zig
<Shucks> found out ? is optional ;p
<Shucks> oh, nice website
waleee-cl has joined #zig
layneson has quit [Ping timeout: 264 seconds]
<epmills> agreed. i love zig but i struggle without examples. sites like ziglearn.org really help so thanks!
adamkowalski has joined #zig
adamkowalski has quit [Ping timeout: 256 seconds]
<Shucks> Yup. Hope it will complete soon
<Shucks> Still hard to find stuff like string handling
<Shucks> Like a simple split can be found nowhere ;D
<ifreund> std.mem
<ifreund> std.mem.split in particular iirc
cole-h has joined #zig
Mulugruntz has quit [Ping timeout: 246 seconds]
<Shucks> Still messing around with that script. Seems like the windows api doesn't accepts anything else than [MAX_PATH]u8. Could I cast that array later to a null terminated string?
<ikskuh> yes
<ikskuh> you can use that array and pass it to std.mem.span
<ikskuh> or just use indexOf:
<ikskuh> const str = if(std.mem.indexOf(u8, &array, 0)) |i| array[0..i] else &array;
Mulugruntz has joined #zig
xackus has quit [Ping timeout: 272 seconds]
blinghound has quit [Remote host closed the connection]
xackus has joined #zig
layneson has joined #zig
adamkowalski has joined #zig
<Shucks> Weird that doesn't does anything. I'm pretty sure because my array isn't filled with null characters. "undefined" actually gives every field the highest value?
<ifreund> it's 0xaa in debug/release-safe
<ifreund> actually undefined in release-fast
adamkowalski has quit [Ping timeout: 258 seconds]
blinghound has joined #zig
<blinghound> what is the case convention for public constants? PI for example
<ifreund> just foo.pi afaik
<blinghound> awesome, thanks!
<ifreund> std.math.pi is a thing fyi
<ifreund> np
<ifreund> we also have tau
<Shucks> build-exe without any args should give me a debug build right?
<ifreund> yes, that should be the default
<ikskuh> ifreund, help me! i'm stuck :D
<ifreund> ikskuh: what do I do??
<ikskuh> i've installed wtype
<ikskuh> it made my sway broken
<Shucks> Weird, gdb is not hitting any breakpoint on that build
<ikskuh> now i'm stuck, can't change the workspace, can't open new terminals and can't switch to another vconsole
<ifreund> that's probably related to https://github.com/atx/wtype/issues/6
<ifreund> are you running sway master or 1.4?
<ikskuh> can't tell you, i'm still stuck
<ikskuh> wtype seemed to change my keyboard layout
<ifreund> ah, you probably can't switch VT either
<ikskuh> ack
<pixelherodev> andrewrk: did you see my (in-IRC) proposal to add details to Models as a replacement for linker scripts?
<ikskuh> can't open dmenu as well :D
<ikskuh> oh i should ask in sway-devel :)
<ifreund> really the only thing to do is a hard reboot :/
<ifreund> but I'm guessing this should be fixed by https://github.com/swaywm/sway/pull/5204
epmills has quit [Remote host closed the connection]
epmills has joined #zig
epmills has quit [Remote host closed the connection]
blinghound has quit [Remote host closed the connection]
<ikskuh> ssh+reboot sounds smoother
<ifreund> yeah if you have another machine to ssh in with do that
<ikskuh> mobile phone + connectbot <3
<Shucks> I should be able to use gdb from mingw to debug zig code right?
<shcv> ikskuh: is magic sysrq enabled?
<ikskuh> i don't think so
<pixelherodev> ConnectBot = :)
epmills has joined #zig
<pixelherodev> Meh, just going to do it and PR
<pixelherodev> Worst case I waste ten minutes
<pixelherodev> Hmm, not Model actually
<pixelherodev> that would be good for *CPU*-specific changes, this is about the broader hardware
aerona has joined #zig
<Shucks> Anyone else having issues debugging zig code on windows? Gdb just says no debugging symbols found on zig binaries.
adamkowalski has joined #zig
<epmills> thoughts on embedding version and git hash into executable? build.zig the right spot?
layneson has quit [Ping timeout: 260 seconds]
<pixelherodev> epmills: definitely possible, and yes, ZBS is the way to go
<pixelherodev> look at std.ChildProcess
<pixelherodev> I use `git describe --abbrev=0`
<pixelherodev> You can also use `--dirty=+` if you want a `+` added to the revision if there are uncommitted changes
<epmills> cheers, pixelherodev. yeah, i like having that dirty flag in there as well. i use it with rust in build.rs.
<epmills> with rust, i can pass an env var that is avail via env! macro to embed in source. is there a similar comptime embed of env vars in zig as well (can't remember)?
redj_ is now known as redj
<pixelherodev> epmills: build options?
<pixelherodev> @import("build_options") IIRC
<epmills> pixelherodev: investigating... thx!
<pixelherodev> No problem :)
gpanders has quit [Read error: Connection reset by peer]
gpanders has joined #zig
gpanders has quit [Ping timeout: 256 seconds]
gpanders has joined #zig
<leeward> Shucks: You should, but I've heard there are issues. gdb certainly does work on Linux.
<Shucks> well I wanna play a bit with the windows api and zig
<leeward> I think there are some Windows users around who use the msvc libc and vscode.
<Shucks> I'm still that confused about the behaviour of `undefined` https://paste.sh/7LnI8thv#UMbmq0uw7FowgJBUiim0OH92
<fengb> undefined is 0xaa (repeating of course)
<fengb> If you convert those values to hex, they should all be 0xaaaa
<Shucks> So 0xaa is not null. How should I "null terminate" szModule and szExePath
Mulugruntz has quit [Quit: ZZZzzz…]
<pixelherodev> Are those strings?
<Shucks> yea
<ifreund> with a 0?
<ifreund> that's what null termination means in the context of c strings
<pixelherodev> Look into sentinel-terminated slices
<Shucks> ifreund, Yes, but if undefined fills that fields with 0xaa thats actually not 0 right? pixelherodev,
<Shucks> wops. replied to early
<Shucks> Gonna check it out. Thanks for now =)
<ifreund> no, undefined is not 0
<ifreund> I'm not totally understanding what you want to do tbh
<ifreund> create a string and pass it to C?
<pixelherodev> Then yeah, you want a sentineled slice
<Shucks> thats [*:0]const Char right?
<ifreund> that works to, but is a pointer not a slice
<ifreund> the a sentinal terminated slice would be [:0] and stores a length as well as the ptr
<ifreund> it looks like this api wants arrays though, so all you need to do is put the bytes of your string at the start of the array and the put a 0 right after it
<pixelherodev> `[:0]const Char`.ptr == `[*:0]const Char`
<pixelherodev> Is Char != u8?
<ifreund> lol might be UTF16
<pixelherodev> hahahaha
<pixelherodev> hahahahahahahahahahaha
<pixelherodev> Sorry, but
* pixelherodev rolls around on the floor, laughing
<Shucks> :p
<pixelherodev> Whelp, there goes my amusement
<scientes> Shucks, in all seriousness there is a gcc bug that complains that uint8_t doesn't have strict aliasing, as it IS NOT char
<pixelherodev> uint8_t != char; uint8_t == unsigned char
<pixelherodev> That's not a bug
<scientes> not unsigned char either
<pixelherodev> ...?
<scientes> pixelherodev, char is special in the c11 standard
<scientes> for strict aliasing rules
<ikskuh> unsigned char for all platforms with CHAR_BITS = 8
<ikskuh> scientes: afaik aliasing is allowed for char, unsigned and signed char
<pixelherodev> scientes: wait, really?
<pixelherodev> Huh
<scientes> and the GCC devs agree, but do not want to add another type
<pixelherodev> Wait, so GCC isn't actually complying to the C11 standard?
<scientes> pixelherodev, no, it is missing a possible optimization by keeping unsigned char and uint8_t the same type
Mulugruntz has joined #zig
kchambers has joined #zig
riba has quit [Ping timeout: 260 seconds]
<leeward> I have worked on a platform where `unsigned char` was 16 bits wide.
<leeward> It's a thing.
<ikskuh> leeward, so CHAR_BITS was 16? near :D
<ikskuh> *neat
<scientes> I don't consider that neat
<scientes> I consider it a PITA
<leeward> ikskuh: I don't know if neat is the word I'd use, but yeah. They had a uint8 type in their platform headers, but it was also actually 16 bits wide. Not a good feature in a system with 1k for global memory.
<scientes> that breaks the C standard
<ikskuh> :D
<ikskuh> scientes: why?
<scientes> oh no, it doesn't
<scientes> because the standard is funky
<leeward> It would break the C standard if it had claimed to support stdint.h
<ikskuh> char is defined to be at *least* 8 bit wide and sizeof(char) == 1
<fengb> PDP7 was an 18bit architecture
<scientes> ugggh
<ikskuh> :D
<scientes> the llvm model is much better
<fengb> Back before we standardized around octets
* ikskuh votes for 55 bit words
<fengb> C has a lot of historical baggage :P
<scientes> fengb, it isn't c++
<leeward> So much historical baggage.
<fengb> Well C++ also tried to add the kitchen sink
<fengb> 3 times
adamkowalski has quit [Ping timeout: 246 seconds]
<scientes> and the bathroom sink too
<leeward> I have a copy of C89 somewhere...
<scientes> have you looked at tcc?
<scientes> beautiful compiler
_Vi has quit [Ping timeout: 256 seconds]
nikita` has joined #zig
st4ll1 has quit [Ping timeout: 260 seconds]
st4ll1 has joined #zig
<leeward> Yeah, C99 CHAR_BIT is at least 8, but implementation defined.
<leeward> C is such a deceptively complex language. C++ gets a lot of flak for being impossible to grok, but C is so crufty its surface area is huge too.
<scientes> not if you keep the implementation sane
<scientes> the biggest problem is UB, and zig does that much saner
<ikskuh> scientes: sadly, a lot of C stuff people like to do is UB
<ikskuh> "ah yeah, unaligned access sometimes tend to crash, why is the compiler so stupid?!"
<fengb> x86 programmers you mean :P
<scientes> that is based on supporting hardware however
<fengb> UB is “fine” if it’s implementation defined
<ikskuh> fengb: nah, ARM
<scientes> and hardware that supports unaligned is harder to build, because of when it straddles a cache line
<scientes> but it does mean better code density
<fengb> But ARM actually crashes though...
<ikskuh> scientes: not even cache lines, but actual RAM access is harder
<scientes> fengb, not any more
<ikskuh> cortex-m3 does
<epmills> trying to get code that works from binary and 'zig run'. @import("build_options") not avail in latter (obviously)...
<epmills> but can i catch the failing import and provide a default value?
aerona has quit [Ping timeout: 246 seconds]
<leeward> scientes: Anything is fine if you keep the implementation sane. That's a high bar.
<pixelherodev> scientes: gotcha
<pixelherodev> thanks for the explanation
Akuli has joined #zig
<leeward> epmills: You should be able to get the run mode with comptime variables, and check before trying to @import.
<pixelherodev> leeward: C is nowhere *near* C++ complexity.
<leeward> pixelherodev: I didn't say it was, I said it was bigger than people tend to think.
<pixelherodev> I'm not going to say C isn't more complex than I'd like, because it is, but conflating the two is just *wrong*
<pixelherodev> "[Like C++,] C's surface area is huge too" is what I read, but that might have been me misreading what you were saying
<leeward> C is much bigger than most C programmers realize. C++ wears its complexity on its sleeve.
<gonz_> It's not as if most things in C++ are there to be explicit about its complexity, though.
<leeward> I'm putting C in the same class as C++ because they're both above the "hold the whole thing in head at once" threshold. C++ is still orders of magnitude bigger, but they're both over the limit.
<leeward> gonz_: C++ programmers know that things like templates and copy constructors are complex features that require care in their use.
aerona has joined #zig
<leeward> Not that I'm excusing C++. I avoid it every chance I get. I'm just saying that C has an undeserved reputation for simplicity.
<leeward> epmills: There's also `zig build run` if that's an acceptable substitute for `zig run`
<gonz_> I'm with you that the complexity of languages extends beyond their language surface area.
xackus has quit [Ping timeout: 256 seconds]
<gonz_> It just doesn't seem to me like most of C++'s complexity is it being clear about its complexity inherited from C, but rather just a long series of additions by people interested in adding things + the hidden and unintuitive behavior those things create + the inherent complexity of C, still unclear
codic56 has joined #zig
<codic56> heyo, i notice that the hello world example has a return type of !void for the main function. what's the difference between void and !void?
<epmills> leeward: thx - i'll check it out
<gonz_> codic56: `!void` means it has no return value but may return an error.
<gonz_> `!` alone before a type means an inferred error type
<leeward> codic56: !void is an error union of void and an inferred error enum.
* leeward is slow.
<gonz_> `SomeErrorUnion!ReturnType` means we are specifically returning just that error union or the return type.
<codic56> ah okay
<codic56> i see, thank you!
<gonz_> Use inferred error unions when you can, they're nice. :)
<codic56> also, what's the difference between a returntype of void and noreturn?
<gonz_> You also don't have to worry about messing this up, Zig takes care to check whether or not you can return an error.
<leeward> Functions that return void return, there's just no data.
<oats> gonz_: I would have guessed that it's better practice to explicitly enumerate your errors, no?
<leeward> noreturn means they never return.
<gonz_> oats: There's no technical downside and sometimes you actually have to because the error union can't be inferred.
<gonz_> oats: But I've found that it never really makes things much nicer to be specific.
<leeward> oats: Not necessarily. If you have a function that might only return one member of an error enum, the caller's catch block still has to either handle all the possible values in that enum or have an "else".
<gonz_> You'll always get exhaustive checks regardless in `catch` and friends.
<codic56> leeward: but main never returns does it?
<oats> codic56: just as an example, os.exit() is noreturn because it terminates the program right then
<leeward> codic56: It can, if it doesn't have any infinite loops in it.
<leeward> That's one way to terminate a program.
<codic56> leeward: ah, okay
<codic56> oats: i see, I get it now. thanks!
codic56 has quit [Remote host closed the connection]
<oats> gonz_, leeward: good points, thanks!
<oats> I was starting to have some trouble in a little side project keeping track of all the errors that could bubble up, in one error set
<gonz_> oats: I will say that I used to be specific about it, but ended up removing most of the cases because it just became a burden when adding more `try X` calls.
<leeward> @typeInfo.error_type is implemented now, right?
<gonz_> In cases where you very much need a function to be specific and always only return a very specific set of errorss I think it makes a lot of sense.
codic86 has joined #zig
<gonz_> But for the most part the part I want is just exhaustive checks and correct bubbling up.
<codic86> how can i make a function that accepts a string of any length?
<leeward> codic86: fn foo(string: []const u8) void {}
<oats> codic86: well, a string is just a slice of bytes
<codic86> if i make it accept []u8 it says that it finds *const [stringlength:0]u8
<codic86> ah okay
<gonz_> codic86: `fn takesAString(string: []const u8) R`
<oats> yeah, it needs to be const :)
<leeward> At some point (after self-hosted is working) we'll do an error message niceness pass, and anything where it expected (T) but found (thing that could be coerced to const T, but not to T) it will suggest adding const to your parameter type.
xackus has joined #zig
<codic86> what i'm trying to do is create a println function https://hastebin.com/ebipuvekup.java but it says "expected 3 arguments, found 2
<leeward> stdout.print takes another argument: .{} if you don't have any {}s in your format string.
<codic86> ah k
<leeward> I think what you want is `try stdout.print("{}\n", .{s});` though.
<codic86> but then it says unable to evaluate constant
<codic86> ah
<leeward> Also, you'll have an issue since you're calling it without a try block in main. `try println("hi");`
<leeward> That's another one of the hard-to-interpret error messages.
<codic86> ah
<leeward> Oh, and println isn't noreturn, it's void.
<codic86> yeah, i realized
<leeward> :)
<codic86> stdout.print("{}\n", .{s}); this says that expression value is ignored for some reason
<codic86> but if i assign it to _, it says i ignored an error
<leeward> That sounds like a missing `try`
<oats> _ = try stdout.print("{}\n", .{s});
<oats> huh, so you can't tell zig to ignore the returned error as well?
<oats> I thought that would be included in the _ =
<fengb> foo() catch unreachable;
<gonz_> You can do `thing catch unreachable`
<gonz_> It's intentionally ugly
<fengb> It’s intended to look kludgy
<fengb> Ha
<gonz_> :D
<leeward> If you want to ignore an error, you have to do it the ugly way, yeah.
<oats> "Zig: making the wrong thing ugly"
<leeward> The path of least resistance is to bubble errors up. That's by design.
stripedpajamas has joined #zig
<codic86> i'm still confused, i got to https://hastebin.com/alecotiluk.java though
<oats> codic86: you still need the 'try' in front of 'stdout.print()'
<oats> zig doesn't like it when you pretend that function won't return an error :P
<leeward> Line 8 doesn't need the "_ =", and line 4 needs "_ = try"
<leeward> Think of an error union as a wrapped type. It might be an error, it might be the type. You have to unwrap it to resolve which it is. That's what `try` does.
<leeward> The return type for stdout.print is Error!void. To get at the void, you have to unwrap the returned value.
<leeward> So it looks like line 4 doesn't need a _ either.
<leeward> The only return value Zig will let you ignore is {}, which is the only value of type void.
<codic86> Perfect, it works now!
<codic86> This is a strange concept that I'm not really used to, but I'll try to get used to it
<leeward> codic86: https://godbolt.org/z/sE4c76
<leeward> codic86: try to get used to it, and you will eventually catch on.
<leeward> sorry, I can't help myself.
<codic86> yep, thanks
<codic86> leeward: what do you mean?
<leeward> try/catch jokes are bad.
<codic86> ohhhh lol i didn't even catch that
<leeward> codic86: What languages are you coming from?
<leeward> /facepalm
<codic86> well, i've done python and ruby in the past, and in terms of compiled languages i've done go, nim, and c++
<codic86> i also know a bit of web js
<leeward> Ok, so nothing with algebraic data types (C++17 notwithstanding, because they're awful to use)
<codic86> nope, why?
<leeward> That's what optionals and error unions are.
<fengb> It’s kinda like checked exceptions if each failable function needed its own try
<leeward> We should get a good explanation somewhere. That is a broader than average set of languages.
<fengb> Or Go if the if nil is hidden behind try
<codic86> fengb: ahh okay
<fengb> The only major difference is that Go lets you ignore the error sometimes, whereas Zig usually forces you to try or catch it
<codic86> With Go I just write the error to _ instead of a variable (since then I have to use the variable) when I'm sure that I can ignore it
<fengb> I can assign the error in Go and just never bother checking it. Zig is a bit more anal
<fengb> Yeah but you can also assign to err and forget to check
<leeward> Take Go's multiple return values and wrap them up in a single type. That's what an error union is.
<fengb> Zig decided that was bad so you need a more explicit silence
<leeward> "Communicate intent precisely." - zig zen bullet #1
<scientes> leeward, C has multiple return values in the ABI
<scientes> even if the language does not have it
<leeward> scientes: return structs by value
<scientes> I know
<leeward> It's in the language, just basically nobody uses it.
codic86 has quit [Remote host closed the connection]
<scientes> because it isn't really part of the language
<scientes> it isn't like in go
<leeward> It definitely isn't like Go.
<scientes> they don't use it because you have to have your function have two names
<scientes> which is stupid
<leeward> Huh?
layneson has joined #zig
<scientes> leeward, yeah your function is named f and foo_t
<scientes> that is why people don't use it
<leeward> Because the return type needs a name?
<leeward> The struct could just as easily have been called err_int_t.
<Shucks> I gave up. Im just not able to convert that array into a []const u8 :p
<gonz_> An array coerces to a []const slice with `&array`
<scientes> not anymore
<scientes> use [0..]
<leeward> What?
<leeward> When did that change back?
<gonz_> wut
<scientes> it now stays a slice, although i think it still implicitely casts
<scientes> *now stays an array
<scientes> unless it changed back
<ifreund> that's what coerces means no?
<scientes> well, something changed in that area
<scientes> because it use to be really hard to cast from array to slice
<scientes> and now you can
<scientes> but then i think it was fixed up so it stays an array
<ifreund> anyhow, you can probably pass &array to whatever wants a slice
layneson has quit [Ping timeout: 258 seconds]
ur5us has joined #zig
ifreund has quit [Ping timeout: 258 seconds]
blinghound has joined #zig
<blinghound> I'm aware of @Vector, but how can I manually use intrinsics like avx?
<leeward> Is there a builtin for the max value of an integer type? I can't seem to find it.
<ikskuh> <scientes> because it use to be really hard to cast from array to slice
<ikskuh> not really since 0.5
<ikskuh> once arrays coerced to slices implicitly, now pointer-to-array coerces to slice implicitly
<blinghound> leeward thanks for the link! Is there anything higher level at the moment? If not I'll definitely use this
<ikskuh> nope
<ikskuh> you could implement a AVX-Module which exposes those functions
<leeward> blinghound: Not that I know of, but I haven't done anything with vector instructions in Zig.
<blinghound> leeward is this what you were looking for btw https://ziglang.org/documentation/0.6.0/std/#std;math.maxInt
<scientes> you could use the llvm intrinsics for arch-specific stuff
<ikskuh> but i don't think it's a good idea to expose those intrinsics to the language itself
<leeward> It is! Thanks.
<scientes> you can call llvm intrinsics directly
<scientes> its a bit of a hack however
<scientes> and llvm has arch-specific intrinsics, like avx2
<blinghound> scientes actually those might be perfect for what I'm trying to achieve
<scientes> you have to look at the llvm source to get the names
<blinghound> ah crap lol
<scientes> and then see how zig uses an intrinsic to allocator memory on wasm
<scientes> blinghound, it isn't that hard with git grep
<scientes> to find what you need
nikita` has quit [Quit: leaving]
<blinghound> is the wasm memory allocator in the zig repo?
<blinghound> I'll have a try grepping
<scientes> you might also be able to call them by their gcc intrinsic name
<blinghound> that might be easier for now actually
<scientes> I said "might", I haven't tried it
<blinghound> is it possible now to cast an array of f32s to a zig Vector without a copy?
<scientes> blinghound, yeah,
<scientes> there is am implicit cast
<Shucks> I did that with @bitCast today I guess
<scientes> the bitCast that got merged doesn't seem to work correctly
<Shucks> Well that worked for me: https://paste.sh/Zq4LPmQc#jRZhKGB2uitnSmPFvpmBUqmC
<Shucks> casting t into vec2. Not sure how the built in vecs look like
<ikskuh> omg. paste.sh wtf.
<ikskuh> yu cannot select full words to copy them. the site will then js-alert
<scientes> Shucks, the built in vec is just llvm vector type
<Shucks> ah alright
Akuli has quit [Quit: Leaving]
<shcv> how much do y'all recommend zig-network vs std for udp networking?
<Shucks> learn
<Shucks> ops*
<ikskuh> shcv: std doesn't do UDP atm
<ikskuh> zig-network does UDP on both windows and linux :)
<leeward> std is pretty incomplete.
<ikskuh> (tested)
* ikskuh does shameless self promotion
<pixelherodev> andrewrk: ping me when you have a chance to discuss ELF16 / CBE design a bit more :)
<shcv> that makes it a pretty easy decision then
<shcv> would be nice if there were a few more examples :P
<ikskuh> oh yeah, i could link my stuff
<ikskuh> give me a second
<pixelherodev> ikskuh: why not merge your UDP into STD?
<ikskuh> if this, we should merge zig-network in one piece
traviss has quit [Quit: Leaving]
<ikskuh> shcv: search here for multicast_sock
<ikskuh> xnet is now called zig-network and i should replace that file ther :D
traviss has joined #zig
<shcv> ikskuh: thanks
<ikskuh> it does everything you want from UDP
<ikskuh> Multicasting :D
<ikskuh> btw, zig-network does *not* support broadcasting :D
<shcv> has anyone done raw IP networking?
<ikskuh> (because it's not in IPv6)
<shcv> that's probably good enough
<shcv> though I'm not that familiar with udp multicast
<ikskuh> udp multicast is neat
<ikskuh> you join a multicast group (IP) + port
<ikskuh> and every joined user receives the messages for that group
<ikskuh> it's like you've bound your socket to an IP not local to your computer
<shcv> interesting
<shcv> what's the magic number stuff in your header for?
<leeward> shcv: raw IP networking...in Zig? Or in general?
<shcv> either really
<leeward> Yeah, I spent 6 years working on network devices.
<shcv> cool
<leeward> Haven't really touched it in Zig though, except to try opening a socket.
<ikskuh> shcv, where exactly?
<ikskuh> leeward, have you experience with lwIP or other "embedded" network stacks?
<shcv> L#1261
<ikskuh> that's a classic magic number
<ikskuh> protocol identifier
<shcv> so, for your dunstblick protocol?
<ikskuh> yeah
<ikskuh> oh man…
<ikskuh> possible talk #4 :D
<ikskuh> but i need to make a nicer demo yet
<leeward> ikskuh: We used the BSD network stack for the things I worked on. Only the management interface actually had a real network stack hooked up though, so it didn't consume much in the way of resources.
<ikskuh> ah
<ikskuh> i want to replace the windows network stack in a project of mine
<ikskuh> because it is buggy and i need faster arping
<leeward> Last I looked, Windows incorporated a very old version of BSD's stack. There was even a resolv.conf file tucked away somewhere.
<ikskuh> haha
layneson has joined #zig
<ikskuh> my plan is: disable ipv4, ipv6 and use lwIP + libpcap
<andrewrk> pixelherodev, no I did not see your proposal, can you do it in a github issue?
<leeward> ikskuh: I'm so glad I don't have to support Windows.
<ikskuh> leeward: legacy…
blinghound has quit [Remote host closed the connection]
<shcv> where does the msg.numberOfBytes come from?
<shcv> nvm, I found it
layneson has quit [Ping timeout: 256 seconds]
<shcv> how does your UdpBaseMessage work for receiving messages? it doesn't look like it would necessarily be large enough to handle the incoming message, and I don't really know how extern unions work either...
<andrewrk> daurnimator, if you add orderedRemove to hash maps, you should be able to remove the array list of header entries from Headers
<Shucks> How would I find the index of 0 here? https://paste.sh/9NBOyw0O#xHM0WzjkZ8VTUhBW26_dFSoW
<andrewrk> Shucks, it looks like you've already figured it out, no?
<shcv> wouldn't you just put 0 instead of " "?
<Shucks> well that returns "null"
<Shucks> using 0 says expected type '[]const u8', found 'comptime_int'
<ikskuh> shcv: for udp, i can tell the OS that my buffer that large and any message longer than that will be truncated
<shcv> maybe [_]u8{0}[0..] ? I'm not sure how to do literal slices... or maybe "\x0" would work
<andrewrk> Shucks, oh, look for the scalar functions
<andrewrk> indexOfScalar
<Shucks> that did it. Thanks
<shcv> ikskuh: I think I see; os.recvfrom passes buf.len to to system.recvfrom, so it should Just Work™
<ikskuh> yep
<ikskuh> i'm gone for the night.
<ikskuh> good luck!
<shcv> g'night
stripedpajamas has quit [Quit: sleeping...]
wootehfoot has quit [Read error: Connection reset by peer]
<Shucks> gnight
<pixelherodev> andrewrk: I could, but it's more of an idea I tossed out for immediate discussion and less an actual concrete plan
<pixelherodev> Plus after thinking it over I realized it wasn't a very good idea, either
<pixelherodev> andrewrk, ikskuh: one option for the short term would be to tweak my emulator to have 64KiB of RAM and no ROM, allowing us to hold off on figuring out linker scripts but still get the raw CPU codegen working
<pixelherodev> That'd require most of the *linker* changes later, while allowing the actual backend itself to be worked on *now*
ifreund has joined #zig
<ifreund> pixelherodev: RE the joinZ helper function I think you may be right but am not confident enough to open a PR changing the param to comptime
<Shucks> So zig's tables are hashmaps?
<ifreund> tables?
<Shucks> like python dicts
<pixelherodev> ... you mean our HashMaps? :P
<ifreund> there are no language-level tables/dicts in zig...
<pixelherodev> Yes, our HashMaps are HashMaps XD
<ifreund> there are hashmaps in the std
<Shucks> pixelherodev, thanks ;p
<pixelherodev> Thank ifreund; he actually gave useful info lol
<pixelherodev> I just gave you a tautology :P
<Shucks> thank you aswell ;)
<ifreund> :D
<leeward> pixelherodev is as helpful as pixelherodev.
<ifreund> true that
<leeward> The first rule of tautology club is the first rule of tautology club.
<pixelherodev> What have I done.
<pixelherodev> (What I have done is what i have done, I know)
<leeward> Hey, I stopped.
<leeward> Note the heroic use of restraint.
dermetfan has quit [Ping timeout: 256 seconds]
<pixelherodev> haha
xackus has quit [Ping timeout: 272 seconds]
epmills has quit [Remote host closed the connection]
epmills has joined #zig
epmills has quit [Remote host closed the connection]
dingenskirchen has quit [Remote host closed the connection]
dingenskirchen has joined #zig
bastienleonard has joined #zig