169 похожих чатов

Every now and then I remember that C has function

pointers and I just wonder why. It’s like the least ergonomic language feature I think I’ve ever seen, and never once have I seen them used without it feeling like a super alien kludge. I’d use flag bit packing bullshit too if function pointers were the option I had for injecting one function into another.

And like they’re this obnoxious to use and yet they have to be a designed feature right? It’s not obvious that you should be able to address a function, and there’s specific syntax for it, so someone must have sat down at some point and said “yes, this is how function pointers should work”

10 ответов

13 просмотров

Why is it unergonomic? And why is it unobvious that functions should be addressable

callbacks ig?

Thomas
Why is it unergonomic? And why is it unobvious th...

i understand the hate for asterisks, assembly uses square brackets for pointers and honestly its way easier to comprehend visually at first

Thomas
Why is it unergonomic? And why is it unobvious th...

im not a c dev but i think that's the only way to use callbacks, right?

demon with L
im not a c dev but i think that's the only way to ...

Well a callback must be passed as an argument

Lanny- Автор вопроса
Thomas
Why is it unergonomic? And why is it unobvious th...

The syntax is p funky imo, I mean you need something but why the extra parens? Why the asterisk on the identifier and not after the arg list? That’s mostly a taste thing but it does feel kludgy compared most the rest of the language and it’s something I always have to look up. More substantially, you can’t dereference a function pointer and expect anything meaningful to result, so the most fundamental operation of a pointer is basically unused. Pointer arithmetic doesn’t really work either, since depending on architecture a function pointer is not necessarily in the same address space as data. So I guess my complaint is that a function pointer is basically not a pointer, imo defining an opaque func_t or something and an apply function or built in would have been preferable

Lanny
The syntax is p funky imo, I mean you need somethi...

You'd love learning about execution tokens in Forth

Lanny
The syntax is p funky imo, I mean you need somethi...

Syntax stuff I was expecting, but the pointer operation stuff makes sense too

Lanny
The syntax is p funky imo, I mean you need somethi...

I guess you could have a separate "function address" type entirely

Похожие вопросы

Обсуждают сегодня

Господа, а что сейчас вообще с рынком труда на делфи происходит? Какова ситуация?
Rꙮman Yankꙮvsky
29
А вообще, что может смущать в самой Julia - бы сказал, что нет единого стандартного подхода по многим моментам, поэтому многое выглядит как "хаки" и произвол. Короче говоря, с...
Viktor G.
2
30500 за редактор? )
Владимир
47
а через ESC-код ?
Alexey Kulakov
29
Чёт не понял, я ж правильной функцией воспользовался чтобы вывести отладочную информацию? но что-то она не ловится
notme
18
У меня есть функция где происходит это: write_bit(buffer, 1); write_bit(buffer, 0); write_bit(buffer, 1); write_bit(buffer, 1); write_bit(buffer, 1); w...
~
14
Добрый день! Скажите пожалуйста, а какие программы вы бы рекомендовали написать для того, чтобы научиться управлять памятью? Можно написать динамический массив, можно связный ...
Филипп
7
Недавно Google Project Zero нашёл багу в SQLite с помощью LLM, о чём достаточно было шумно в определённых интернетах, которые сопровождались рассказами, что скоро всех "ибешни...
Alex Sherbakov
5
Ребят в СИ можно реализовать ООП?
Николай
33
https://github.com/erlang/otp/blob/OTP-27.1/lib/kernel/src/logger_h_common.erl#L174 https://github.com/erlang/otp/blob/OTP-27.1/lib/kernel/src/logger_olp.erl#L76 15 лет назад...
Maksim Lapshin
20
Карта сайта