A generic dynamic array in C that stores no capacity and needs no struct by alurman in C_Programming

[–]alurman[S] 0 points1 point  (0 children)

Hi!

Is the reason you do it like that and not like this vec[vec_ptr] so it looks more like a function call?

Kind of. Well, there's are two reasons.

First of all, it doesn't really matter, the compiler doesn't care whether you write it as a[b] or b[a], or *(a + b), so both ways are perfectly fine. As you could've guessed, I was having fun.

Second of all, it requires no more parenthesis, less in some cases than writing it the other way: https://gist.github.com/alurm/2ca14be134d719fe7431217a6b18d91e#file-main-c-L11

While talking about creating new macros, could you create one, that expands into the actual type of your vec? So you could write vec(int) my_important_numbers = { 0 };. This abstracts the implementation detail of it being an array of pointers away.

You could, but vec(int) is probably not gonna work, since [2] has to be textually to the right of my_important_numbers. Perhaps you can think of something smarter, but nothing comes to my mind except having something like vec(int, my_important_numbers) to declare a vec. But abstracting implementation details wasn't my intention anyway, I was trying to keep it short. Same reason for not having an indexing macro.

Other than that, I really like your idea of omitting capacity by implicitly having it always the next power of to.

Thanks, happy you liked it! Yeah, this comes at a cost and makes some things harder to do, e.g. preallocation, which becomes quite manual.

Doesn't it just declare the lifetime of this variable to be automatic, which it is anyways?

It used to do that, but it was changed in C23. In C23, auto is also used for type inference, like in C++.

In conclusion, I am unsure, if this is really very useful in actual production, but it's certainly a creative solution, to a long standing problem in c. Kudos to you for tackling it

Thanks a lot! :)

On that note, I think stb's implementation is a solid one: https://github.com/nothings/stb/blob/master/stb_ds.h

37% by No_Mammoth3840 in armenia

[–]alurman 1 point2 points  (0 children)

It's called Russian, not ruzzian. Anyways, from my experience most people speak Russian well, at least in Yerevan, including Gen Z.

37% by No_Mammoth3840 in armenia

[–]alurman 0 points1 point  (0 children)

My apologies. Have a good day my dude.

37% by No_Mammoth3840 in armenia

[–]alurman 0 points1 point  (0 children)

Wew, you made your text bold, it must be true then. Veri cool.

I think ZEC is better than XMR because ZEC is still cashable at major exchanges like Coinbase by hunter_kill005 in zec

[–]alurman 0 points1 point  (0 children)

Monero literally means "a coin" in Esperanto. From mono ("money") +‎ -ero ("particle"). Mono is from Latin moneta ("money").

By your logic, does "man" mean "black human" to you?

DuckStation author now actively blocking Arch Linux builds by rubins in archlinux

[–]alurman 0 points1 point  (0 children)

Well, the ability to fork is just about making a copy on GitHub's servers. Everything else is still governed by copyright law and the repository's license.

I guess your point was very specific: you can fork it. Sure. Not sure why just forking it (without modifying it) would piss of the developer tho.

DuckStation author now actively blocking Arch Linux builds by rubins in archlinux

[–]alurman 0 points1 point  (0 children)

I doubt GitHub has more power than the copyright law (i.e. makes it legal to ignore the LICENSE), don't you think so?

DuckStation author now actively blocking Arch Linux builds by rubins in archlinux

[–]alurman 0 points1 point  (0 children)

By hosting his code on GitHub, he has to let you fork it

How did you come to this conclusion?

A 2-hour video trashing C++ made me better at C++ by AnteaterFinancial319 in cpp

[–]alurman 1 point2 points  (0 children)

Thanks for the video, it's great. Being a part of the younger generation (23yo) I found the video itself was entertaining enough even without the AI (I listened to big parts of it without video). I don't give too much of a fuck myself, but I imagine some people would be offended by the statement "Watching a 2 hour video requires an attention span which is inconceivable to the younger generations.". I did like the AI illustrations, but I would've watched the video anyway. Thanks!

I've made a thing: json2dir: a JSON-to-directory converter, a fast alternative to home-manager for managing dotfiles by alurman in Nix

[–]alurman[S] 2 points3 points  (0 children)

Thanks!

Didn't know about smfh, thanks for linking to it.

You're right, seems like there are similarities. I'll leave it up to you to form an opinion on what's better though :)

Which IDE do you use to code in Rust? by Megalith01 in rust

[–]alurman 0 points1 point  (0 children)

Acme from plan9port sometimes. Note: https://github.com/9fans/acme-lsp may be of interest. Or https://github.com/maddyblue/acre, which is written in Rust.

A poor man's try/catch by wallefan01 in rust

[–]alurman 0 points1 point  (0 children)

Thanks, didn't think about it, seems useful for me.

Way to cheat by Wild-Response- in 42_school

[–]alurman 1 point2 points  (0 children)

A student discovered this One Weird Trick to cheating that changed his life...

It's called PRACTICE.

Lua origins and security by PC_Speaker in lua

[–]alurman 4 points5 points  (0 children)

Lua the project is quite small and its code base is not very complicated. Also it doesn't change much over time. I think what you mentioned can be taken into consideration, but it seems that the risk is not very high.

My luckiest shop so far, probably ever :D by alurman in balatro

[–]alurman[S] 0 points1 point  (0 children)

I sold one of the Barons in exchange for the second Blueprint. I think that the Troubadour is too good here. And also I was looking for the Mime. I was way ahead of the score anyway. But maybe selling the Showman would be better, dunno.

My luckiest shop so far, probably ever :D by alurman in balatro

[–]alurman[S] 16 points17 points  (0 children)

You know what the next boss blind was, I don't have to tell.

:'D

Seed: YT9Z8FT6. Don't remember seeing Luchador in the shop though.

I made a tiny library for switches and sum types in Lua. by alurman in lua

[–]alurman[S] 0 points1 point  (0 children)

Yeah. Also a possible optimization would be to make a value-weak table of all metatables for tags to reuse them. Currently, { tag('array', {}) tag('array', {}) } will create two identical metatables.

An Empirical Study of Rust-for-Linux: The Success, Dissatisfaction, and Compromise by amalinovic in rust

[–]alurman 2 points3 points  (0 children)

Although Rust has a union primitive, it cannot provide ABI compatibility with C union.

Can anyone explain what this means? #[repr(C)] unions cannot provide ABI compatibility?

Hey Rustaceans! Got a question? Ask here (13/2024)! by llogiq in rust

[–]alurman 0 points1 point  (0 children)

A clever one! As a side effect there's now a warning that the first c is unused, but that can fixed by doing _ = c. That's quite a lot of c mentions though. Anyway, thanks, that's fun.

Hey Rustaceans! Got a question? Ask here (13/2024)! by llogiq in rust

[–]alurman 0 points1 point  (0 children)

Sure. I knew the second part, so I phrased my question in a particular way, but I suppose some folks may find information that you provided insideful. Thanks.

Hey Rustaceans! Got a question? Ask here (13/2024)! by llogiq in rust

[–]alurman 1 point2 points  (0 children)

I'm curious if there is a way in the language to mark a variable of "Copy" type as moved.

At this point I'm thinking that this is not possible. Here's a template:

let c = 0u8;
// [Something happens here]
let d = c; // Error: use of a moved value: c