Похожие чаты

Do u call the use of “void*” polymorphism? If u

know what I mean.

21 ответов

71 просмотр

Definitely not. Polymorphism happens when the compiler does stuff for you under the hood and you as a developer just have to understand the idea of it to get it to work. Use of void* on the other hand requires you as a developer to write the code yourself and also understand the idea of polymorphism to get it to work right.

It can be *part of* polymorphism I guess

VD
Definitely not. Polymorphism happens when the comp...

polymorphism is still polymorphism when done manually

Mahdi- Автор вопроса
Thomas
It can be *part of* polymorphism I guess

How’d u define polymorphism in C/Cpp?

Mahdi- Автор вопроса
Mahdi
Psudocode?

struct MyInterface { void *data; void (*doThing)(void *); } x->doThing(x->data);

Mahdi- Автор вопроса
Mahdi
This is exactly what I had in mind

with bounded you can use a tagged union

Mahdi- Автор вопроса
Thomas
with bounded you can use a tagged union

Not sure what u mean by bounded

Mahdi
Not sure what u mean by bounded

How many possible different kinds of things are there?

Mahdi- Автор вопроса
Mahdi- Автор вопроса
Mahdi
How many different types you mean?

This can be like: "4" "I'll add like 10-ish, but I'll know at compile time" "It's a plugin system, so it's only known at runtime, however many plugins the user needs to load"

I call it downcasting.

Thomas
polymorphism is still polymorphism when done manua...

Polymorphism as a concept defines subtyping which by definition is not something that is allowed in C. So you can't then say using void* pointers to simulate subtyping is polymorphism in the strictest sense. As long as a language does not support subtyping, it can't be called polymorphism. Moreover using void* pointers to cast from one type to another unrelated type is Undefined Behavior according to the C standard. So even if you see the behavior you expect on your implementation, it is not guaranteed to happen across all implementations. So this behavior is indeed undefined behavior and is therefore no where close to the idea of polymorphism

VD
Polymorphism as a concept defines subtyping which ...

But you're never casting from one type to another

VD
Polymorphism as a concept defines subtyping which ...

https://en.m.wikipedia.org/wiki/Polymorphism_(computer_science)

Thomas
https://en.m.wikipedia.org/wiki/Polymorphism_(comp...

I'm not talking about subtype polymorphism

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

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

Господа, а что сейчас вообще с рынком труда на делфи происходит? Какова ситуация?
Rꙮman Yankꙮvsky
29
А вообще, что может смущать в самой Julia - бы сказал, что нет единого стандартного подхода по многим моментам, поэтому многое выглядит как "хаки" и произвол. Короче говоря, с...
Viktor G.
2
@Benzenoid can you tell me the easiest, and safest way to bu.y HEX now?
Živa Žena
20
This is a question from my wife who make a fortune with memes 😂😂 About the Migration and Tokens: 1. How will the old tokens be migrated to the new $LGCYX network? What is th...
🍿 °anton°
2
30500 за редактор? )
Владимир
47
а через ESC-код ?
Alexey Kulakov
29
What is the Dex situation? Agora team started with the Pnetwork for their dex which helped them both with integration. It’s completed but as you can see from the Pnetwork ann...
Ben
1
Гайс, вопрос для разносторонее развитых: читаю стрим с юарта, нада выделять с него фреймы с определенной структурой, если ли чо готовое, или долбаться с ринг буффером? нада у...
Vitaly
9
Anyone knows where there are some instructions or discort about failed bridge transactions ?
Jochem
21
@lozuk how do I get my phex copies of my ehex from a atomic wallet, to move to my rabby?
Justfrontin 👀
11
Карта сайта