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/
blinghound has quit [Remote host closed the connection]
Penguinl0l has joined #zig
<Penguinl0l> hi, does anyone have a link to where i can read on zig's platform portability?
<Penguinl0l> cant really find much
<GreaseMonkey> Penguinl0l: think of a use case and we can probably tell you how well it's going to work
<GreaseMonkey> in general the Big Three™ (linux, windows, macos) works from my understanding, and so does at least one BSD
<GreaseMonkey> both as build machines and as targets
<GreaseMonkey> although outside of amd64 you might struggle for a build machine, i'm not entirely sure how well it works
<Penguinl0l> how hard is it to produce sym
<GreaseMonkey> what do you mean
<Penguinl0l> symlinks**** (folders, files)
<Penguinl0l> sorry my keyboard bonked
<Penguinl0l> do i invoke shell in zig, or is it supported via the language?
<GreaseMonkey> i don't know if the stdlib has support for the syscall required, but you can either use that approach or you can link against the libc and use a C import
<Penguinl0l> gotcha
<GreaseMonkey> ok it seems that symlink support is in the stdlib
<Penguinl0l> i havent actually started learning zig, but i want to use it for cli apps. i was just wondering how much it would be like C vs rust
<Penguinl0l> im about to start, but basically i wanted to see if zig had any standard libraries for misc file ops that in C i would normally have to invoke shell for (mkdir, symlink, etc)
<lemmi> why would you need to shell out for these Oo?
<Penguinl0l> i guess im just used to doing everything with sprintf and shell because mkdir() by itself isn't portable. I could ifdef it and do _mkdir but this gets harder with symlink so i usually just sprintf everything and call system()
<Penguinl0l> i thought rust handled this without a hitch but i've run into an issue when it comes to symlinks. Keep in mind this isn't that big of a deal, I'm just sorta fishing for what zig does for portability. C usually hasn't dif headers and dif functions, rust abstracts it out (for the most part) =P
<GreaseMonkey> what are your target OSes
craigo has joined #zig
<GreaseMonkey> ...OK, seems there's support for symlinks on Windows as well
<GreaseMonkey> std.os.symlink() is what you want
<GreaseMonkey> pub fn symlink(target_path: []const u8, sym_link_path: []const u8) SymLinkError!void
<Penguinl0l> Thanks! I couldn't find this on my own... and I've been looking, but I probably just don't know what to google yet
<Penguinl0l> my target oses are linux (amd64 i guess) and windows??? I'm not used to desktop development. I normally do embedded but i wanna try and make some cool cli progs
daurnimator has joined #zig
waleee-cl has quit [Quit: Connection closed for inactivity]
Penguinl0l has quit [Remote host closed the connection]
nikita_ has joined #zig
nikita` has quit [Ping timeout: 256 seconds]
traviss has quit [Remote host closed the connection]
stripedpajamas has joined #zig
stripedpajamas has quit [Quit: sleeping...]
stripedpajamas has joined #zig
mikdusan has quit [Quit: WeeChat 2.6]
knebulae has quit [Read error: Connection reset by peer]
marnix has joined #zig
marnix has quit [Ping timeout: 260 seconds]
xackus has joined #zig
knebulae has joined #zig
xackus has quit [Ping timeout: 258 seconds]
marnix has joined #zig
stripedpajamas has quit [Quit: sleeping...]
riba has joined #zig
nikita_ is now known as nikita`
craigo has quit [Ping timeout: 260 seconds]
riba has quit [Ping timeout: 246 seconds]
ur5us has joined #zig
riba has joined #zig
ur5us has quit [Ping timeout: 260 seconds]
marnix has quit [Read error: Connection reset by peer]
KKRT has joined #zig
_Vi has joined #zig
ur5us has joined #zig
riba has quit [Ping timeout: 258 seconds]
nikita` has quit [Quit: leaving]
nikita` has joined #zig
craigo has joined #zig
dermetfan has joined #zig
<danyspin97> Last month I saw a nice tutorial on a third party site
<danyspin97> but now I can't find it. Does anyone know about it?
<ikskuh> did you mean ziglearn.org?
<danyspin97> I think yea
dermetfan has quit [Ping timeout: 260 seconds]
Ashpool has joined #zig
bastian[m] has joined #zig
bastian[m] is now known as Bastian[m]
ur5us has quit [Ping timeout: 260 seconds]
ur5us has joined #zig
marnix has joined #zig
ur5us has quit [Ping timeout: 260 seconds]
ziggypop has joined #zig
komu has joined #zig
<komu> Penguinl0l: you can use sourcegraph to search(it has better search than github IMHO).
<komu> Here is a search of `fn symlink`: https://sourcegraph.com/search?q=repo:%5Egithub%5C.com/ziglang/zig%24+fn+symlink+lang:zig&patternType=literal
komu has quit [Remote host closed the connection]
nikita` has quit [Quit: leaving]
SimonNa has quit [Remote host closed the connection]
waleee-cl has joined #zig
dongcarl9 has joined #zig
swills_ has joined #zig
haliucin1s has joined #zig
Stephie- has joined #zig
azarus_ has joined #zig
spader has joined #zig
corvid has joined #zig
dongcarl has quit [*.net *.split]
haliucinas has quit [*.net *.split]
rooke has quit [*.net *.split]
casaca has quit [*.net *.split]
terinjokes has quit [*.net *.split]
swills has quit [*.net *.split]
Stephie has quit [*.net *.split]
azarus has quit [*.net *.split]
yeti has quit [*.net *.split]
bens has quit [*.net *.split]
dongcarl9 is now known as dongcarl
spader is now known as terinjokes
yeti has joined #zig
<Sahnvour> what's the best option to create a slice from a separate pointer and length ? if it's at all possible
<ifreund> Sahnvour: var x = undefined; x.ptr = y; x.len = z;
<ifreund> well, var x: []T = undefined; would be needed
<Sahnvour> ifreund: thanks, was trying to do it with struct initialization only ... :)
<ifreund> yeah, I'm not totally sure why that's not allowed, maybe someday
opDispatch has quit [Quit: Konversation terminated!]
marnix has quit [Ping timeout: 256 seconds]
<ikskuh> there's no option to do a "analyse only" step, right?
<ikskuh> so no code gen, just validity checking
<ifreund> not that I know of
<ikskuh> would allow faster iteration cycles i think
aarvay has joined #zig
marnix has joined #zig
aarvay_ has joined #zig
aarvay has quit [Remote host closed the connection]
aarvay_ is now known as aarvay
stripedpajamas has joined #zig
riba has joined #zig
Akuli has joined #zig
riba has quit [Ping timeout: 260 seconds]
casaca has joined #zig
nikita` has joined #zig
xackus has joined #zig
SimonNa has joined #zig
marnix has quit [Ping timeout: 260 seconds]
<KKRT> hi guys, can anyone explain to me why i cannot access variables in this returned struct? https://i.imgur.com/a5hvjut.png
<KKRT> i tried to google it, but didnt get anything fitting, only found Zig's assertion tests, but it didnt clear things up for me https://git.sr.ht/~andrewrk/ziglang/tree/cd5c9c8998f1669059cee3d915831ee539dea2b6/test/compile_errors.zig#L5945
<scientes> KKRT, you set it as const
<scientes> you can't change a const
<scientes> you have to use "var"
<scientes> oh nvm
<scientes> KKRT, you have to unwrap the error
<scientes> like start the call with "try "
<scientes> "try std.ChildProcess.exec(..."
<KKRT> omg, it was so simple
<KKRT> thanks
<KKRT> i saw the error handling within the code of this exec function -> https://github.com/ziglang/zig/blob/7d9ee5d6d53011e9edc7ca10b76d64af807a833f/std/child_process.zig#L188
<scientes> KKRT, with a return, try does nothing
<KKRT> so i thought i dont need to handle it on my side, but still the message was kinda confusing to me, like variables within the struct were set to private mode or smth
<scientes> as try is just a short-circuit to return the error
<scientes> this is not C++, errors are just values
<scientes> its basically what C code would look like if you did it correctly
B4s1l3 has joined #zig
B4s1l3 is now known as opDispatch
tgschultz has quit [Ping timeout: 256 seconds]
manikawnth has joined #zig
<manikawnth> Hi, I'm new to zig and finding if there's a way to mutate struct fields when passed to function as a parameter, the docs say func parms are immutable.
<Akuli> you could pass by pointer
<Akuli> fn foo(thing: *MyStruct) void { thing.stuff = 123; }
<manikawnth> I tried, but the compiler is interpreting it always as constant pointer
<manikawnth> fn reverse(p: *Point) void{ ... }
<manikawnth> var p = &Point {.x = 32, .y = 45 };
<manikawnth> reverse(p);
<Sahnvour> do `var p = Point{...}; reverse(&p);` instead
<Akuli> hmm, 'var p = &...' makes a pointer that can be changed, not a struct that can be changed
<Sahnvour> in your case, the `var p` is a pointer to a constant `Point` struct
stripedpajamas has quit [Quit: sleeping...]
<manikawnth> Thanks a lot, took some to digest, but it is very clear now.
<manikawnth> This code is resulting in segfault, on the surface it looked like stack memory got popped. But I'm still able to print but not pass into another function. Where am I doing wrong?
<manikawnth> ```
<manikawnth> return ptr; //escapes?
<scientes> manikawnth, I generally do _thing: *MyStruct..and then var thing = _thing;
Ashpool has quit [Quit: Leaving]
<scientes> not sure if IRC kept the underscore there...
Ashpool has joined #zig
manikawnth has quit [Remote host closed the connection]
manikawnth has joined #zig
marnix has joined #zig
<yeti> it did
manikawnth has quit [Remote host closed the connection]
marnix has quit [Ping timeout: 260 seconds]
manikawnth has joined #zig
<Sahnvour> manikawnth: try to upload your code on a gist/pad on the web, it'll be easier to read and help you
<Sahnvour> in reverse_facade, you can't return the address of q, because it is a local variable. it's located on the stack and will be overwritten in the future by other possibly unrelated code
<manikawnth> Yeah kind of guessed that, but somehow this `copyValPtr.print()` seems to be alive and printing consistently. And this is on windows.
<Sahnvour> this can either work or not, depending on many factors, because that is malformed code
<fengb> It’s probably working because the memory space hasn’t been overwritten yet
marnix has joined #zig
cole-h has joined #zig
dermetfan has joined #zig
riba has joined #zig
riba has quit [Ping timeout: 260 seconds]
manikawnth has quit [Remote host closed the connection]
marnix has quit [Ping timeout: 256 seconds]
<Akuli> hm
<Akuli> zig has no way to prevent returning a stack variable (yet)?
<Akuli> eeh, returning pointer to stack variable
<Akuli> i guess it's not something that's easy to do accidentally after some experience with the language
<fengb> Not yet. I think some escape analysis and potential use-after-free are planned
<scientes> Akuli, no way to prevent it entirely
<scientes> except with an expensive run-time safety check
<scientes> but a simple check would be nice
<Akuli> right
marnix has joined #zig
<pixelherodev> Whoa, more nice stage2 work lately :)
<pixelherodev> Hopefully I"ll be able to get back into it this week
traviss has joined #zig
stripedpajamas has joined #zig
_Vi has quit [Ping timeout: 272 seconds]
dermetfan has quit [Ping timeout: 256 seconds]
dermetfan has joined #zig
ur5us has joined #zig
nikita` has quit [Quit: leaving]
marnix has quit [Ping timeout: 256 seconds]
craigo has quit [Ping timeout: 256 seconds]
layneson has joined #zig
layneson has quit [Ping timeout: 246 seconds]
signop has quit [Quit: signop]
KKRT has quit [Quit: KKRT]
xackus has quit [Quit: Leaving]
layneson has joined #zig
layneson has quit [Ping timeout: 256 seconds]
stripedpajamas has quit [Quit: sleeping...]
Akuli has quit [Quit: Leaving]
dermetfan has quit [Ping timeout: 256 seconds]
signop has joined #zig
ofelas has joined #zig
ofelas has quit [Ping timeout: 256 seconds]
ofelas has joined #zig
ofelas has quit [Ping timeout: 260 seconds]
ofelas has joined #zig