lanodan has quit [Read error: Connection reset by peer]
lanodan has joined #zig
bjornroberg has joined #zig
dingenskirchen has quit [Quit: dingenskirchen]
dingenskirchen has joined #zig
bheads has joined #zig
riba has joined #zig
Aransentin has joined #zig
<Aransentin>
Is it just me or is latest Zig release broken wrt. `io_mode = .evented;`? `zig run test.zig` on this simple file fails with "Instruction does not dominate all uses!": https://pastebin.com/raw/SXQkDEMw
Akuli has joined #zig
riba has quit [Ping timeout: 272 seconds]
alexnask has joined #zig
wozeparrot__ has joined #zig
<andrewrk>
ah, I've been meaning to set up CI test coverage for evented I/O
decentpenguin has joined #zig
<blueberrypie>
is the zig meetup is happening in an hour right?
<wilsonk>
andrewrk: update for you and any others that were asking the other day. I have added a new store for merchandise with the new logo designs (as well as new zero, ziggy and a few zigfast items <<-- ifreund). Check the new link at the https://github.com/ziglang/zig/wiki/community#merchandise
<fengb>
Awesome 🥳
<andrewrk>
thank you wilsonk! it's been really nice having you manage the store so that I can focus on other things <3
<alexnask>
wilsonk, tyty
<wilsonk>
no problems
dingenskirchen has quit [Quit: dingenskirchen]
dingenskirchen has joined #zig
<ifreund>
wilsonk: this is awesome, thank you!
<wilsonk>
my daughter (who actually did all the changes to earn a few bucks from me since she lost her job in this climate) thinks that zigfast is her spirit animal :) I will probably order a sample of one zigfast item for her to see how it looks.
antaoiseach has joined #zig
<andrewrk>
haha I love that zigfast made it in there
<marler8997>
I'd like to be able to use std.fs.path.join to create a pathname that needs to be available at comptime
<marler8997>
I wrote my own that puts "comptime" as a parameter modifier on the "paths" array, but that means it can't be used at runtime
<marler8997>
And the one in std.fs.path requires an allocator
<marler8997>
I wonder if we could make join work at compile-time by having some sort of comptime allocator?
<marler8997>
@ctAllocator() or something
<marler8997>
or better yet, just create the allocator primitives such as @comptimeRealloc(..) and @comptimeShrink(...), then we can create an Allocator type that calls them, so then the details of mem.Allocator don't get into the language
<andrewrk>
kristoff_it, Q for fengb: What's the #1 issue in Zig that you would like to see addressed which would help FUN+DUDE?
<dimenus>
how would i iterate over std.builtin.StructFields at runtime?
<andrewrk>
dimenus, you would create an array at comptime, then iterate over that array at runtime
<alexnask>
StructField is a comptime only type though I believe
<dimenus>
yeah that's my challenge here, basically i'm trying to debug offset issues
<dimenus>
the goal is to just print out all of the struct fields and their offsets
<alexnask>
If you only want to print stuff you should be able to `inline for` over the fields and do your `std.debug.warn`s in there
lanodan has quit [Ping timeout: 272 seconds]
<dimenus>
alexnask: inline for works, thanks for the tip
<dimenus>
also i'm not sure i know how to create an array at comptime yet
lanodan has joined #zig
craigo has joined #zig
<alexnask>
dimenus, `const array = [_]T { T{...}, T{...}, T{...} };` this is comptime if all the things inside are comptime
<dimenus>
alexnask: i should clarify, i'm not quite sure what Andrew is referring to. How would i create a comptime array of something the compiler hasn't figured out yet?
metaterically has joined #zig
waleee-cl has joined #zig
<greenfork>
how do I convert `*[8000]u8` to `*[]const u8`? I've read that it's possible to convert `var` type to `const` and tried `@as` with no success
<BaroqueLarouche>
greenfork: does `my_array[0..]` does the trick ?
<greenfork>
BaroqueLarouche: no, it still complains
<andrewrk>
greenfork, are you sure you want `*[]const u8`? that's a double pointer
<dimenus>
andrewrk: thanks
<andrewrk>
you can already coerce *[8000]u8 to []const u8, without any casting builtins
<greenfork>
expected type '*std.io.fixed_buffer_stream.FixedBufferStream([]const u8)', found 'std.io.fixed_buffer_stream.FixedBufferStream([]u8)'
<greenfork>
when I try to construct this fixed buffer with an array type it complains that the type is not correct
<greenfork>
this error comes from a function where I require this buffer to be of u8 type
<greenfork>
I should probably make a code snippet
<alexnask>
That would be helpful :)
Invader_Bork has quit [Ping timeout: 272 seconds]
<fengb>
greenfork: it's because you're trying to pass a const slice into a mutable one
<greenfork>
fengb: I've also tried the other way around, I will make a correct snippet :)
Aransentin has quit [Remote host closed the connection]
Aransentin has joined #zig
lanodan has quit [Read error: Connection reset by peer]
<dimenus>
comptime is so awesome, i'm glad stuff like this works: https://bpa.st/Y3JQ
<dimenus>
a generic function for pulling objects off the wire and byte swapping specific fields
lanodan has joined #zig
_whitelogger has joined #zig
decentpenguin has joined #zig
fraktor has joined #zig
reductum has joined #zig
<karrick>
@kristoff_it Awesome show!
<fengb>
+1
<greenfork>
yeah, thanks!
<karrick>
Yeah, and the speakers, thank you so much for putting yourselves in the spotlight!
<karrick>
You guys inspire me to start doing something Zig
<pixelherodev>
I haven't seen it yes, but I'm sure you all did a great job!
<pixelherodev>
yet*
<karrick>
I want to get river running on my box now.
<ikskuh>
ifreund: nice talk!
dottedmag has quit [Quit: QUIT]
<ifreund>
ikskuh: thanks!
<ifreund>
karrick: if you run into any issues let me know :)
satchmo has joined #zig
dottedmag has joined #zig
<kristoff_it>
karrick: thanks!
drewr has joined #zig
wootehfoot has quit [Ping timeout: 246 seconds]
decentpenguin has quit [Quit: decentpenguin]
satchmo has quit [Ping timeout: 260 seconds]
greenfork has quit [Ping timeout: 264 seconds]
metaterically has quit [Remote host closed the connection]
<Aransentin>
Here's an optimization for ArenaAllocator that somebody more skilled than me might want to implement:
<Aransentin>
As it is, when running ArenaAllocator over page_allocator it initially very wastefully creates memory areas smaller than the page size; i.e. the OS returns a full 4KiB page but it only uses the first few bytes, and when those are used up it requestsan entirely new page.
<Aransentin>
Maybe if ArenaAllocator can "know" that it's running over page_allocator you can add a special case for it
jfo has quit [Ping timeout: 240 seconds]
<fengb>
There’s an issue to allow for in place resizing
<fengb>
So once that’s done, the first expand will just resize into the page
mokafolio has joined #zig
<Aransentin>
Ah, that'd solve it, yes
mokafolio has quit [Remote host closed the connection]
mokafolio has joined #zig
tdc has quit [Ping timeout: 246 seconds]
<pixelherodev>
You could also do e.g. arena over FBA over page allocator
<pixelherodev>
Or a custom FBA-like that grows when it runs out of space
Akuli has quit [Quit: Leaving]
slowtyper has quit [Ping timeout: 246 seconds]
Invader__Bork has quit [Ping timeout: 264 seconds]
data-man has joined #zig
<data-man>
Hello everyone! Is there any Sublime Text users?
<ikskuh>
does anyone else also see the need for a library that wraps all primitive types with operators into a struct that provides functions like add, sub, wrappingAdd, mulWithOverflow, ...?
cole-h has quit [Quit: Goodbye]
cole-h has joined #zig
<gonz_>
Heh
<ikskuh>
it would be a good base for arithmetic-type-agnostic libraries
<gonz_>
Someone flamebaited r/haskell with a video where andrewrk said you can't write perfect software in lots of languages, Haskell included.
<pixelherodev>
Nah
<pixelherodev>
I mean, I don't see the need for such a library
<pixelherodev>
That just seems like unnecessary abstraction to me
<ikskuh>
pixelherodev:
<ikskuh>
then tell me how i should write a type-agnostic library eg for linear algebra
<ikskuh>
i have actual use case for that and i don't want to write the library twice
<ikskuh>
once for custom types, once for builtin types
<alexnask>
gonz_, lol that sounds hilarious, link? :D
<gonz_>
ikskuh: If I need this my go-to way is to have a function that generates an interface from a specification given to it, matching the types I want to use.
<gonz_>
You can generate it at comptime and it'll be normal calls
<ikskuh>
so the only way i can see that working without operator overloading is inversing the process
<alexnask>
nvm Ill go get it myself and stop being lazy >.>
<pixelherodev>
ikskuh: what's the use case for built-in types?
<pixelherodev>
s/built-in/custom
<pixelherodev>
Sorry
<pixelherodev>
brainfart
<ikskuh>
fixed-point arith or similar
<ikskuh>
i use them a lot on embedded HW instead of fp32
<pixelherodev>
Maybe try to get fixed point into the language, instead?
<ikskuh>
this is a type i may want to use in my next embedded demo
jamii has joined #zig
<ikskuh>
gonz_: yeah, that still doesn't change the fact that one has to write such a wrapper for primitive types
<jamii>
Does anyone know how to pass '-fsanitize=fuzzer' to clang?
<gonz_>
You can provide the interfaces for the types you can think of, people have the opportunity to rewrite them and provide the ones you don't
data-man has quit [Quit: Konversation terminated!]
<jamii>
I tried `-mllvm -fsanitize=fuzzer` but it gives me `Unknown command line argument '-fsanitize=fuzzer'. Try: 'zig (LLVM option parsing) --help'`
<ikskuh>
problem with the function pointer struct is probably that you cannot force-inline the functions?
<gonz_>
I dunno, it doesn't seem reasonable to me to expect code generic over everything without the work being done somewhere, and the caller will always know more than you do about what's good anyway.
<pixelherodev>
Inttteresting
<gonz_>
So the caller is the person most qualified to supply the actual difference.
<gonz_>
`comptime` ensures that it's a call like any other, at the very least.
<ikskuh>
gonz_: i'm only taking about arithmetic types atm
<alexnask>
Its passed as comptime everywhere so it should be inlinable
<gonz_>
As in a fastcall
<gonz_>
I checked the assembly for this program to ensure it
<gonz_>
What you get is the same code you would as if it was written with whatever your type T was from the beginning
<alexnask>
You can even use .always_inline with comptime fn type values
<ikskuh>
ah right
<gonz_>
There were issues with error sets, though.
<ikskuh>
no problem in my case
<gonz_>
it couldn't infer them, etc., so I ended up having to nail them down
<gonz_>
If you had a bigger set of operations AFAIK you could extend this to return an interface as well
<gonz_>
Though I'm not sure how much I'd use that.
<ikskuh>
i can send you the list of the operations, if you want :D
<ikskuh>
rest is in scope of the thing i'm thinking about
<gonz_>
I guess the time is ripe for experimentation. Whatever you try out and how it looks, highlight me when you've checked it out.
<gonz_>
I will always be a bit curious how people end up approaching generic code in Zig because the user base is likely very diverse in terms of languages used before.
<gonz_>
I ended up doing this because it's basically first class modules from OCaml, or exactly what the Haskell compiler does when it passes type class dictionaries into generic functions with constraints/type classes.
<gonz_>
`add :: Num a => a -> a -> a` will in reality be a function that takes a `Num` dictionary of numeric functions as a first argument, then the rest.
aerona has joined #zig
<gonz_>
This all gets magically and massively inlined
<hspak>
Is there a way to force a `defer` to trigger at the end of the function instead of at the end of the block if it was called inside a while loop for instance?
<ikskuh>
no
stripedpajamas has joined #zig
neceve has quit [Ping timeout: 240 seconds]
jamii has quit [Remote host closed the connection]
r4pr0n has quit [Ping timeout: 240 seconds]
alexnask has quit [Quit: Leaving]
st4ll1 has joined #zig
dimenus has quit [Quit: WeeChat 2.8]
_Vi has quit [Ping timeout: 246 seconds]
alexnask has joined #zig
stripedpajamas has quit [Quit: sleeping...]
frmdstryr has quit [Ping timeout: 272 seconds]
DpEpsilon_t has joined #zig
<gonz_>
ikskuh: How does the call-site and function look?
<gonz_>
s/function/function using this
klltkr has joined #zig
mokafolio has quit [Remote host closed the connection]