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/
<plumm> same with function arguments; if there is an argument mismatch can't the compiler show me the signature so I don't have to jump to the source to know which place things go?
dimenus has joined #zig
<stratact> daurnimator: I'm working on it, thank you for the lua source too. Earlier I just didn't have the confidence and I felt inspired by andrewrk when he made it contributor friendly to learn it more. I also got that book for reference/learning
<daurnimator> stratact: `man tzfile` is all you need :)
<stratact> I see what you did there. Thank you :)
<protty> andrewrk: do you remember how you recorded time spent in functions using `perf`?
<daurnimator> protty: `perf record`?
<protty> am getting perf.data and trying to open it with perf report but it doesnt seem to display anything noteworthy
<daurnimator> protty: -g ?
<daurnimator> protty: may also want -F 99
protty has quit [Ping timeout: 260 seconds]
reductum has quit [Quit: WeeChat 2.6]
qbradley has quit [Remote host closed the connection]
waleee-cl has quit [Quit: Connection closed for inactivity]
<Flaminator> Is there any specific reason why the `address of` operator is a prefix operator instead of a postfix operator like .* is?
<daurnimator> Flaminator: I've actually been asking that question myself lately. I think its because a postfix *operates* on the result; but address of isn't really that.
<daurnimator> Flaminator: e.g. &foo.bar -> it's not getting bar and taking the address of it; it's changing the "." operator for the current expression
<Flaminator> Isn't &foo.bar actually foo.bar.&?
<Flaminator> So you get the address of bar and not foo.
<daurnimator> Flaminator: but foo.bar might load bar into a register. or make a copy on the stack
<Flaminator> But wouldn't the end result be the same? a.b has a higher precedence than & has.
<daurnimator> Flaminator: no. imagine if `foo.bar` made a copy of bar on the stack
<daurnimator> --> then `foo.bar.&` would be a stack address.
<daurnimator> rather than the location of `bar` inside of `foo`
<daurnimator> likewise `&foo.bar.qux` -> the & operator essentially changes the semantics of `.` for the expression.
<shachaf> lvalues are the weird thing here, not &
<shachaf> Assignment also "changes the semantics" because x.y = 5 doesn't read the value of x.y.
<shachaf> The difference, I guess, is that in a.*, a is used an rvalue (i.e. just a value). In &a, a is used as an lvalue (which is really more like a memory location).
lunamn has quit [Ping timeout: 268 seconds]
lunamn has joined #zig
lunamn has quit [Quit: leaving]
mforney has quit [Quit: quit]
mforney has joined #zig
<fengb> seems like alignment is broken for a default 0 size array
<fengb> Setting it explicitly in the struct body works
<fengb> It looks like it's due to the recent removal of automatic slice coercion. I'll create an issue
<daurnimator> fengb: I mean.... your array there is *not* aligned.
<fengb> 0 size implies aligned to nothing, yet aligned to everything 🤔
<daurnimator> but I did manage to find another bug while playing: https://godbolt.org/z/QnS-2d
<fengb> Yeah trying to explicitly align a 0 value crashes the compiler
<fengb> Probably a divide by 0 error
muffindrake has quit [Ping timeout: 250 seconds]
muffindrake has joined #zig
<fengb> Wow, the wasm "mmap" is super slow
kapil_ has joined #zig
ur5us__ has quit [Ping timeout: 250 seconds]
abbiya has joined #zig
<fengb> Oof, I'm glad I ran this memory fuzzer
abbiya has left #zig [#zig]
adamkowalski has joined #zig
<adamkowalski> Can I make the output type of a function be a function of one of the inputs? Assuming that variable is a var
<adamkowalski> something like fn f(x: var) g(@typeOf(x))
<daurnimator> yes.
<adamkowalski> Care to elaborate haha
<adamkowalski> Huh it's literarly the syntax I posted? I wonder why it wasn't working for me. I'll try again
<adamkowalski> Also if I have a struct with a compile time parameter how do I get get access to it from outside of that struct?
<plumm> Foo.bar
<plumm> compile time parameter being... sorry if i misunderstood
<adamkowalski> fn Foo(comptime T: type) type {
<adamkowalski> return struct {
<adamkowalski> bar: type = T,
<plumm> ok, wdym outside?
<adamkowalski> }
<adamkowalski> }
<plumm> @typeOf(Foo(usize).bar) ?
<adamkowalski> bar is a type
<adamkowalski> it's not a value
<plumm> ok, so then just access bar directly
<plumm> you can also use the above if bar's type is computed based on T
<adamkowalski> Okay I'll post some code on pastebin, because I tried that and it doens't work
<adamkowalski> Actually I want to do the oposite. I have a graph and it will contain elements of type T. I want to write a free function which takes a graph and a value as long as value can be converted to the element type of the graph
<plumm> var?
<adamkowalski> Okay so inside of the graph struct I have something called elementType: type = T
<traviss> adamkowalski i posted this yesterday in response to your question/patste? https://pastebin.com/pD0kmS32
<adamkowalski> without that line it compiles
<adamkowalski> traviss: sorry I didn't reply to that earlier. But I am not a fan of that solution. I think it's interesting, however constant is still now a privleged function
<adamkowalski> People who want to add new functions that modify the graph will not be able to leverage that as the struct is in a library presumably
<traviss> ok just making sure you saw it
<adamkowalski> I am not a fan of member functions in general since you cannot crack open the struct and add new ones
<daurnimator> adamkowalski: you probably want: `const elementType = T;`
<adamkowalski> So I want what you posted but only using free functions haha
<adamkowalski> daurnimator: awesome, thanks!!
<daurnimator> adamkowalski: fields of type `type` need to be comptime known; which means they have to be const; or inside a comptime-only struct.
<adamkowalski> I was trying the comptime keyword instead of const haha
<adamkowalski> Man everything in Zig ends up being so clean and simple. Sometimes I feel like I overcomplicate things and the right solution ends up being the obvious thing to try haha
<adamkowalski> I got it to compile. Is this how you all would approach writing that function? There is some repition with the type deduction: https://pastebin.com/b2QgdBnE
adamkowalski has quit [Ping timeout: 250 seconds]
<daurnimator> plumm: looks.... coarse
<plumm> i use it for lumbar support
mahmudov has quit [Ping timeout: 240 seconds]
adamkowalski has joined #zig
ltriant has quit [Quit: leaving]
adamkowalski has quit [Ping timeout: 240 seconds]
shodan45 has joined #zig
marmotini_ has joined #zig
marmotini_ has quit [Ping timeout: 240 seconds]
plumm has quit [Quit: Lost terminal]
redj has quit [Read error: Connection reset by peer]
marmotini_ has joined #zig
<muffindrake> I was told by andrew that something were something interesting hitting zig on Dec 1st. What was it?
marmotini_ has quit [Remote host closed the connection]
marmotini_ has joined #zig
marmotini_ has quit [Remote host closed the connection]
FireFox317 has joined #zig
ur5us__ has joined #zig
<FireFox317> https://twitter.com/Foone/status/1201956309941116928 > for the people who enjoy some reading about programming back in the days
terinjokes has quit [*.net *.split]
wtw has quit [*.net *.split]
diginet has quit [*.net *.split]
Nazral has quit [*.net *.split]
nore has quit [*.net *.split]
niftynei has quit [*.net *.split]
Nazral has joined #zig
diginet has joined #zig
terinjokes has joined #zig
wtw has joined #zig
niftynei has joined #zig
nore has joined #zig
<mq32> FireFox317: Foone is a general recommendation for computer nerds :D
<FireFox317> Yeah I'm figuring that out xd, quite new to computer nerds twitter world :P
<mq32> hehe
<mq32> btw, it's a quite fun experience to actually program a computer by punching in bits by hand
<FireFox317> You did that too? Working on microcontrollers is a bit like that, changing bits by bits
<mq32> i programmed that machine a bit (literally the thing on the photo)
<mq32> it's a quite cool architecture to code, but the machine we (i'm a bit with the computer museum) have has some glitch that will make the core memory lose its contents :(
<mq32> also, if you ever come to stuttgart: visit the computer museum!
<FireFox317> Owh, that's a nasty glitch indeed XD But the computer looks so cool tho!
<mq32> yeah that's why i wanted to hack some stuff with it :D
<mq32> but i failed at a "better" bootloader
<FireFox317> Yes! I'm only 6 hours from stuttgart, so will probably be there some time :)
<mq32> :D
<mq32> that's the assembler i wrote
<mq32> there's a opcodes.txt where you can look up the instruction set
<FireFox317> I see, only 82 lines compared to the 2,034 of x86-64 :)
<FireFox317> I'm wondering how many of these instructions are actually used xd
<mq32> hehe
<mq32> i really like how they made the instruction encoding :D
<mq32> you have variable-sized operands depending on the most significant nibble of the instruction
ur5us__ has quit [Ping timeout: 250 seconds]
traviss has quit [Ping timeout: 268 seconds]
adamkowalski has joined #zig