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/
<Gliptic> std.mem.zeroes(type)
zags has quit [Ping timeout: 264 seconds]
<olabaz> Gliptic: very epic, thank you
leon-p has quit [Quit: leaving]
powerofzero has joined #zig
earnestly has quit [Ping timeout: 264 seconds]
powerofzero has quit [Remote host closed the connection]
powerofzero has joined #zig
powerofzero has quit [Ping timeout: 264 seconds]
notzmv has joined #zig
nvmd has quit [Quit: Later nerds.]
earnestly has joined #zig
olabaz has left #zig ["WeeChat 2.3"]
gazler_ has joined #zig
gazler has quit [Ping timeout: 246 seconds]
xackus has joined #zig
xackus_ has quit [Ping timeout: 245 seconds]
cole-h has joined #zig
neptunepink has quit [Ping timeout: 264 seconds]
neptunepink has joined #zig
notzmv has quit [Ping timeout: 260 seconds]
terinjokes has quit [Quit: ZNC 1.8.1 - https://znc.in]
terinjokes has joined #zig
notzmv has joined #zig
dyeplexer has joined #zig
midgard_ has quit [Read error: Connection reset by peer]
midgard has joined #zig
semarie has quit [Ping timeout: 265 seconds]
hnOsmium0001 has left #zig [#zig]
semarie has joined #zig
earnestly has quit [Ping timeout: 276 seconds]
halbeno has quit [Remote host closed the connection]
bitmapper has quit [Quit: Connection closed for inactivity]
halbeno has joined #zig
craigo has joined #zig
waleee-cl has quit [Quit: Connection closed for inactivity]
decentpenguin has quit [Read error: Connection reset by peer]
decentpenguin has joined #zig
sablib has quit [Quit: WeeChat 3.0]
cole-h has quit [Ping timeout: 245 seconds]
gpanders has quit [Ping timeout: 268 seconds]
gpanders has joined #zig
maier has joined #zig
xackus has quit [Read error: Connection reset by peer]
xackus_ has joined #zig
maier has quit [Ping timeout: 256 seconds]
notzmv has quit [Ping timeout: 260 seconds]
ur5us_ has joined #zig
earnestly has joined #zig
ur5us_ has quit [Ping timeout: 240 seconds]
zags has joined #zig
TheLemonMan has joined #zig
notzmv has joined #zig
notzmv has quit [Ping timeout: 276 seconds]
leon-p has joined #zig
maier has joined #zig
johannes_ has joined #zig
johannes_ is now known as kenran
_whitelogger has joined #zig
squeek502 has joined #zig
maier has quit [Ping timeout: 245 seconds]
kenran has quit [Quit: leaving]
notzmv has joined #zig
bjornroberg has joined #zig
zags has quit [Quit: leaving]
eax has joined #zig
bjornroberg has quit [Ping timeout: 245 seconds]
bitmapper has joined #zig
powerofzero has joined #zig
Wolf481pl is now known as Wolf480pl
<marler8997> being inspired by Andrew's big DOD change, I found the opportunity to use the same technique to improve this tiny-regex-c library: https://github.com/kokke/tiny-regex-c/pull/62
<marler8997> it's a pretty cool project, regex in like 500 lines of C code
<TheLemonMan> tiehuis wrote a nice regexp engine in Zig
<marler8997> hmmm, not sure it looks very DOD
<TheLemonMan> Department of Defense?
<marler8997> Data Oriented Design
<marler8997> which says nothing about the API, the api could be great
<TheLemonMan> ah
<TheLemonMan> g-w1, what happened to your PR for detecting TERM=dumb ?
<g-w1> closed because it was a hack
<g-w1> you said we need a terminfo parser
powerofzero has quit [Ping timeout: 260 seconds]
<TheLemonMan> I said it was a stopgap solution, writing a terminfo parser is boring and a lot of work
<g-w1> this still got merged, but its for progress so it also enables better progress printing for files/piping to stuff too https://github.com/ziglang/zig/commit/1bd434fd18e0cb769ca46849dac056a562ce7ce3
cole-h has joined #zig
<g-w1> andrewrk: would you reconsider 8026 now that 7920 has been merged?
powerofzero has joined #zig
mikdusan has quit [Read error: Connection reset by peer]
mikdusan has joined #zig
v0idify has quit [Ping timeout: 268 seconds]
midgard has quit [Ping timeout: 260 seconds]
midgard has joined #zig
wootehfoot has joined #zig
factormystic has quit [Quit: The Lounge - https://thelounge.chat]
powerofzero has quit [Ping timeout: 276 seconds]
cole-h has quit [Ping timeout: 245 seconds]
nvmd has joined #zig
powerofzero has joined #zig
simson has joined #zig
<simson> hi! I'm trying to understand Zig Github issue 1717. Does it mean that the more Rust-style function definitions (e.g. `pub fn foo() {...}`) are not possible anymore when this is implemented? Or is the RFC just an alternative way to make function definitions?
Raito_Bezarius has joined #zig
<ikskuh> simson: yes, that's the current accepted variant
<ikskuh> so a function definition will be
<ikskuh> const foo = fn() void { std.debug.print("Hello, World!", .{}); }
<Raito_Bezarius> Hi there, I'm trying to build a riscv64-uefi target and I'm getting lld-linker errors about "unknown file type" on an object file, could it be I'm doing something wrong?
<Raito_Bezarius> (version 0.7.1)
<TheLemonMan> is that a thing?
<simson> ikskuh: ok, thank you. Won't this hurt readability? It feels alot more lisp-y than C-like.
<Raito_Bezarius> AFAIK, riscv64-uefi is Tier 3
<ikskuh> i actually think it's better for readability
<ikskuh> as now *every* declaration is "(var|const) ${NAME} = ${VALUE};"
<ikskuh> and there is no distinction between functions (which cannot be local right now)
<TheLemonMan> Raito_Bezarius, I'll have a look
<Raito_Bezarius> Thanks TheLemonMan !
<simson> I understand that, its like in scheme every symbol is declared with (define ...). that makes sense since everything is treated like lists (or data if you will). But ALGOL/C-like language treats function and data differently and highlight that in syntax. I was just wondering, I don't have a strong opinion on this.
waleee-cl has joined #zig
<ikskuh> simson: zig doesn't treat them differently
<ikskuh> you can manipulate types, functions and *other* values
<ikskuh> you can also copy functions around at comptime
<ikskuh> you can even compute some new ones
dimenus has joined #zig
<simson> But functions usually live in a separated memory area. is this not the case with zig? Can I just allocate a function on the heap and mark it executable?
<ikskuh> welcome to lowlevel
<ikskuh> that's also possible in C
<ikskuh> but you need to assemble that function :D
<ikskuh> in zig you can create new functions at comptime with some workarounds (aka implementing a comptime programming language)
<ikskuh> for me, it's the biggest thing that is missing in zig for me besides having a proper support for address spaces and usize vs upointer
<simson> and having both ways to declare functions is not preferred to keep it "simple" I assume?
Barabas has joined #zig
<ikskuh> * Only one obvious way to do things.
<ikskuh> "declare something?"
<ikskuh> "const X = …;"
<Barabas> Hello, how do I write the type of a function pointer?
<ikskuh> construct something?
<ikskuh> "T { … }"
<ikskuh> Barabas: just use the function signature
<ikskuh> const FnPtr = fn() void;
<Barabas> thanks
<simson> ikskuh, that's fair. thanks for answering
dimenus has quit [Ping timeout: 264 seconds]
olabaz has joined #zig
<olabaz> if I'm trying to write a wrapper for a c header file. Is it better to use just one zig file or can I split it up into sections?
<g-w1> both work
<olabaz> it seems like splitting it up into multiple sections I will have to use @cimport multiple times and it will cause it read the header file multiple times
<g-w1> just make one file called c.zig that does pub usingnamespace @cImport ... then @import() that file from other ones
dyeplexer has quit [Remote host closed the connection]
<olabaz> g-w1: ooh ok I'll look into that
<olabaz> thanks
kenran has joined #zig
<olabaz> so previously I had c.func() now is it just func()?
<olabaz> I had done c = @cImport...; now with pub usingnamespace @cImport I can just directly call the stuff?
<g-w1> yes
<olabaz> ok cool everything is working agian!
riba has joined #zig
<olabaz> oh another question I had: I've been using f(comptime T:type,...) but I just realized I can do f(v :anytype)
<olabaz> what's the purpose of each
powerofzero has quit [Ping timeout: 256 seconds]
simson has quit [Quit: Leaving]
<TheLemonMan> Raito_Bezarius, llvm doesn't know how to emit a COFF file for RISCV64
Akuli has joined #zig
craigo has quit [Ping timeout: 260 seconds]
<Raito_Bezarius> ha, TheLemonMan, is there a way to avoid to emit a COFF at all?
<TheLemonMan> well, the whole EFI thing is just PE/COFF in disguise
<Raito_Bezarius> ah makes sense
<olabaz> is there a way to get the f32 from the type Complex(f32)
<TheLemonMan> you can probably get around that by building an ELF file and then re-assembling it as needed
<olabaz> I want to return f32 if input is Complex(f32) and f64 if it is Complex(f64)
<TheLemonMan> olabaz, what's Complex ?
<olabaz> std.math.complex.Complex
<olabaz> I am passing it in through comptime T:type
<TheLemonMan> @TypeOf(instance.re) ?
<TheLemonMan> Raito_Bezarius, edk2 genfw should do exactly that
<olabaz> yeah I tried that but then it fails if I put in just a regular f32
<olabaz> so I guess what I really need is f32 or Complex(f32) return f32 and similarly for 64
Ashpool has joined #zig
<TheLemonMan> how is that failing?
<Raito_Bezarius> TheLemonMan: good point
<olabaz> error: type 'f32' does not support field access
<TheLemonMan> hmm, can you show some code? it seems you're trying to call .re on a number
<olabaz> oh is that not what you meant?
<olabaz> what is instance
<TheLemonMan> an instance of Complex(T)
<olabaz> hmm, I'm confused. my T = Complex(f32)
<Gliptic> olabaz: you want a function that is identity for f32 and .re for Complex?
<olabaz> yeah and also works for f64
wootehfoot has quit [Quit: Leaving]
marijnfs has joined #zig
<TheLemonMan> show some code
<marijnfs> not a fan of there format changes
<marijnfs> not i can't use {x} anymore?
<TheLemonMan> no
<marijnfs> the {s}/{any} is also annoying, can't we just have {} do regular things
<TheLemonMan> no
Akuli has quit [Ping timeout: 260 seconds]
<TheLemonMan> x/X is still printing the slice/array contents in hex, if you want back the old condensed hexdump format follow the instructions contained in the error message
<olabaz> my function header is: pub fn asum(comptime T: type, x: *matrix.Matrix(T)) T.re
<TheLemonMan> oh I see, you don't have an instance
<TheLemonMan> @TypeOf(@as(T, undefined).re) should work :)
<olabaz> should I even be using comptime for this anytype?
<olabaz> ok I'll try that
<TheLemonMan> but you're better off using some helpers in std.meta to inspect the field types in T
<olabaz> hmm still says f32 doesn't support field access
<marijnfs> TheLemonMan: you say {x} should still kind of work? cause it gives me an error
<TheLemonMan> olabaz, is T f32 or Complex(f32) ?
<olabaz> it can be either
<TheLemonMan> marijnfs, no, please read the error
<marijnfs> ah ok, because you said 'x/X is still printing the slice contents in hex'
<TheLemonMan> olabaz, then you need a function that switches on the T
<marijnfs> 'wrap your argument in std.fmt.fmtSliceHexLower instead' is a bit unclear
<marijnfs> which argument
<TheLemonMan> marijnfs, it _should_ print the slice content as `{ 0x00, 0x00, ... }` ... but right now it can't because we're showing the error message
<g-w1> the one that you want to hex
<TheLemonMan> the argument you're printing?
<marijnfs> ok, cause the formatting string is also an argument
<marijnfs> they are arguments to the function
<TheLemonMan> but that wouldn't make any sense, no?
<marijnfs> what's the rationale, don't we want fmt to make printing easy?
<marijnfs> TheLemonMan: dunno, maybe it does something to the formatting string
<TheLemonMan> again, once the error is removed you'll get your beautiful slice formatted the way you wanted
<marijnfs> std.fmt.fmtSliceHexLower in the argument also seems weird, where is this reesulting string allocated?
<marijnfs> it has to be created before it goes to the function
<marijnfs> ok so it's temporary
<TheLemonMan> the {x} stuck out as a sore thumb since it only worked on u8 slices... and we're working to make those regular
<TheLemonMan> there's no string being allocated
<TheLemonMan> the argument is wrapped in a struct with a given format function
<TheLemonMan> check the implementation in the stdlib, it's quite nice
<marijnfs> ah I see, that's not bad
<TheLemonMan> check out #8166 and #8137 to see how well this pattern works for custom formatting styles
kenran has quit [Remote host closed the connection]
maier has joined #zig
riba has quit [Ping timeout: 256 seconds]
maier has quit [Ping timeout: 264 seconds]
maier has joined #zig
<Raito_Bezarius> am I wrong thinking that I can do b.addWriteFile to write a file as per the build process?
<g-w1> i think you must do something with the 'step' it returns
<Raito_Bezarius> I have some_step.step.dependsOn(&result.step);
<Raito_Bezarius> if I understand well, before some_step is executed, result.step must be done, so the file must be written before some_step but I'm seeing nothing in the build directory
<Raito_Bezarius> s/build/output
maier has quit [Ping timeout: 260 seconds]
olabaz has quit [Quit: WeeChat 2.3]
TheLemonMan has quit [Quit: "It's now safe to turn off your computer."]
bitmapper has quit [Quit: Connection closed for inactivity]
Techcable has quit [Quit: ZNC - https://znc.in]
Techcable has joined #zig
maier has joined #zig
maier has quit [Ping timeout: 260 seconds]
xackus__ has joined #zig
ur5us_ has joined #zig
xackus_ has quit [Ping timeout: 260 seconds]
eax has quit [Ping timeout: 268 seconds]
texno has joined #zig
v0idify has joined #zig
v0idify has quit [Remote host closed the connection]
v0idify has joined #zig
cole-h has joined #zig
ur5us_ has quit [Ping timeout: 240 seconds]
notzmv has quit [Ping timeout: 260 seconds]
Barabas has quit [Ping timeout: 240 seconds]
<Raito_Bezarius> is the syntax "use @import(x);" still valid in Zig 0.7.1 ?
maier has joined #zig
maier has quit [Client Quit]
r0bby has quit [Ping timeout: 240 seconds]
<ikskuh> was it ever? *thinking*
r0bby has joined #zig
<Gliptic> there's usingnamespace, but not valid at the top-level as far as I know
powerofzero has joined #zig
v0idify has quit [Remote host closed the connection]
v0idify has joined #zig
<Raito_Bezarius> ikskuh: I thought about something like this, https://github.com/ziglang/zig/issues/3
<Raito_Bezarius> that I have seen in some Zig source trees for previous versions afaik
<Gliptic> that's not really what you wrote though
<ikskuh> that issue … quite old :D
<Raito_Bezarius> true, Gliptic
<Raito_Bezarius> which I suspect has compiled to some point for some version
<ikskuh> that code is at least 2 years old
zupss has quit []
ifreund has quit [Ping timeout: 260 seconds]
<g-w1> use -> usingnamespace;
powerofzero has quit [Ping timeout: 264 seconds]
<g-w1> so the syntax is not valid, but was at one point. the reason it switched is to create more friction because its usually a bad idea to use usingnamespace
marijnfs has quit [Quit: WeeChat 2.8]
leon-p has quit [Quit: leaving]
<Raito_Bezarius> Alright
<Raito_Bezarius> Are tuple a thing in Zig? I see a reference to tuple in the https://ziglang.org/documentation/master/ but I don't see how are they used/defined
<g-w1> search for tuple on this page https://ziglearn.org/chapter-1/
<Raito_Bezarius> Awesome, thanks!