<foobles>
I guess I don't understand when to use a store instruction vs making a new variable for ssa
<foobles>
i thought the point of ssa was to represent the program in a way such that nothing is mutable
<cow-orker>
in a perfect world....
klltkr_ has quit [Ping timeout: 246 seconds]
slowtyper has quit [Ping timeout: 240 seconds]
marijnfs_ has joined #zig
marijnfs has quit [Ping timeout: 260 seconds]
<foobles>
huh, i just read "A key design point of an SSA-based representation is how it represents memory. In LLVM, no memory locations are in SSA form, which makes things very simple. This section describes how to read, write, and allocate memory in LLVM."
<foobles>
but isn't everything in memory?
<fengb>
Memory is not memory 👍
<fengb>
🤔
<fengb>
Wrong emoji
<foobles>
......... ;(
<cow-orker>
llvm values are not "in memory". Or, they may end up there, but maybe not.
<cow-orker>
better: they're just stored in registers
<foobles>
interesting
<foobles>
so the actual llvm values (like the stuff prefixed with % ) are not in memory
<foobles>
but what they sort of "refer to" are
<foobles>
but they aren't pointers
<foobles>
like in the example I posted, all of them are initially assigned with alloca
<foobles>
so you can't re-assign to %0 or something, but you can write into its memory
<cow-orker>
yes, %foobles_result is subject to SSA, but the memory it points to (on the stack) it not
<foobles>
thanks, this will take some getting used to :v
<cow-orker>
so this is SSA wrt LLVM, other backends may differ
<foobles>
haskell as a backend for guaranteed, for real, single assignment O_O
jicksaw has quit [Quit: ZNC is kill]
jicksaw has joined #zig
<cow-orker>
Haskell is nice, but beyond STG (ghc) there are different backends offering different strategies wrt compilation... :-)
st4ll1 has quit [Ping timeout: 260 seconds]
st4ll1 has joined #zig
dimenus|home has joined #zig
dimenus has quit [Ping timeout: 265 seconds]
dimenus|home has quit [Read error: Connection reset by peer]
dimenus|home has joined #zig
<foobles>
what does the handle_is_ptr() function in codegen.cpp do?
<foobles>
it seems to do more than just testing if the type is a pointer type
tines9 has quit [Ping timeout: 256 seconds]
tines9 has joined #zig
shakesoda has quit [Quit: Connection closed for inactivity]
xackus_ has joined #zig
<foobles>
like error unions, regular unions, and some non-pointer optionals still quailfy
<pmwhite>
is there a way to take function parameters that may or may not fail?
<foobles>
what do you mean?
<foobles>
like accepting an error union?
<pmwhite>
My trouble is that if I specify the parameter type as anyerror!void, I can no longer pass in void functions.
<pmwhite>
That is, I can't pass in functions that are guaranteed to not fail.
<pmwhite>
Are those not implicitly castable?
<foobles>
i think it should be
<foobles>
why do you want to accept error unions?
<pmwhite>
I'm not sure we're on the same page. I'm not trying to have error unions as parameters. Maybe I should give an example...
<foobles>
yeah, function pointers can't cast like that
<foobles>
since that would require creating an entirely new function
<foobles>
bc of allocations and all that
<foobles>
so you need to write a different noop with your intended signature
<foobles>
#1717 should make this easier in the future
<pmwhite>
I guess I don't really know the internals at all, but I would expect the same assembly or whatever would be output regardless of the error-ness of the function.
<pmwhite>
I mean, the same instructions would be used to call the function.
<foobles>
no, since if it returns an error union, the function has to be represented differently
<foobles>
to actually return a value saynig "no error"
<foobles>
instead of just returning no value
waleee-cl has quit [Quit: Connection closed for inactivity]
<pmwhite>
oh, i guess so.
knebulae has quit [Read error: Connection reset by peer]
knebulae has joined #zig
<foobles>
so, what does the handle_is_ptr() function in codegen.cpp do?
<mikdusan>
foobles: looking at the handle_is_ptr() and seeing which types _always_ return false, they look suspiciously like types that are always copy-by-value params
<foobles>
ohhhh huh
<foobles>
oh I see: maybe handle_is_ptr is saying whether it will be passed by pointer or by value to functions and such?
<foobles>
I also just found this comment:
<foobles>
For functions that have a return type for which handle_is_ptr is true, a result location pointer is the secret first parameter ("sret"). This instruction returns that pointer.
<mikdusan>
yeah that makes sense too; we don't have result-location for u32 ...those are just copied
dputtick has quit [Quit: Connection closed for inactivity]
<foobles>
ok cool!
<foobles>
wow cool insight, thanks so much that will defintely clear things up
<mikdusan>
the handle is in superposition; and handle_is_ptr measures it. we have quantum tech!
foobles has quit [Ping timeout: 240 seconds]
CommunistWolf is now known as CommunistDragon
CommunistDragon is now known as CommunistWolf
Invader_Bork has joined #zig
ur5us has quit [Ping timeout: 240 seconds]
cole-h has quit [Quit: Goodbye]
Chris660 has joined #zig
Chris660 has quit [Ping timeout: 240 seconds]
metaleap has joined #zig
_Vi has quit [Ping timeout: 265 seconds]
wilsonk has left #zig [#zig]
wilsonk has joined #zig
dddddd has joined #zig
FireFox317 has joined #zig
ifreund has joined #zig
knebulae has quit [Ping timeout: 260 seconds]
ifreund has quit [Quit: WeeChat 2.8]
return0e has quit []
frett27_ has quit [Ping timeout: 264 seconds]
frett27_ has joined #zig
<ikskuh>
hm
<ikskuh>
i think the decision to use NtCreateFile instead of CreateFile will create problems in the long term rum
<ikskuh>
for one, it's not possible to open non-files with this
<ikskuh>
andrewrk, daurnimator: what's the correct way to open "COM3" or "\\.\COM3" or "\Global??\COM3"
<ikskuh>
COM3 is not found, others either yield unreachable or BadPathName
pystub has joined #zig
ur5us has joined #zig
<alexnask>
Dealing with windows T_T_
<alexnask>
gl
<ikskuh>
alexnask: CreateFile works…
<ikskuh>
so i wonder why NtCreateFile is used
<FireFox317>
Its a lower level api that allows for more configuration. I think it was used for stuff like seeking, not completely sure tho
<mikdusan>
ikskuh: just to confirm escaped the string? "\\\\.\\COM3"
<ikskuh>
mikdusan: passing in the string from CLI
<ikskuh>
but tried with hardcoded and escaped paths as well
ur5us has quit [Ping timeout: 240 seconds]
Invader_Bork has quit [Read error: Connection reset by peer]
knebulae has joined #zig
Xavi92 has joined #zig
_Vi has joined #zig
st4ll1 has quit [Quit: WeeChat 2.8]
nycex- has joined #zig
nycex has quit [Ping timeout: 240 seconds]
dimenus|home has quit [Remote host closed the connection]
dimenus has joined #zig
nycex- has quit [Quit: Quit]
nycex has joined #zig
r4pr0n has joined #zig
return0e has joined #zig
metaleap has quit [Quit: Leaving]
metaleap has joined #zig
Cadey has quit [Disconnected by services]
Cadey has joined #zig
r4pr0n has quit [Quit: r4pr0n]
Xavi92 has quit [Ping timeout: 256 seconds]
Akuli has joined #zig
Xavi92 has joined #zig
dimenus has quit [Remote host closed the connection]
return0e has quit []
Xavi92 has quit [Remote host closed the connection]
Nypsie has joined #zig
st4ll1 has joined #zig
cole-h has joined #zig
sarmonsiill has joined #zig
<sarmonsiill>
Hi! I've been curious about Zig for quite some time but I've haven't been able to get into it yet. Anyone got any resources to get started? Is it the official docs or something else? I wanna find examples for how to handle files for example
<afontain_>
I just started reading the official doc
<sarmonsiill>
afontain_: thanks, I'll try doing that too. I'm a php-hacker from the start and then a Go-lover since about 6-7 years. Don't know if that's against me or in favor :)
<sarmonsiill>
blueberrypie7: awesome info. thanks! I've checked some of those sources but can't find much info on how to interact with files. Have I missed it..?
<blueberrypie7>
are you unsure how to make use of the standard library in your project?
<Nypsie>
You're welcome. You'll find yourself looking into the source code alot, but in the end it will help you understand the language alot better than any tutorial could.
drasko has joined #zig
<Snektron>
<mikdusan "ikskuh: just to confirm escaped "> ah, the elder backslash
<pmwhite>
no iter() for arraylists?
return0e has joined #zig
<fengb>
Don't need it anymore. Just do `for (list.items)`
<companion_cube>
by what magic?
FSX has quit [Ping timeout: 240 seconds]
<fengb>
list.items always stores the slice of added items, and internally it breaks out of the slice
<fengb>
Previously it stored a slice of the available size so we needed the extra methods
<companion_cube>
so when pushing a new element, you always modify the slice
<fengb>
Yep
<companion_cube>
fresh take, I guess
<fengb>
Embrace the unsafe :P
<companion_cube>
feels weird, as I've been writing a bit of rust, but well
<ikskuh>
companion_cube: it's not that it gets really unsafe at any point
<companion_cube>
you just have a realloc-like of the slice even if the capacity is enough
<fengb>
We know better than the compiler :P
<fengb>
It's not proveable but still auditable
<companion_cube>
(that's the idea behind rust's unsafe, btw)
<ikskuh>
i like that you can do just
<ikskuh>
slice = slice.ptr[0..slice.len + 1];
<ikskuh>
→ makes slice 1 larger
<fengb>
Right, which is why I mentioned embracing the unsafe
<fengb>
I know in Rust, it can be frowned upon to do this kind of stuff. We just don't care >_>
<fengb>
Maybe not always be a good attitude heh
<ikskuh>
hmm
<ikskuh>
anyone firm with the Dir api?
<ikskuh>
i want to save-and-restore my cwd(
<ikskuh>
cwd()
<Nypsie>
Currently using Dir api here
<companion_cube>
in rust it'd be more annoying indeed
<ikskuh>
there's a lot of functions, but none to change cwd?
<Nypsie>
There's OpenDir that returns a new Dir object
<Nypsie>
OpenDirList if you're using master
<ikskuh>
hm
<ikskuh>
then it looks like i have to change some API :D
<ikskuh>
and pass the dir parameter explicitly
<Nypsie>
You can also use chdir to set the current working directory towards the given path
<Nypsie>
And then use cwd() as you're used it.
<Nypsie>
Part of the std.os API
<ikskuh>
ah no
<ikskuh>
it's better to use dir handles i think
<Nypsie>
Suppose so, but don't know the context of what you're trying to achieve :p
<Nypsie>
Using dir handles myself
* ikskuh
is writing an assembler
<ikskuh>
and i want recursive file inclusion
<ikskuh>
with correct relative-path handling to each file
lunamn has quit [Quit: Ping timeout (120 seconds)]
lunamn has joined #zig
linuxgemini has quit [Quit: Ping timeout (120 seconds)]
linuxgemini has joined #zig
<Nypsie>
Ah gotcha
<ikskuh>
current wishlist:
<ikskuh>
get a path relative to one dir relative/absolute to another :D
ifreund has joined #zig
dddddd has quit [Remote host closed the connection]
foobles has joined #zig
drasko has quit [Ping timeout: 240 seconds]
wozeparrot has joined #zig
benjif has joined #zig
drasko has joined #zig
<ikskuh>
looks like openDir isn't that stable :D
<Nypsie>
You're getting errors? I haven't gotten an error yet
<ikskuh>
unexpected errno: 9
<ikskuh>
[19:29]
<ikskuh>
nah, i was just stupid
<pixelherodev>
Oh this is cool
<pixelherodev>
Don't know why I was motivated to try but
<pixelherodev>
`grep -w N /usr/include/asm-generic/errno-base.h`
<pixelherodev>
For the lower numbers, errno-base.h, for higher ones, errno.h
Akuli has quit [Quit: Leaving]
Akuli has joined #zig
FireFox317 has quit [Quit: Leaving]
<ikskuh>
yeah it's a horrible structure
drasko has quit [Ping timeout: 272 seconds]
waleee-cl has joined #zig
drasko has joined #zig
<foobles>
what does the `initializing` tag mean on a zigvalue?
<foobles>
i can sort of assume what it means
<foobles>
but i dont know when it is enabled
Patrice_ has joined #zig
<foobles>
err, IrInstGen i mean
<nephele>
Someone have an example of openssl used with zig? I want to write a server application using DTLS over SCTP, seems my only options are openssl or wolfssl (unless zig has dtls itself heh)
frett27_ has quit [Ping timeout: 256 seconds]
kydrops has quit [Ping timeout: 265 seconds]
kydrops has joined #zig
_Vi has quit [Ping timeout: 265 seconds]
drasko has quit [Ping timeout: 240 seconds]
<andrewrk>
foobles, it's true when the instruction is being used as part of an initialization expression such as Foo{.a = b} or [_]T{a, b}
<andrewrk>
I can't remember why exactly that's needed, would have to look at the logic to remember
kydrops has quit [Quit: WeeChat 2.8]
drasko has joined #zig
copy has joined #zig
<foobles>
ok alright, thanks
<foobles>
so intialization of a struct?
<foobles>
or just `var x = a + b;`
jjido has joined #zig
<andrewrk>
not sure
<foobles>
alright, thanks '=D
shakesoda has joined #zig
ifreund has quit [Ping timeout: 246 seconds]
ifreund has joined #zig
ifreund has quit [Ping timeout: 240 seconds]
ifreund has joined #zig
Nypsie has quit [Quit: WeeChat 2.8]
joey152 has joined #zig
decentpenguin has quit [Quit: decentpenguin]
decentpenguin has joined #zig
student069 has joined #zig
Chris660 has joined #zig
<gpanders>
Hi all, how do I convert a [*]u8 into []u8? In particular, I am reading arguments using std.os.argv, which returns type [][*]u8, but many of the APIs I'm trying to use want a []u8. I've searched through the docs and haven't been able to find anything on this
<ikskuh>
gpanders: argument parsing is better done via std.process.argsIterator or something
<ikskuh>
but to answer the initial question: slice it!
<ikskuh>
[*] has no length, so you need to slice the pointer to get a slice:
<marler8997_>
if I install "gcc_multi" on my nixos box then I can no longer build Zig, it fails with undefined symbols while "Linking CXX executable zig0". Does this sound like an issue or do you think there's nothing Zig can do?
<ikskuh>
mikdusan: thanks! :)
<marler8997_>
here's the linker output, looks like it can't find symbols that would probably come from LLVM: https://pastebin.com/ADsg4yz5
<ikskuh>
oh, interesting! h11 does not have network support itself
return0e has quit []
<ikskuh>
mikdusan: and there goes my dream of a quick hack :D
<mikdusan>
oh well :(
<ikskuh>
github doesn't allow http API
<ikskuh>
so… linking libcurl-easy it is … :D
decentpenguin has quit [Quit: decentpenguin]
_Vi has joined #zig
return0e has joined #zig
Akuli has quit [Quit: Leaving]
ifreund has quit [Quit: leaving]
Patrice_ has quit [Ping timeout: 260 seconds]
dimenus has quit [Ping timeout: 258 seconds]
<foobles>
huh, I just checked, and optional unwraps will NEVER be constructed with 'intializing' flag true
<foobles>
ir_build_optional_unwrap_ptr is called with `initializing` hardcoded to false in every instance
<andrewrk>
dead code in stage1 would not be surprising given how much churn the codebase goes through
<mikdusan>
foobles: this looks to be redundant residual of src/gen instruction split; good find. #5247