<mikdusan>
andrewrk: does `*align(:3:1) SomeType` mean host integer size is 1 byte, and pointer-child is 3 bits offset into host integer? and what does the missing align num mean?
rageoholic has quit [Ping timeout: 260 seconds]
rageoholic has joined #zig
rageoholic has left #zig [#zig]
lunamn has quit [Ping timeout: 272 seconds]
lunamn has joined #zig
_whitelogger has joined #zig
return0e has quit [Remote host closed the connection]
adamkowalski has quit [Remote host closed the connection]
<fengb>
Thoughts on dropping in "Be excellent to each other"?
<fengb>
Or would that be bad since it's not a real COC
_whitelogger has joined #zig
mahmudov has joined #zig
qazo has joined #zig
<andrewrk>
let's plz not derail the channel by linking to V's CoC
<andrewrk>
mikdusan, yes. the alignment value that is missing should be the alignment of the host integer. I think the meaning of when it is missing might be incorrect in stage1 right now
<andrewrk>
which might have to do with the incorrect @sizeOf() packed struct which has 3 bytes in it
<andrewrk>
here is what it should mean if it is missing: if it is missing then the alignment of the address, which is the address of the host integer, is @alignOf(@IntType(false, 1 * 8)), where 1 is the host integer byte count (the 1 in *align(:3:1))
dddddd has quit [Ping timeout: 268 seconds]
<mikdusan>
thanks this helps
mokafolio has quit [Quit: Bye Bye!]
mokafolio has joined #zig
BaroqueLarouche has quit [Quit: Connection closed for inactivity]
<mikdusan>
andrewrk: the first packed-struct at top; am I remotely close with the values?
alexpana has quit [Read error: Connection reset by peer]
qazo has quit [Ping timeout: 240 seconds]
qazo has joined #zig
<betawaffle>
what's the difference between using `var` as an argument type vs. using something like `comptime_int`, besides the fact that the latter can only be an integer?
<betawaffle>
and also what's the difference between a comptime_int, and a comptime-known regular int type, like u32? (as an argument type)
<Snektron>
comptime int can be any size
<Snektron>
A var can be any value
<Snektron>
The value can be known at runtime
<Snektron>
But the type of the expression has to be known at compile time
<betawaffle>
but a `comptime arg: u32` for example has to have a known value at compile time?
<Snektron>
Exactly
<Snektron>
I do think comptime int stands a bit out
<frmdstryr>
Can struct fields be made const so the value can't be changed after it's intialized?
<mq32>
frmdstryr, nope, that is not possible
<frmdstryr>
Ok thanks
mahmudov has quit [Ping timeout: 268 seconds]
knebulae has quit [Read error: Connection reset by peer]
dddddd has joined #zig
mahmudov has joined #zig
mahmudov has quit [Ping timeout: 240 seconds]
knebulae has joined #zig
<Snektron>
Can i import an extern fucntion inside a struct?
epmills has quit [Remote host closed the connection]
BaroqueLarouche has quit [Quit: Connection closed for inactivity]
WendigoJaeger has joined #zig
WendigoJaeger has left #zig [#zig]
<mikdusan>
silly question: why is fn return type specified after parens, and not as (optional) final component inside parens? `fn(a:u32, b:u32, u32){return a+b;}`. if this ambiguous?
<andrewrk>
for function prototypes (params have no names) it would be ambiguous
<andrewrk>
const fnType = fn(u32, u32, u32);
<andrewrk>
sorry, it wouldn't be ambigious since the last one would always be the return type. but it does look confusing
<mikdusan>
`const fnType = fn(u32, u32; u32)` <-- ok this is cheating
<mikdusan>
`const fnType = fn(;u32)` looks a bit odd but hey...
<andrewrk>
what are you trying to solve?
<mikdusan>
some interesting proposals. was looking at #4170 and the gist of `.|a,b|` to me seems that it always makes return type inferred and that's why it looks clean. so wondering how we could simply compact all fn stuff
<fengb>
What if we had result location based function signatures?
<fengb>
Then the types are inferred but not ambiguous
<pixelherodev>
jessermeyer, you shouldn't be taking the slice address like that
<pixelherodev>
You want `error_message.ptr` to get a `[*]u8`
epmills has quit [Ping timeout: 268 seconds]
<jessermeyer>
Huh, should the compiler be yelling at me, cause it's not.
<jessermeyer>
But isn't error_message an array?
<pixelherodev>
I mean... unless I'm misremembering something
<pixelherodev>
Let me just reread them docs real quicl
<pixelherodev>
s/quicl/quick
<jessermeyer>
I know 'string' handling has changed quite a bit since I last dabbled in Zig, so this stumbling block doesn't surprise me.
jessermeyer has left #zig [#zig]
<pixelherodev>
`[512:0]u8`, unless I'm more tired than I thought, is a slice of 512 u8s, zero-terminated
jessermeyer has joined #zig
<pixelherodev>
No wait, you're right; it's an array
kynan has joined #zig
<pixelherodev>
jessermeyer, you want `&error_message[0]` IIRC
<pixelherodev>
The address of the first member
<jessermeyer>
So what does &error_message mean?
<pixelherodev>
The address of the array itself
<pixelherodev>
That is, a `*[512:0]u8`
<pixelherodev>
Whereas you want a `[*]u8`
<pixelherodev>
(pointer to array of 512 u8s, terminated by zeroes; versus a pointer to an unknown number of u8s)
<pixelherodev>
The latter is what C uses
<jessermeyer>
I agree that those are technically different at a type level, but isn't the address number of each identical?
<jessermeyer>
For whatever reason, zig is cool with taking the address of the array as input.
<pixelherodev>
Potentially, but having the type be correct is also a good idea
<pixelherodev>
Regardless of whether the generated binary ends up producing the correct result
<pixelherodev>
Having all info be correct on the Zig level allows for more correct info to be exposed to, say, the optimizer
<jessermeyer>
Yeah I do agree with you there
<pixelherodev>
Not necessarily a major concern, but I can imagine the optimizer making an incorrect decision if it thinks the type is something its not
<jessermeyer>
Can you think of an instance where the starting byte address would be different?
<jessermeyer>
Could alignment cause that to get funky?
<pixelherodev>
In C, arrays are just their members - that is, the address of the array == the address of member one
<pixelherodev>
I'm not 100% sure if that's true in Zig, give me two seconds
dddddd_ has joined #zig
<pixelherodev>
Seems to be, at a quick glance
<jessermeyer>
The docs don't mention otherwise, at least.
dddddd has quit [Ping timeout: 272 seconds]
<jessermeyer>
But thanks for the helpful advice and assistance =)
<Snektron>
Im pretty sure that in practise its the same address, though it doesn't mean the same to the compiler
dddddd_ is now known as dddddd
jessermeyer has quit [Remote host closed the connection]
<pixelherodev>
`In theory, theory and practice are the same` <- pretty sure someone used that one yesterday :P
<traviss>
jessermeyer <pass a 0 to a * c_void parameter as part of a C API> maybe you can use an allowzero type? something like `@intToPtr([*c]allowzero c_void, 0)`
<pixelherodev>
Source: working on a project that passes null to C code right now :)
<traviss>
oh thanks. will use that next time i run into this.
<traviss>
much simpler
<pmwhite>
What are people's thoughts on language integrated units of measure?
<pixelherodev>
Overkill
<pixelherodev>
In the standard library, maybe
<pixelherodev>
But that doesn't belong in the language itself
<pixelherodev>
My two cents
<pmwhite>
All the attempts at userland versions in other languages seem to either not have real algebraicness, or aren't ergonomic to use, or aren't "zero-cost"
<metaleap>
might be able to whip sth up with comptime as long as "real algebraicness" require "operator-like sigils as func names"
<pmwhite>
Which is merely a guess that a library version might not be possible, not a proof that it ought to be included in the language.
<metaleap>
s/require/doesnt-require
metaleap has quit [Quit: Leaving]
<pmwhite>
In zig at least, you would probably have to forsake using normal math operators.
kynan has left #zig [#zig]
mahmudov has quit [Remote host closed the connection]