haliucinas has quit [Read error: Connection reset by peer]
haliucinas has joined #zig
g_w1 has joined #zig
<g_w1>
test
<g_w1>
is this working
ur5us has joined #zig
<klltkr>
g_w1: you're coming through loud and clear
<g_w1>
cool. my first time on irc
cr1901_modern has left #zig [#zig]
nephele_ has joined #zig
nephele has quit [Ping timeout: 272 seconds]
nephele_ is now known as nephele
zippoh has quit [Ping timeout: 258 seconds]
decentpenguin has quit [Quit: ZNC crashed or something]
marnix has joined #zig
marnix has quit [Ping timeout: 258 seconds]
klltkr has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
cole-h has joined #zig
smolck has joined #zig
<smolck>
is there a way to get the value of a nested anonymous struct, i.e. given .{false, .{5, 6, 7}} get the .{5, 6, 7} and iterate over it?
<smolck>
if I try and access it by @typeInfo(@TypeOf(...)).Struct.fields[1].default_value (in this case) it just returns null
<daurnimator>
smolck: anonymous structs are made to be coerced to something.
<daurnimator>
smolck: but also, anonymous structs are I think comptime fields?
<daurnimator>
not default values.
<smolck>
hmm
<smolck>
I guess I'm trying to use them like arrays that can take any type of value
<smolck>
which is not such a good idea?
<daurnimator>
they'll coerce to arrays....
<daurnimator>
but note that you'll have trouble using them at runtime
<daurnimator>
e.g. your `5` there is of type `comptime_int` -> you need to coerce it into a runtime type for it to exist at runtime
<smolck>
yeah I've noticed that, which can be a bit annoying
<smolck>
but interestingly, the way I have things set up currently, all I have to do is add `comptime` to the start of the nested struct and it works
<smolck>
one unrelated question I have though, is there a way to coerce something like "hello" to []const u8 w/out an @as cast or similar?
<daurnimator>
just assign it to a variable of type []const u8
<daurnimator>
const foo: []const u8 = "hello";
<smolck>
sorry, should have clarified, I mean within a struct, so have it be that type in this sort of situation: .{"hello"}
<smolck>
hmm
<daurnimator>
no. @as *is* the way to do that
<daurnimator>
anything else would be contrived....
<smolck>
yeah okay
<smolck>
that makes sense
<smolck>
cool, thank you for your help!
smolck has left #zig [#zig]
marnix has joined #zig
ur5us has quit [Ping timeout: 256 seconds]
xd1le has quit [Read error: Connection reset by peer]
xd1le has joined #zig
frett27_ has joined #zig
frett27_ has quit [Ping timeout: 240 seconds]
a_chou has joined #zig
waleee-cl has quit [Quit: Connection closed for inactivity]
ur5us has joined #zig
a_chou has quit [Quit: a_chou]
ur5us has quit [Ping timeout: 265 seconds]
marnix has quit [Ping timeout: 258 seconds]
marnix has joined #zig
omglasers2 has joined #zig
jjsullivan1 has joined #zig
cole-h has quit [Quit: Goodbye]
<jjsullivan1>
hi, I have a question about zig's compile-time evaluation. Would it be possible to modify an array of structs at compile time? I'm making a virtual keyboard, and I'd like to precalculate the approximate position of each key in a layout based on how wide the key is. I tried writing this down as far as I could here https://gist.github.com/jjsullivan5196/a8f923473f923e7f4d31a6d03c05b14a
<jjsullivan1>
I left ellipses for the declarations I couldn't figure out, of course idk if this method is idiomatic/correct in zig
st4ll1 has joined #zig
radgeRayden has quit [Read error: Connection reset by peer]
<daurnimator>
jjsullivan1: take in a `[]Key`, and then you'll probably need to declare that array as a `comptime var` and take address of it?
<jjsullivan1>
daurnimator: ahhh, I didn't realize there was a `comptime var`. I think I was digging in the wrong parts of the manual. I'll give that a try, thank you!
marnix has quit [Read error: Connection reset by peer]
<jjsullivan1>
yeah, there's some similar problems I'm trying to get around
<jjsullivan1>
first I got a simple surface example working in wayland, then I tried porting some of sxmo-svkbd over https://git.sr.ht/~mil/sxmo-svkbd
<jjsullivan1>
and while it is a 'simple' program, I think a few parts of it could be expressed more easily with explicit ctfe and other tricks
<daurnimator>
jjsullivan1: one application I can imagine is typing my password into a bootloader
<daurnimator>
for tablets and 2-in-1s I don't know of any UEFI password entry systems
<jjsullivan1>
the guys at postmarketOS have that covered, they made one that uses the linux framebuffer
<jjsullivan1>
it uses SDL_Renderer though, so it can only blit to the framebuffer or open as a desktop window
<daurnimator>
I'm talking about in a pre-boot environment
<daurnimator>
zig can target UEFI :)
<jjsullivan1>
oh yeah, I'll keep that in mind actually
<jjsullivan1>
The drawing library I use only needs pixman, and pixman can probably run in a stripped down environment
<jjsullivan1>
might not even need it to begin with, pretty sure it's only doing some fancy buffer fills I could do on my own. It does give me a nice frontend to freetype though:^(
<daurnimator>
jjsullivan1: freetype? why not harfbuzz directly?
<jjsullivan1>
the more you know :^)
<jjsullivan1>
I wasn't even using freetype directly, it's just what pixman was using
<jjsullivan1>
or this drawing library itself, guess that's more reason to drop it
<jjsullivan1>
wayland can just hand me memory mapped buffers to barf pixels on, probably easier to do simple fills + harfbuzz
<jjsullivan1>
the real dragon though is fontconfig
<jjsullivan1>
god help me
<daurnimator>
fontconfig? do you need to touch that?
<jjsullivan1>
to search installed fonts yeah, there's probably an alternative but I haven't looked into it
<jjsullivan1>
maybe I should just skip attribute-based searches for fonts, but most people expect to just give fontconfig pattern strings for most stuff
<jjsullivan1>
for a UEFI environment or something like that I'd definitely skip it and pack in a font file
ur5us has joined #zig
* Michcioperz
whispers "const font = @embedFile(…)"
_Vi has quit [Ping timeout: 246 seconds]
dec05eba has quit [Remote host closed the connection]
xd1le has quit [Read error: Connection reset by peer]
xd1le has joined #zig
ur5us has quit [Ping timeout: 260 seconds]
_Vi has joined #zig
_Vi has quit [Ping timeout: 246 seconds]
marnix has quit [Ping timeout: 246 seconds]
marnix has joined #zig
knebulae has quit [Read error: Connection reset by peer]
knebulae has joined #zig
Snetry has quit [Ping timeout: 264 seconds]
Snetry has joined #zig
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
_Vi has joined #zig
klltkr has joined #zig
martylake_ has joined #zig
klltkr has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
klltkr has joined #zig
marnix has quit [Ping timeout: 265 seconds]
marnix has joined #zig
waleee-cl has joined #zig
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
klltkr has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
brotein has quit [Remote host closed the connection]
brotein has joined #zig
dmiller has joined #zig
<dmiller>
Hello! Is there a function similar to `readUntilDelimiterOrEof` for reading from stdin, except it just reads until EOF rather than also accepting a delimiter? Thanks!
a_chou has joined #zig
whatupdave has joined #zig
dmiller is now known as dmiller2
dmiller has joined #zig
whatupdave has quit [Client Quit]
_Vi has joined #zig
dmiller2 has quit [Remote host closed the connection]
a_chou has quit [Quit: a_chou]
Akuli has joined #zig
<traviss__>
dmiller, have you tried read(buffer: []u8) or readAll(bufer: []u8) ?
cole-h has joined #zig
riba has joined #zig
klltkr has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<KoljaKube>
It is not possible to initialize single elements of an array that is a struct member with default values, right? :-/
riba has quit [Ping timeout: 265 seconds]
riba has joined #zig
riba has quit [Ping timeout: 265 seconds]
brotein has quit [Remote host closed the connection]
klltkr has joined #zig
<ifreund>
KoljaKube: sure it is: [1]u8{42} ++ [1]u8{undefined} ** 5;
<ifreund>
then you get an array of length 6 with the first value initialized to 42 and the rest undefined
<KoljaKube>
My member is `.content: [some_const][some_other_const]?[]u8 = std.mem.zeroes([come_const][some_other_const]?[]u8`
<KoljaKube>
I had hoped for something like `.content[0][0] = only_element_set`
<KoljaKube>
I would have preferred having the rest of the array filled by the default defined in the struct
_Vi has quit [Ping timeout: 260 seconds]
<KoljaKube>
But that would take two steps I guess
<KoljaKube>
I'm using an initializer block now, repeating the mem.zeroes in there. That way I at least don't need to calculate array sizes
dongcarl has quit [K-Lined]
marijnfs has joined #zig
radgeRayden has joined #zig
<marijnfs>
I see the allocator.zig now defines the class directly in the zig file? How does this work
<KoljaKube>
Every file is implicitely a struct as well, or am I misunderstanding the question?
<marijnfs>
no that was what i was wondering
frett27_ has joined #zig
<marijnfs>
it that new?
<KoljaKube>
No
<alexnask[m]>
Its been a while
<marijnfs>
it's a bit jarring the first time, but also interesting
<KoljaKube>
It saves you from having to usingnamespace or `const MyStruct = @import("my_struct").MyStruct;`
<marijnfs>
yeah I found that annoying as well. So thats cool
<marijnfs_>
I would suggest he just casts to u8 like a human being
<davi2205>
marijnfs, I implement the callback function using the target type like fn myCallback(self: *A) void
<alexnask[m]>
Why? This is the same generated code but clearer, `*u8` is a single item pointer to a u8, `*Erased` is a single item pointer to an item of unknown length
<marijnfs_>
I guess just don't call it Erased
<davi2205>
then I call the callback function using the CallbackEntry struct like entry.func.*(entry.target);
<marijnfs_>
that's very confusign
<alexnask[m]>
But anyway, suit yourself, just mentioning how Ive seen other zig codebases do this
<marijnfs_>
yeah it's probably the most proper way to do it
<marijnfs_>
but a *u8 also says it doesn't know the length right?
<marijnfs_>
it's not a []u8
<alexnask[m]>
And yes Erased is prob bad, Context or something is probably better
<alexnask[m]>
No, `*u8` is a single item pointer, I guess you could use `[*]u8` (which is a pointer to an unknow number of elements)
<marijnfs_>
ah yes
<davi2205>
I'll try the @Type(.Opaque) method
<marijnfs_>
where does .Opaque come from?
jjsullivan1 has quit [Remote host closed the connection]
<alexnask[m]>
.Opaque is an enum literal, @Type takes std.builtin.TypeInfo which is a union(enum) with `Opaque: void`
<alexnask[m]>
Because the payload is void, .Opaque will coerce to TypeInfo
<marijnfs_>
ah okay @Type takes the enum as argument, and .Opaque is an element therein
xackus has quit [Ping timeout: 265 seconds]
mokafolio has quit [Quit: Bye Bye!]
<Nypsie[m]>
Hell yeah, zlib/deflate in std!
mokafolio has joined #zig
omglasers2 has quit [Read error: Connection reset by peer]