Conversation
Notices
-
Embed this notice
snacks (snacks@netzsphaere.xyz)'s status on Monday, 02-Dec-2024 01:55:34 JST snacks This would be easier if c could return muktiple values, guess i can just abuse some internals of the bindings to make it work? -
Embed this notice
snacks (snacks@netzsphaere.xyz)'s status on Monday, 02-Dec-2024 02:25:54 JST snacks @maija or i just push the values onto the stack -
Embed this notice
Maija (maija@netzsphaere.xyz)'s status on Monday, 02-Dec-2024 02:25:55 JST Maija @snacks return a struct or a pointer snacks likes this. -
Embed this notice
snacks (snacks@netzsphaere.xyz)'s status on Monday, 02-Dec-2024 02:26:31 JST snacks @maija for now i just resorted to not handling errors -
Embed this notice
Bankizo (bankizo@netzsphaere.xyz)'s status on Monday, 02-Dec-2024 02:26:49 JST Bankizo @maija @snacks having to create structs to return value is so annoying, and then you have to deconstruct it 😭
no way c will ever implement something better thosnacks likes this. -
Embed this notice
snacks (snacks@netzsphaere.xyz)'s status on Monday, 02-Dec-2024 02:27:27 JST snacks @paula @maija yes, but the stack is forths native type -
Embed this notice
Bankizo (bankizo@netzsphaere.xyz)'s status on Monday, 02-Dec-2024 02:27:29 JST Bankizo @snacks @maija returning 2 integers and returning a struct with 2 integers is effectively the same snacks likes this. -
Embed this notice
Bankizo (bankizo@netzsphaere.xyz)'s status on Monday, 02-Dec-2024 02:28:54 JST Bankizo @snacks @maija oo fancy
also fun fact, you can do it in c++
you can return a std::tuplesnacks likes this. -
Embed this notice
snacks (snacks@netzsphaere.xyz)'s status on Monday, 02-Dec-2024 02:29:57 JST snacks @paula @maija should only do shit with those if you're in html mode -
Embed this notice
Bankizo (bankizo@netzsphaere.xyz)'s status on Monday, 02-Dec-2024 02:29:58 JST Bankizo @snacks @maija oh my reply had < > for the templates and it filtered it all out? -
Embed this notice
Bankizo (bankizo@netzsphaere.xyz)'s status on Monday, 02-Dec-2024 02:30:59 JST Bankizo @maija @snacks you can return a std::tuple int int then deconstruct it with auto [a, b] = f() snacks likes this. -
Embed this notice
snacks (snacks@netzsphaere.xyz)'s status on Monday, 02-Dec-2024 02:31:12 JST snacks @paula @maija c# has similar syntax -
Embed this notice
snacks (snacks@netzsphaere.xyz)'s status on Monday, 02-Dec-2024 02:31:51 JST snacks @paula Weird -
Embed this notice
Bankizo (bankizo@netzsphaere.xyz)'s status on Monday, 02-Dec-2024 02:31:53 JST Bankizo @snacks yeah, plain text but it still removes the >int, int< snacks likes this. -
Embed this notice
Bankizo (bankizo@netzsphaere.xyz)'s status on Monday, 02-Dec-2024 02:31:54 JST Bankizo @snacks idk let me try again std::tuple -
Embed this notice
snacks (snacks@netzsphaere.xyz)'s status on Monday, 02-Dec-2024 02:32:55 JST snacks @paula @maija multiple returns in stack based languages are just natural and it seems like a weird thing that other languages struggle with it after experiencing that -
Embed this notice
akkoma flavored lizzy (fleckenstein@lizzy.rs alt) (lizzy@social.vlhl.dev)'s status on Monday, 02-Dec-2024 03:56:34 JST akkoma flavored lizzy (fleckenstein@lizzy.rs alt) @paula @maija @snacks false. C23 already has structural typing (as well as typeof and auto) which allows you to effectively have generics using macros, meaning you can do tuples like:
#include <stdio.h> #define tuple(A,B) struct tuple_##A##_##B { A fst; B snd; } tuple(int, char) silly_function() { return (tuple(int, char)) { 25, 'a' }; } int main() { auto x = silly_function(); printf("(%d, %c)\n", x.fst, x.snd); }however this is limited so far, basically structs with the same name and fields are compatible, and because of that you can only pass in types that can be properly concatenated into the name into there. (e.g. can’t have pointers in there without making a typedef for them, which is annoying). C2y will add record types which solve this problem.
snacks likes this. -
Embed this notice
snacks (snacks@netzsphaere.xyz)'s status on Monday, 02-Dec-2024 03:57:13 JST snacks @maija @paula it is way clearer to return shit than to just mutate -
Embed this notice
Maija (maija@netzsphaere.xyz)'s status on Monday, 02-Dec-2024 03:57:14 JST Maija @paula @snacks no it's not -
Embed this notice
Bankizo (bankizo@netzsphaere.xyz)'s status on Monday, 02-Dec-2024 03:57:16 JST Bankizo @maija @snacks
auto [a, b] = f()
is much better than
int a, b
f(&a, &b) -
Embed this notice
Maija (maija@netzsphaere.xyz)'s status on Monday, 02-Dec-2024 03:57:17 JST Maija @paula @snacks why is that bad? its not -
Embed this notice
Bankizo (bankizo@netzsphaere.xyz)'s status on Monday, 02-Dec-2024 03:57:18 JST Bankizo @maija @snacks its convenient
c programmers use return on a pointer parameter wayy too often -
Embed this notice
Maija (maija@netzsphaere.xyz)'s status on Monday, 02-Dec-2024 03:57:19 JST Maija @paula @snacks why would they? -
Embed this notice
Bankizo (bankizo@netzsphaere.xyz)'s status on Monday, 02-Dec-2024 03:58:05 JST Bankizo @maija @snacks kill yourself snacks likes this. -
Embed this notice
snacks (snacks@netzsphaere.xyz)'s status on Monday, 02-Dec-2024 04:24:10 JST snacks @maija @paula less annoying than creating a struct just for this return -
Embed this notice
Maija (maija@netzsphaere.xyz)'s status on Monday, 02-Dec-2024 04:24:12 JST Maija @snacks @paula auto[a,b] = f() is a horrific format -
Embed this notice
Bankizo (bankizo@netzsphaere.xyz)'s status on Monday, 02-Dec-2024 04:24:18 JST Bankizo @maija @snacks i said auto [a, b] cause thats the syntax on c++
on lua and python its just
a, b = f()snacks likes this. -
Embed this notice
snacks (snacks@netzsphaere.xyz)'s status on Monday, 02-Dec-2024 04:29:04 JST snacks @paula @maija in forth it's just f -
Embed this notice
Maija (maija@netzsphaere.xyz)'s status on Monday, 02-Dec-2024 04:36:12 JST Maija @snacks @paula pointers man snacks likes this. -
Embed this notice
snacks (snacks@netzsphaere.xyz)'s status on Monday, 02-Dec-2024 04:36:53 JST snacks @maija @paula
-uck -uck ? - unrecognized word!
Stack<10>
THROW code = -13
Undefined word! -
Embed this notice
Maija (maija@netzsphaere.xyz)'s status on Monday, 02-Dec-2024 04:36:54 JST Maija @snacks @paula -uck -
Embed this notice
翠星石 (suiseiseki@freesoftwareextremist.com)'s status on Monday, 02-Dec-2024 20:01:53 JST 翠星石 @snacks Just define the function to take 2 pointers to each variable and then write directly to those variables and return the success/error code. -
Embed this notice
snacks (snacks@netzsphaere.xyz)'s status on Monday, 02-Dec-2024 20:04:26 JST snacks @EdBoatConnoisseur @Suiseiseki i know that pointers and structs exist, i just want my forth interop to work like forth -
Embed this notice
EdBoatConnoisseur (edboatconnoisseur@poa.st)'s status on Monday, 02-Dec-2024 20:04:27 JST EdBoatConnoisseur @Suiseiseki @snacks just return a struct.
-
Embed this notice
snacks (snacks@netzsphaere.xyz)'s status on Monday, 02-Dec-2024 20:28:56 JST snacks @EdBoatConnoisseur @Suiseiseki read the thread, i'll just figure out how to get to pforths stack and push the values there -
Embed this notice
EdBoatConnoisseur (edboatconnoisseur@poa.st)'s status on Monday, 02-Dec-2024 20:28:57 JST EdBoatConnoisseur @snacks @Suiseiseki i mean, you can always do bad and worse things, say you do not have to return a struct or pointer or rather not want to return either of those, you can return an array or do something worse and return your 2 values inside a string with a field separator, that was you get the added fun of iterating over the string to find the field separator, split the string and re-cast the 2 values from string to their canonic types.
-
Embed this notice
EdBoatConnoisseur (edboatconnoisseur@poa.st)'s status on Monday, 02-Dec-2024 20:33:24 JST EdBoatConnoisseur @snacks @Suiseiseki >read
nosnacks likes this.
-
Embed this notice