[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

Is C functional or object-oriented?

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 17
Thread images: 1

Is C functional or object-oriented?
>>
>>55005199
hardly functional
>>
>>55005199
Neither. It's procedural.
>>
No.
>>
>>55005203
you see that's kind of funny because in french "functional" kind of translates to "does work",
so it's a cool way of saying that C "hardly works" but using a programming paradigm way
>>
high functioning autistic
>>
>>55005199
Both.

>functional
https://lucabolognese.wordpress.com/2013/01/04/functional-programming-in-c/

>OO C
https://www.cs.rit.edu/~ats/books/ooc.pdf
>>
>>55007376
Same as in any language. FP fags simply hijacked the word.
>>
>>55005199
It's traditionally viewed as within the imperative camp
>>
>>55007376
In French oop is poo
>>
>>55005199
can it do this
let (^) x y = pown y x

let fs = List.map
let f1 = (*) 2
let f2 = (^) 2
let fsf1 = fs f1
let fsf2 = fs f2

printfn "%A" (fsf1 [0; 1; 2; 3])
printfn "%A" (fsf1 [2; 4; 6; 8])
printfn "%A" (fsf2 [0; 1; 2; 3])
printfn "%A" (fsf2 [2; 4; 6; 8])


[0; 2; 4; 6]
[4; 8; 12; 16]
[0; 1; 4; 9]
[4; 16; 36; 64]
>>
>>55007904
Of course not nearly as flexible (C++ has far more support with std::bind and with std::function and of course lambdas)

#include <stdio.h>
#include <stdlib.h>

typedef int (*func_t)(int, int);

typedef struct {
func_t func;
int arg;
} bound_t;


bound_t* bind(func_t func, int arg)
{
bound_t* bound = malloc(sizeof(bound_t));

bound->func = func;
bound->arg = arg;

return bound;
}


void unbind(bound_t* bound)
{
free(bound);
}


void map(size_t count, int* list, const bound_t* bound)
{
if (bound->func != NULL)
{
for (size_t i = 0; i < count; ++i)
{
list[i] = bound->func(list[i], bound->arg);
}
}
}


void print(size_t count, int* list)
{
for (size_t i = 0; i < count; ++i)
{
printf("%d ", list[i]);
}
printf("\n");
}


int multiply(int a, int b)
{
return a * b;
}


int power(int a, int b)
{
int x = 1;

while (b > 0)
{
x *= a;
--b;
}

return x;
}


int main()
{
int list1[] = { 0, 1, 2, 3 };
int list2[] = { 0, 1, 2, 3 };

bound_t* f1 = bind(multiply, 2);
bound_t* f2 = bind(power, 2);

print(4, list1);
map(4, list1, f1);
print(4, list1);

print(4, list2);
map(4, list2, f2);
print(4, list2);

unbind(f2);
unbind(f1);
return 0;
}

>>
>>55007376
>>55007845
That's all deliberate. The FP shills in the 70s were trying to use "functional" as a marketing tool, but it backfired so badly due to the poor quality, complexity, and uselessness of functional languages that calling your language "not functional" was considered a good thing.

That's not the only word they hijacked either. Another synonym they used was "applicative" which means "Having practical application; applicable." That also backfired so they switched to using "functional."

Some antonyms of "functional" are impractical, useless, worthless, and broken, which happen to describe "functional" languages a lot better than "functional" does.
>>
>>55008869
I'm working on a better version now, stay tuned.
>>
>>55005199
Procedural faggot
>>
>>55009477
Functional fags on suicide watch
>>
>>55005251
This senpai.
Thread posts: 17
Thread images: 1


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.