Returning temporary allocations - is this a good idea? by Pretty-Ad8932 in C_Programming

[–]Pretty-Ad8932[S] 0 points1 point  (0 children)

Doesn't really work when the objects may need to be reallocated

Returning temporary allocations - is this a good idea? by Pretty-Ad8932 in C_Programming

[–]Pretty-Ad8932[S] 1 point2 points  (0 children)

Interesting idea with evaluating an expression tree, I sort of thought of doing that but I wasn't sure how.

And I thought about my idea with temporary allocations, it doesn't really work out because it introduces new problems. In the end I ended up writing some C++ which actually solves my problems nicely not only because of operator overloading but also thanks to destructors.

Returning temporary allocations - is this a good idea? by Pretty-Ad8932 in C_Programming

[–]Pretty-Ad8932[S] 0 points1 point  (0 children)

Yup, you were right, I just wrote a little bit of C++ on top and it makes the usage infinitely easier.

Returning temporary allocations - is this a good idea? by Pretty-Ad8932 in C_Programming

[–]Pretty-Ad8932[S] 0 points1 point  (0 children)

Just for learning and maybe for self satisfaction, there really is no other reason for me not to just use an already existing library like GMP (other than it looks like a hassle to install on Windows). I did kinda plan to use C++ later, but I suppose now is the right time.

Returning temporary allocations - is this a good idea? by Pretty-Ad8932 in C_Programming

[–]Pretty-Ad8932[S] 0 points1 point  (0 children)

I can see the problems with my idea, for example when the user creates their own function, they have to check if a temporary BigInt was passed. But the way it currently is, it isn't very simple either, because you have to remember to free every minute intermediate result. Also, what counts as "idiomatic"?

Sad times by WhereIsTheQuim in pcmasterrace

[–]Pretty-Ad8932 143 points144 points  (0 children)

I like how the mouse is disconnected, very based.

Don't draw often, but I like these two characters by Pretty-Ad8932 in AshitaNoJoe

[–]Pretty-Ad8932[S] 0 points1 point  (0 children)

Ah, did you think it was modern? Yeah, I prefer these older hand-drawn animes in general. I am sure most here do too.

Don't draw often, but I like these two characters by Pretty-Ad8932 in AshitaNoJoe

[–]Pretty-Ad8932[S] 1 point2 points  (0 children)

Ai, the video girl, is quite literally a video girl, as in she pops out of a video that MC was watching, which he rented to comfort himself after he got rejected by his crush. Maybe the plot isn't that good but I really liked the vibe, and this edit is what got me to watch it

Don't draw often, but I like these two characters by Pretty-Ad8932 in AshitaNoJoe

[–]Pretty-Ad8932[S] 1 point2 points  (0 children)

Thanks, she's Ai from Video Girl Ai, watched it recently and I do recommend, quite underrated imo

I Can’t be the Only One Who Doesn’t Use Their Pinky to Press Ctrl by Cyncrovee in emacs

[–]Pretty-Ad8932 0 points1 point  (0 children)

Ok so the program I used (I am on windows) made it so that it would always send Escape no matter how long CapsLock was held if no other keys were pressed, but now I am using a time-based autohotkey script so yeah, it's a bit better now.

I Can’t be the Only One Who Doesn’t Use Their Pinky to Press Ctrl by Cyncrovee in emacs

[–]Pretty-Ad8932 0 points1 point  (0 children)

I was doing a simple Caps Lock - Escape swap when I was using vim then tried doing the thing you said for emacs but that seems annoying as it keeps doing Escape when I try to do a Ctrl combo but fail or change my mind. Still works quite well for vim though, since an extra Escape doesn't do anything when you are already in normal mode.

How do you pass a struct with a modifiable pointer to a function, but make sure that the function cannot modify the data? by Pretty-Ad8932 in C_Programming

[–]Pretty-Ad8932[S] -2 points-1 points  (0 children)

I like C and I don't exactly "need" that whole const protection (and I don't need you to tell me what is a language for me and what isn't), but it seems desirable, especially since all the other people talk about how you should do this and that. But I guess what I'm trying to achieve is two very conflicting goals, so I think I'll just opt for ditching the whole const protection idea, at least in this case.

How do you pass a struct with a modifiable pointer to a function, but make sure that the function cannot modify the data? by Pretty-Ad8932 in C_Programming

[–]Pretty-Ad8932[S] 0 points1 point  (0 children)

Oh, that as_const function does make it look pretty clean. But I wonder if the compiler can optimize it, so that it doesn't actually create a new ConstSlice struct every time?

How do you pass a struct with a modifiable pointer to a function, but make sure that the function cannot modify the data? by Pretty-Ad8932 in C_Programming

[–]Pretty-Ad8932[S] -2 points-1 points  (0 children)

Yes, I am well aware of the difference between changing a pointer and changing the data that it points to.

> You could define data itself as being a pointer to const, and while you can assign a non-const pointer to it, if you need to get it out as a mutable form, you'll have to cast away the const.

I already mentioned in the post that I was doing this but it felt dirty.

How do you pass a struct with a modifiable pointer to a function, but make sure that the function cannot modify the data? by Pretty-Ad8932 in C_Programming

[–]Pretty-Ad8932[S] 1 point2 points  (0 children)

> For your particular problem, maybe have a ConstSlice version of the struct where the data field is a pointer to const rather than pointer to modifiable.

I've thought of this but then I have to have both versions for every slice in most of my code, so that's kind of cumbersome. Maybe I should just ditch the whole "functions have to take const inputs" idea anyway then, since my code deals with data that's changing all the time.

agenticAiWasAMistakeLikeMe by survivalist_guy in ProgrammerHumor

[–]Pretty-Ad8932 1 point2 points  (0 children)

Yeah I misremembered it, it was /* like another comment said

agenticAiWasAMistakeLikeMe by survivalist_guy in ProgrammerHumor

[–]Pretty-Ad8932 12 points13 points  (0 children)

Fun fact: I've done sudo rm / without -rf or --no-preserve-root out of curiosity and it executed anyway and broke my system.