<ifreund>
hmm, i32x4 or 4i32 might be less cumbersome to type than [|4|]i32
<ryuukk__>
that is the first time i see || inside []
<ryuukk__>
what it does?
ur5us has quit [Ping timeout: 260 seconds]
nvmd has joined #zig
ur5us has joined #zig
x2C25 has quit [Ping timeout: 260 seconds]
AceNovo has joined #zig
AceNovo has quit [Client Quit]
AceNovo has joined #zig
x2C25 has joined #zig
a92 has quit [Quit: Leaving]
zippoh has joined #zig
user0 has quit [Quit: Leaving]
CodeSpelunker has joined #zig
<frmdstryr>
Can I create a []u8 with an initial value without using mem.dup?
<frmdstryr>
var str: []u8 = "thisdoesnotwork";
<frmdstryr>
? I thought there was some way to do it but I forget..
AceNovo has quit [Remote host closed the connection]
<ryuukk__>
you can, var str: [] const u8 = "thiswork"
<ryuukk__>
if i remember correctly frmdstryr
<frmdstryr>
but then it's const
<kandinski>
frmdstryr: you want to create a mutable slice and the backing array of u8 in one go?
<kandinski>
(I didn't want to sound incredulous or critical, just to make sure I understand your intent)
<frmdstryr>
yes
<kandinski>
interesting puzzle
<kandinski>
I don't have an answer, but now it will be on my mind as I work on my project
<torque>
you can specify it as an array of bytes, I believe
<kandinski>
frmdstyr trying something...
<frmdstryr>
The only thing I can get to work is to define an undefined array then use std.fmt.bufPrint to print the initial value into it but it seems awfully convoluted
<kandinski>
frett27_: this didn't work: var str: []u8 = ("lalalala")[0..];
<kandinski>
I think the question was about a quick shorthand
<kandinski>
not about how to get a mutable slice of characters by any mean
<torque>
it's not possible to make it from a string literal without duping because literals are stored in rodata
kristoff_it2 has joined #zig
<kandinski>
excuse my ignorance, what is rodata?
<kandinski>
I mean, "ro" probably means "read only", but and I understand "data", but isn't this the same as saying "it's const"?
<frmdstryr>
torque: Ah, ok make sense
xackus has joined #zig
xackus_ has quit [Ping timeout: 240 seconds]
<ryuukk__>
TIL: there is a native debugger for vscode and it works great with ZIG, breakpoints, watches, even you can mouse over symbols and see their value
<ryuukk__>
i love it
CodeSpelunker has quit [Quit: CodeSpelunker]
<torque>
kandinski, yeah, it has to do with storage location of the data in the output binary (see https://en.wikipedia.org/wiki/Object_file#Segmentation for some more info). I don't think there's actually any requirement for string literals to be stored read-only but I believe that is what's done currently
<kandinski>
torque: thanks!
<kandinski>
is there a way to clobber a mutable array of u8 with a slice that's better than this? mem.copy(u8, self.errorbuffer[0..len], message[0..len]);
<kandinski>
(len already contains the message.len)
Kingsquee has joined #zig
ur5us has quit [Ping timeout: 260 seconds]
<kandinski>
I'm having trouble overwriting struct fields
<kandinski>
I konw structs are passed const into functions, and this includes a struct's own functions sugared to pass the struct as first parameter with "self"
<kandinski>
should I only have struct fields for immutable values? I feel the language is pushing me in that direction.
<torque>
do you have an example of what you're describing?
marnix has joined #zig
marnix has quit [Read error: Connection reset by peer]
<kandinski>
yes, let me extract
marnix has joined #zig
Axiomatic has joined #zig
traviss has quit [Remote host closed the connection]
<Axiomatic>
I'm new so i don't know
<kandinski>
torque: this is a reduced model of my PCRE2 wrapper. the saveError function is actual code, and it manifests my intent but doesn't work because self.errorlength = len can't assign to constant. There may be other issues, but I wonder if this is not the design: https://termbin.com/ut57
<kandinski>
And this is the kind of thing I'm doing to have the C library write directly into the struct's field buffer: https://termbin.com/ges6 Note that I can write into Pattern.errorlength directly, because this is during initialisation, so the Pattern has been created in the current scope, not passed in as a parameter, so it's not const yet.
<kandinski>
I've been writing C/Zig for less than a week, so I wonder if there's some kind of design insight that I'm missing.
<kandinski>
(the code from ges6 would go in Pattern.init())
frett27_ has quit [Ping timeout: 264 seconds]
frett27_ has joined #zig
<torque>
I believe you need to specify the self type as a pointer (i.e. *Pattern) for it to be mutable
<torque>
so something like `fn saveError(self: *Pattern, error_code) void`
<torque>
(I believe c_wrapper_that_returns_an_error_code would also need to be updated because it calls saveError)
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
gazler has joined #zig
gazler_ has joined #zig
gazler has quit [Ping timeout: 256 seconds]
ask6155 has joined #zig
siulManfroni has quit [Quit: Leaving]
xackus has quit [Ping timeout: 256 seconds]
omglasers2 has joined #zig
cole-h has quit [Ping timeout: 256 seconds]
<kandinski>
torque: I see, thanks!
<kandinski>
dammit: ./re.zig:49:5: error: opaque types have unknown size and therefore cannot be directly embedded in structs
<kandinski>
this is a type that comes from C and is in the C heap
<kandinski>
I can however store a pointer to it, right?
<kandinski>
silly question, let's try it
commander has joined #zig
DarkPlutonium has quit [Quit: ZNC 1.8.1 - https://znc.in]
<kandinski>
I'm trying to cast the array into a slice
<kandinski>
and it does something, apparently not something stable under assertion of identity
<kandinski>
I'm running 0.6 from nixpkgs
<kandinski>
oh, ifreund, I see what you mean
<kandinski>
this is equivalent to [0..0], which is what?
semarie has quit [Ping timeout: 260 seconds]
x2C25 has quit [Remote host closed the connection]
<ifreund>
no that's actually vaild, constness doesn't matter with zero bit types
x2C25 has joined #zig
<kandinski>
yeah, but there's no clear literal for a zero length slice of anything
<kandinski>
which, since it doesn't need a backing buffer, should be available in its own literal, IMHO
<kandinski>
s/should/could/, why demand like I'm the customer here (apologies)
semarie has joined #zig
<ifreund>
kandinski: oh this is actually fine, you just cant use mem.eql like that
<kandinski>
boing of course
<kandinski>
you're 100 right, of course
<kandinski>
how do I figure out if two results are the same, though? how can I see that the bytes from a slice are the same as the bytes from another slice?
<ifreund>
for (zero_matches) |str| assert(mem.eql(u8, str, str));
<kandinski>
oh
<kandinski>
dang ofc
<ifreund>
mem.eql wants the element type not the slice type
<kandinski>
yeah
<kandinski>
I have to iterate through two slices at the same time, though
<kandinski>
expected and returned
<kandinski>
but I'll figure that out
<kandinski>
I mean izip, etc.
<kandinski>
thanks mate
<ifreund>
no problem
<kandinski>
as to the construction of the zero element slice of strings, with a zero length backing buffer, would that be as idiomatic as reasonably expected?
<ryuukk__>
maybe there is a way but i'm not aware of?
<g-w1>
I think this would be very hard to impliment. I think the parser only expects one thing in the parens if it is unwrapping an optional, so the parser would have to communicate with analyzer
<g-w1>
and I think it hinders readability because you don't know which one of the things is an optional if you are reading the code. imo
<ryuukk__>
it is if variables name are a, b, c ,d ,e
<ryuukk__>
real world it's: enable_something
<dutchie>
you can't design language features around naming conventions
<ryuukk__>
you know by reading it's a bool
<ryuukk__>
but he said it is hard to know what it is
<dutchie>
the compiler doesn't know that "enable_something" is a boolean
<ryuukk__>
it's a language, it should be "readable"
<g-w1>
andrewk: just saw your video about the crazy landlord (I am subscribed to your rss). I just want to say that I hope you are well.
jayschwa has joined #zig
<ryuukk_>
i saw the video too, if you know him IRL call police so they can check what is wrong, it doesn't look safe the way he ended the video..
<betawaffle>
andrewrk: best of luck with your landlord.
luismanfroni has quit [Ping timeout: 272 seconds]
supercoven has quit [Ping timeout: 244 seconds]
omglasers2 has joined #zig
marnix has quit [Ping timeout: 256 seconds]
marnix has joined #zig
rob_b has joined #zig
rob_b has quit [Remote host closed the connection]
ur5us has joined #zig
omglasers2 has quit [Read error: Connection reset by peer]
luismanfroni has joined #zig
nrdmn68 is now known as nrdmn
nvmd has quit [Quit: Later nerds.]
skuzzymiglet has quit [Ping timeout: 260 seconds]
frmdstryr has quit [Ping timeout: 256 seconds]
omglasers2 has joined #zig
luismanfroni has quit [Quit: Leaving]
skuzzymiglet has joined #zig
<andrewrk>
thanks
Miaourt7 has joined #zig
Miaourt has quit [Ping timeout: 244 seconds]
Miaourt7 is now known as Miaourt
<kandinski>
how can I ensure that my slicing indexes are runtime known only, and not comptime known? I'm trying to write tests, and in tests everything is a literal, therefore comptime known.
<kandinski>
Same for the string buffers that will back the slices, if anybody has a tip so I can ensure they are runtime known in the tests.
<kandinski>
context: wrapping PCRE2, I'm writing utility functions for a slice of slices into the target string, and obviously in the regex library all of those will be runtime known only.
<kandinski>
The issue is that the wrapping code is declaring types as []SomeType, but the comptime known nature of the tests makes my values *[N]Something
<kandinski>
s/Something/SomeType/g
marnix has quit [Ping timeout: 246 seconds]
via_ has joined #zig
<jayschwa>
kandinski: Why does it matter? Are you concerned that a test with comptime-known data will hide runtime problems?
<kandinski>
the types returned when you slice with comptime-known indices and with runtime-known ones are different
<kandinski>
so my tests don't even compile because types don't match
jabb has joined #zig
<kandinski>
between the code I'm writing and the values that the tests generate
denucat has joined #zig
<kandinski>
jayschwa: after having seen this issue, I would also be concerned that a test with comptime-known data could hide runtime problems, but for that my test has to compile first, and I'm not there yet.
<torque>
kandinski, that page you linked seems to have an example right on it of runtime indexing
<torque>
by assigning to a variable instead of using a literal
commander has quit [*.net *.split]
zippoh has quit [*.net *.split]
washbear has quit [*.net *.split]
braket has quit [*.net *.split]
factormystic has quit [*.net *.split]
[RMS] has quit [*.net *.split]
PC98017 has quit [*.net *.split]
JoshAshby has quit [*.net *.split]
teqwve has quit [*.net *.split]
gpanders has quit [*.net *.split]
via has quit [*.net *.split]
doublej472 has quit [*.net *.split]
zippoh has joined #zig
braket has joined #zig
gpanders has joined #zig
[RMS] has joined #zig
PC98017 has joined #zig
washbear has joined #zig
factormystic has joined #zig
doublej41 has joined #zig
<kandinski>
torque: hmmm silly me
gonzus has joined #zig
<gonzus>
Hey. I just watched Andrew's video about his landlord and wanted to check and see if Andrew is ok.
<gonzus>
Gonna check the channel logs in the meantime...
<gonzus>
Ah, I see him replying in the last half an hour. Good.
gazler_ has joined #zig
<gonzus>
Stay safe Andrew. I would suggest you get some legal advice and even police involvement. Take care!
gazler__ has quit [Ping timeout: 265 seconds]
<kandinski>
oh damn, I'd missed that. Best wishes and good luck indeed.
commander has joined #zig
ur5us has quit [Quit: Leaving]
<kandinski>
torque: it's not just assigning to var, you have to give it an explicit type, or there will be a confusing compiler error. That's what had thrown me last night when I tried just that: https://termbin.com/yuei
<kandinski>
torque: got these tests running, thanks very much
sawzall has quit [Read error: Connection reset by peer]
sawzall has joined #zig
<kandinski>
a
ur5us has joined #zig
wootehfoot has quit [Quit: Leaving]
gonzus has quit [Ping timeout: 245 seconds]
skuzzymiglet has quit [Ping timeout: 272 seconds]
ur5us has quit [Ping timeout: 260 seconds]
omglasers2 has quit [Read error: Connection reset by peer]
Akuli has quit [Quit: Leaving]
frmdstryr has joined #zig
donniewest has quit [Quit: WeeChat 2.9]
cr1901_modern has quit [Ping timeout: 256 seconds]
kristoff_it1 has quit [Ping timeout: 258 seconds]
a_chou has joined #zig
radgeRayden has quit [Ping timeout: 272 seconds]
jj__ has quit [Remote host closed the connection]
radgeRayden has joined #zig
jj__ has joined #zig
a_chou has quit [Client Quit]
tane has quit [Quit: Leaving]
kristoff_it1 has joined #zig
ryuukk__ has joined #zig
ryuukk_ has quit [Read error: Connection reset by peer]
<jayschwa>
andrewrk: vacating your apartment seems logical, but I hope you still take this guy to small claims or release his name so other people can learn to avoid him.