Quantcast
[ 3 / biz / cgl / ck / diy / fa / g / ic / jp / lit / sci / tg / vr / vt ] [ index / top / reports / report a bug ] [ 4plebs / archived.moe / rbt ]

Due to resource constraints, /g/ and /tg/ will no longer be archived or available. Other archivers continue to archive these boards.Become a Patron!

/g/ - Technology


View post   

[ Toggle deleted replies ]
File: 111 KB, 600x800, 1502554078961.png [View same] [iqdb] [saucenao] [google] [report]
61875133 No.61875133 [Reply] [Original] [archived.moe] [rbt]

What are you working on, /g/?

Previous thread: >>61868339

>> No.61875159

>>61875133
Anyone built something with Haskell, if so what was it?

>> No.61875169

>>61875159
I think Idris was made in Haskell

>> No.61875185

>>61875159
Nothing practical has ever been nade in Haskell. Only academic circlejerk projects.

>> No.61875195
File: 44 KB, 636x616, 1474325315193.jpg [View same] [iqdb] [saucenao] [google] [report]
61875195

Employed Haskell programmer reporting in

>> No.61875210

>>61875195
So, how are you finding the latest JS framework?

>> No.61875270

>>61875133
stop using that image
you're scaring the children

>> No.61875286
File: 139 KB, 470x545, dlang_chan.jpg [View same] [iqdb] [saucenao] [google] [report]
61875286

Germany loves dlang-chan!
https://dlang.org/blog/2017/07/28/project-highlight-funkwerk/

>> No.61875287

splitvalue = *(&(&tp->v0 + tv)->x + axis);

Is this acceptable to you?

>> No.61875293

>>61875133
Variety is the spice of life, OP. You, on the other hand, are Miracle Whip spread on Wonder Bread.

>> No.61875316

>>61875287
no

>> No.61875419

>>61875195
What do you do?

>> No.61875520
File: 358 KB, 2238x1168, Screen Shot 2017-08-12 at 6.28.22 PM.png [View same] [iqdb] [saucenao] [google] [report]
61875520

Trying to wrap my head around how C handles headers.

Pic related is my setup for an implementation of linked lists. However, when I try printing the value of "p->Next", I get the following error (gcc)
Test_Poly.c:12:41: error: incomplete definition of type 'struct Node'
printf("Address of p->next: %d\n", p->Next);
~^
./Polynomial_List.h:3:8: note: forward declaration of 'struct Node'
struct Node;


Why is this happening? Don't I include the header file, which specifies how Node should be built?
Using the following gcc command to compile:
gcc Polynomial_List.c Test_Poly.c

>> No.61875596

>>61875520
either say
export struct node;
in the header
or just define it in header fully

i think that would work

>> No.61875619

>>61875520
Can you please show the filenames of all the files you included

The top right header file just declares the existance of the struct Node, but doesn't declare what fields it has. The bottom right header file declares what fields it has.
In order to use fields such as ->Next, you need to include the bottom right file, and in order to use those functions you need to include the top right file.

>> No.61875656

>>61875619
nigga the file on the left includes the header
and he compiles both of the .cpp files
use your eyes

>> No.61875675

>>61875656
Okay so the bottom right file is a .c file but that's wrong, it needs to be a header file that the left file includes.

The key takeaway here is that compiling multiple C files at once is the same as compiling them seperately. So if you were to just say
gcc Test_Poly.c -c
then it has no way of knowing what ->Next is. So you need to tell it that information by declaring it in a header

>> No.61875728
File: 552 KB, 2612x1420, Screen Shot 2017-08-12 at 6.44.41 PM.png [View same] [iqdb] [saucenao] [google] [report]
61875728

>>61875619
Yeah sorry.

Left file is "Test_Poly.c"
Top right is the header file Polynomial_List.h
Bottom right is the implementation file Polynomial_List.c

>>61875675
I'm thinking of ways I can include both the implementation and header files, but I'm worried that might lead to duplicate symbols and leading to compiler errors

Not sure if this helps, but when I
#include "Polynomial_List.c"

int the left file, I get linker errors (duplicate symbols errors for the functions defined)

>> No.61875756

>>61875675
>it needs to be a header file that the left file includes.
but that's wrong
>>61875728
you're getting duplicate symbol errors because the poly-lists header should have a
#define Polynomial_List_H
right after the #ifndef
right now that #ifndef never does anything

>> No.61875773

>>61875728
pretty sure you want to do something like this:

https://en.wikipedia.org/wiki/Opaque_pointer

either define functions to return the inner values required or expose the struct definition in the header file

>> No.61875778

>>61875728
Don't include the header. There's no reason to have a header file anon. This isn't sepples. You only need header files when you are thinking about an interface and then you'll link against the .o file not the .c file.

>> No.61875799

>>61875728
Functions get compiled into assembly code, and if the same function gets compiled twice (which is what happens when you #include the .c file) then you get a linker error.

However, struct declarations are not compiled into anything. As long as each c file sees the same definition of a struct, you're good to go.
examples:

// a.c
void foo() {}

// b.c
void foo() { printf("yikes"); }

result: LINKER ERROR

// a.c
struct thing {
int x;
};

void foo(struct thing) { printf("x = %d\n", thing.x); }

// b.c
struct thing {
int x;
};

void foo(struct thing); // note: this is a DECLARATION not an IMPLEMENTATION

void bar() {
struct thing;
thing.x = 4;
foo(thing);
}

result: x = 4 (GOOD)

// a.c
struct thing {
int x;
};

// b.c
struct thing {
double y;
};

result: this compiles, but is undefined behavior since a.c and b.c see different versions of struct thing. never do this.

>> No.61875843
File: 786 KB, 2954x1522, Screen Shot 2017-08-12 at 6.53.25 PM.png [View same] [iqdb] [saucenao] [google] [report]
61875843

>>61875756
Alright... I should have seen that coming, but unfortunately I don't think that did anything (see pic related)

>>61875778
I want to include header files because it makes it easier to organize imo.

>>61875799
>As long as each c file sees the same definition of a struct, you're good to go
But don't I do this? I have a declaration of a struct, and define it in an implementation file.

>> No.61875866

>>61875843
Each C file needs to see the definition of a struct. The only way it can "see" it is by having it be inserted into the file.

// a.c
struct thing { int x; }

// b.c
// note: does not #include anything
void foo() {
struct thing t.
printf("%d\n", t.x);
}


$ gcc a.c b.c
ERROR: b.c doesn't "see" the definition of the struct, so it doesn't know that the field .x exists

>> No.61875869

>>61875159
xmonad was built in haskell
>>61875185
it was heavily used in the corporate world as a fast, safe language before java and C++ came into the picture.

>> No.61875876

>>61875843
>But don't I do this?
i think the test-poly still sees the undefined struct, might be wrong

you should really be defining structs in the header, not in the .c file

>> No.61875893

>>61875869
>

>> No.61875917

>>61875843
Not the same anon but you just need to put the struct definition in the header, basically instead of this:

struct Node;


Put this:

struct Node
{
int Coefficient;
int Exponent;
struct Node* Next;
};


And then get rid of the definition in the .c

>> No.61875926

>>61875520
The header defines a function the name of which should point somewhere. That somewhere would be a library file linked to your program.

Basically the header file does nothing but to announce the existence of the function, alone it's worthless. The library/binary file the function is in (if it's not called from the file itself) defines what the function is.

So for example #include <stdio.h> will bring in symbols from stdio, therefore tell (promise to) your program that the function printf (and every other in stdio) exists. Doing -lc when compiling (often done by default by your compiler) will have the program call the libc library in which it will find the actual printf function.

>> No.61875929

Netbeans-Cpp IDE is pretty comfy.

>> No.61875952

>>61875869
>xmonad
>Pure and innocent window manager written in 1.2 kLOC.
>Built on top of the heaping garbage fire known as X11.
It hurts.

>> No.61875953
File: 709 KB, 2788x1498, Screen Shot 2017-08-12 at 7.05.11 PM.png [View same] [iqdb] [saucenao] [google] [report]
61875953

>>61875866
I moved the definition of Node to the header file... Never thought I'd be so happy to get a seg fault!

Many thanks to everyone!

>> No.61875980

>>61875953
any day lad

>> No.61875984

>>61875953
what in the world are you editing text with? This looks like software from the 90's that was ported to cocoa, and it looks even worse than acme.

>> No.61876012

>>61875984
Emacs... So exactly what what you described.

On an unrelated note, anyone know why the value of p-> Next changes between a function call?

void Initialize(Polynomial p)
{
p = (struct Node*) malloc( sizeof(struct Node));
p->Next = NULL;
printf("Printing P->NEXT: %d \n", p->Next);

}


int main()
{
Polynomial p;

Initialize(p);
printf("Address of p: %d\n", p);
printf("Address of p->Next: %d\n", p->Next);
}


And output is below:
Printing P->NEXT: 0 /* In function Initialize(p) */

/* In main */
Address of p: 136380470
Address of p->Next: -1991765899

>> No.61876013

>>61875984
looks like some type of vim application

>> No.61876043

>>61876012
functions only change the inputted values locally
if you want to change p's value use a pointer
pass the function &p and use it in the function as p*

>> No.61876049

Rate my 7th C++ program
#include <iostream>
#include <string>
using namespace std;

enum class monster_t {
ogre,
orc,
dragon,
giant_spider,
slime
};

struct monster_detail {
string name;
int health;
};

struct monster {
monster_t type;
monster_detail detail;
};

string get_type_string(monster_t m)
{
switch (m) {
case monster_t::dragon: return "dragon";
case monster_t::giant_spider: return "Giant spider";
case monster_t::ogre: return "ogre";
case monster_t::orc: return "orc";
case monster_t::slime: return "slime";
}
}

void print_monster(monster m)
{
cout << "This "
<< get_type_string(m.type)
<< " is named "
<< m.detail.name
<< " and has health value: "
<< m.detail.health << endl;
}

int main()
{
monster T{
monster_t::ogre,
{"Torg", 120}};
print_monster(T);
return 0;
}

>> No.61876055

>>61875929
nice to hear

>> No.61876076

>>61876049
are you going through a game development book?

>> No.61876079

>>61875316
You have no taste anon. Code like that is the only reason I still bother with this crap.

>> No.61876087

>>61876076
Nope, it's http://www.learncpp.com/
Pretty nice resource if you ask me

>> No.61876088

>>61876043
Oh duh...

I guess I just forgot about this because I was working with pointers and assumed I could change values will-nilly

>>61876049
My only concern is that it's not very prone to being expandable (what if you had 100 monster types? A gargantuan switch/case statement isn't exactly something you would want to type out)

I recommend having an array of structs and a file for monster names... But not really into game development (yet) so take my concern with a grain of salt

>> No.61876090

>>61876049
2/10
all pretty silly
it would be smarter to have a map that maps strings of monster names -> structs of monster stats

>> No.61876139

>>61875952
>not creating a pure Linux opengl es context by using generic buffer manager and kernel mode setting
>not creating your own hardware accelerated graphics
>not grabbing input directly from evdev

>> No.61876142

>>61876087
i'm not a game dev but to me it seems like it'd be better organized if you make a class for every monster than inherits from the monster class. also, if you're not trying to do OOP stuff don't try to learn cpp

>> No.61876172

>>61876139
This kind of shit is why I'm not productive in Linux. I end up fucking with the env endlessly instead of working.

>> No.61876177

We need a pastebin.

>> No.61876181

found an old fizzbuzz i wrote a few years ago. what was i thinking

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

#define Oo 100ULL
#define __(oo,oO)\
for (o=(Oo*(oo)>>(oO));o<=Oo;o+=(Oo*(oo)>>(oO)))OO ++[O]

int _o(const void *o, const void *O) { return
((*(uint64_t*)o) >> 48) > (uint64_t)(*((char*)O + 6)) ;}

int main(void)
{
uint64_t oo, oO, o, O [Oo * 0x1bbbbbbbd4 >> 36], OO = 0;

__(0x3e0f83e1ull, 35) = (o << 060) | 2054842694;
__(0xcccccccdull, 36) = 0x7a7a7542 | (o << 48);
__(0xa57eb503ull, 38) = (uint64_t)0xff << 36 | (o << 0x30)
| ((o + 0x30 - 10 * (o * 205 >> 11)) << 010)
| (((0x1999999a * o >> 32) + 0x30)); qsort(

O, OO, sizeof(0[O]), _o);
for (o =0;o <OO;o ++) {
oO= o[O] >> 060; oo =o;
while (!(oO^ (o [O]>>48)) && (o [O]&16711680))
printf("%s", (char*)&o ++[O]);
printf(!(o ^oo) ? "%s\n" : "\n", (char*)&o [O]);
} return

0;
}

>> No.61876217

>>61876177
What should be on it?

>> No.61876224

>>61876172
But that's the purpose of Linux, of programming. Making programs for other people is for idiots. Do it for yourself

>> No.61876258
File: 1.82 MB, 1920x1080, terrain.png [View same] [iqdb] [saucenao] [google] [report]
61876258

>>61874357
>>61874664
>>61874691

>>61876065

>> No.61876352

>>61876049
If you're dispatching on type (in your case the big switch statement) you should consider a polymorphic approach instead.

>> No.61876354

>>61876224
Nigga I'm lazy. I have work to do unrelated to my environment, and I generally would like to get that work done. The problem with Linux is sharpening that particular axe is alluringly straightforward, so if I don't check myself I end up grinding metal for hours instead of just chopping the fucking tree down. As weird as it sounds, knowing nothing about how the dev tools I'm using work under the hood leads to far greater productivity for me.

>Making programs for other people is for idiots.
That's pretentious as fuck. I write code for people who can't, but will pay me for my efforts. In turn I pay contractors, attourneys, doctors, etc. for services I need but don't have the time to become an expert on. Eventually you'll need to pay for someone to do something you can't. That doesn't make then superior to you, and you knowing how a computer works doesn't make you superior to others.

>> No.61876365

>>61875953
If you don't want to define Node in the header, you could also have used a function (inside the header) that took a struct Node pointer and returned the next of it. That's why the error existed. The struct definition was hidden inside the implementation, so the compiler doesn't know how to dereference it in main.

>> No.61876375

>>61876142
>inheritance
lol

>> No.61876380
File: 479 KB, 800x600, terrain.png [View same] [iqdb] [saucenao] [google] [report]
61876380

>>61876258
Innovation! This new version allows the dividing planes to not be positioned perfectly at the center of the sphere. This means that elevation changes won't be forced into symmetry at antipodes.

>> No.61876395
File: 1.19 MB, 1127x1600, trap-programming.png [View same] [iqdb] [saucenao] [google] [report]
61876395

>>61875953
Next time you're having problems, try wearing some thigh-highs and girl clothes. They always help me solves any issues in my programs.

>> No.61876465

>>61876217
RTFM and Google for Retards

>> No.61876472

Memes

>> No.61876489
File: 999 KB, 1920x1080, terrain.png [View same] [iqdb] [saucenao] [google] [report]
61876489

>>61876380
1920x1080, fewer slices

Elevations:
Magenta: Z < -2
Blue: -2 < Z < -1
Cyan: -1 < Z < 0
Green: 0 < Z < 1
Yellow: 1 < Z < 2
Red: 2 < Z

>> No.61876504
File: 971 KB, 1920x1080, elevation.png [View same] [iqdb] [saucenao] [google] [report]
61876504

>>61876489
Where Z = (pixel's elevation minus mean elevation of all pixels) / standard deviation of all pixels' elevations, of course.

>> No.61876508

>>61876049
>>61876352
>>61876142
These are correct responses

>>61876088
This is not

>>61876375
this guy is just being edgy

There are good arguments to me made against OOP but "lol inheritance" is not one of them.

>> No.61876541

>>61876012
EVERYTHING in C is PASS-BY-VALUE. Which is why you pass pointers to stuff to save your results outside a function. You pass-by-value a pointer so that when you dereference it the memory pointed at is the same.

Polynomial Initialize()
{
Polynomial p = (struct Node*) malloc( sizeof(struct Node));
p->Next = NULL;
printf("Printing P->NEXT: %d \n", p->Next);
return p;
}


void Initialize(Polynomial *x)
{
Polynomial p = (struct Node*) malloc( sizeof(struct Node));
p->Next = NULL;
printf("Printing P->NEXT: %d \n", p->Next);
*x = p;
}

>> No.61876548

>>61876508
Isn't multiple inheritance the feature that's looked upon with disdain? And if I recall correctly, C++ is the only major OOP player that supports it.

>> No.61876568

>>61876548
Inheritance in general is viewed in a far more negative light than it used to be.

Extending functionality in a way that doesn't require dynamic dispatch is done with mixins or composition.

Dynamic dispatch is the only reason to model with inheritance, and it's not a very good one with today's languages.

>> No.61876628
File: 36 KB, 1116x244, Screen Shot 2017-08-12 at 8.08.06 PM.png [View same] [iqdb] [saucenao] [google] [report]
61876628

>>61876541
Thanks!! I kind of completely forgot about pass by value (because I'm kind of used to pass-by-reference in sepples)

Everything works now! I even made an addition function!

>> No.61876667

is there like a cheatsheet for common/useful methods/imports (in java)?

ive done c++/c# for a few years now as its the standard at my school and while learning java im having trouble thinking of the useful methods i could use instead of doing everything manually.

stuff like string.replace() is super basic but i was doing that shit manually with loops for too long before realizing it was a thing.

>> No.61876670
File: 3.23 MB, 3840x2160, terrain indexed.png [View same] [iqdb] [saucenao] [google] [report]
61876670

>>61876504
Simple worldbuilding...
>Magenta/blue/cyan: Ocean
>Green: Continental shelf
>Yellow: Habitable land
>Red: Uninhabitable mountains/plateaus

In this 4k image, we have one big continent, composed of a big landmass, a small landmass, and a bunch of smaller islands. The continent technically extends underneath the northern ice cap, and there are a few undiscovered islands (yellow dots in the upper-left area of this picture), since the people living on the bigger landmasses haven't yet invented ocean travel.

>> No.61876682

>>61876548
A lot of people criticize multiple inheritance, whether or not that's fair is up for debate. Python also supports multiple inheritance. Java classes may implement multiple interfaces which is sorta like multiple inheritance.

But what we're talking about here is _not_ multiple inheritance. Multiple inheritance is when one class can have multiple parent classes. In this situation we're talking about one parent having many subclasses, which is considered perfectly fine among people who are into OOP.

There's a growing but still certainly minority opinion that inheritance in general is "bad". This is a position that's come out of seeing people abuse inheritance and a few vocal high-profile language designers advocate "composition over inheritance" which is not a blanket dismissal of inheritance but a statement that inheritance is not the solution to every situation where you want to reuse code.

>> No.61876698

>>61876667
Usually when I'm using a language I'm not sure familiar with, I scoure the documentation for something I want and if I don't find it very quickly I'll write it myself.

>> No.61876739

>>61876698
The java documentation is absolutely fucking garbage because you have to go to the parents of the parent of the grandparents to see wherever the fuck a method exists and its signature. Just google shit and you more likely than not find a solution with an example on stack overflow from people tired of the same garbage.

>> No.61876752

>>61876739
This is one reason why I love Racket, it has absolutely excellent documentation that makes it very easy to find out how something is supposed to be used and find related functions for the same kind of data.

>> No.61876762

>>61876548
multiple inheritance is if you had "Slime" inherit from "Monter" and also from "DungeonCritter". what i described isn't multiple inheritance

>> No.61876771

>>61875133
If I had to devote my energy to learning a language that will get me employed between clojure and Haskell, what do you recommend?

>> No.61876776

redpill me on rust /g/

>> No.61876783

>>61876771
Clojure will get you employed. As a Haskell lover who doesn't really have any interest in Clojure I still acknowledge that it has more applications in webdev jobs and the such

>> No.61876789

>>61876771
if you only know clojure and haskell it seems you're oriented towards app development, so java

>> No.61876799

>>61876682
>>61876762
Yes, I know. Jesus christ. The implication of my question was to clarify whether or not the anon who laughed at inheritance was referring to single or multiple variety. Please read more carefully before replying.

>> No.61876818

>>61876776
Rust is a meme. Improve yourself at C. Unless you want to waste time fighting the borrow and the lifetime checker and putting "unsafe" before writing C.

>> No.61876846

>>61876818
I've been using rust for a few days now and I only ever fought the borrow checker once; it seems more than obvious how it works, does it not?

>> No.61876863

>>61876846
Not for C weenies

>> No.61876894

>>61876818
>>61876846
I should also mention that it's very difficult to write C that does lots of buffer manipulation, whereas writing Rust that does so is trivial. So much so that it's easier to write Rust that does the heavy lifting and export unsafe C bindings.

>> No.61876897

>>61876846
It is. That's how you write C that doesn't segfault. No training wheels required.

>> No.61876910

>>61876818
Rust is fine for its purposes. I still use C heavily but that is mainly when doing embedded and other no-allocation based stuff.

I've written >10K+ lines of rust and haven't needed to use unsafe once at all. The borrow checker and all that isn't too big a deal I don't think, and I'd just advise people to make unnecessary clones when they start of to ease in to it.

The big boon to productivity for me is that it prioritizes performance in a way which I won't be stuck at some point in the future at some wall where I may otherwise be with something like python. That and the fact that libraries and the like are so much easier to use which makes it much easier for less low-level things like api-servers and the like.

There are some things I don't really like using it for but in general, it makes you feel confident in the small details and lets you focus on the actual program logic.

>> No.61876912

>>61876897
If Rust was just C with a borrow checker, I wouldn't use it.
If Rust was C++ with a borrow checker, I still wouldn't use it.

>> No.61876915

>>61875133
C# is such an incredible language with an incredible IDE Loving it so far.

>> No.61876955

>>61876910
I've found it most comfortable to use a hybrid approach: Rust staticlib for high level code, compiled together with C to start and do certain syscalls

>> No.61876957

>>61876739
>The java documentation is absolutely fucking garbage because you have to go to the parents of the parent of the grandparents to see wherever the fuck a method exists and its signature
Inherited methods are listed on every doc page, is clicking one link really that hard for you?

>> No.61876972

>>61876799
How the fuck does

> Isn't multiple inheritance the feature that's looked upon with disdain? And if I recall correctly, C++ is the only major OOP player that supports it.

imply

> clarify whether or not the anon who laughed at inheritance was referring to single or multiple variety

you illiterate shit?

>> No.61876987

>>61876972
he probably just learned what multiple inheritance is recently and wanted to use it in conversation. be easy on him

>> No.61877077

>>61876972
Because it's written according to the rules of the English language, and if you knew English you'd be able to correctly comprehend its meaning. As such, calling me an "illiterate shit" shows me the dire severity of your ignorance. Are you an ESL pleb?

>> No.61877208

>>61877077
Wrong, here's a list of the things >>61876548 implies:
- You're unsure of how multiple inheritance is viewed
- As far as you know C++ is "only major OOP player that supports it" (which is wrong)
- You're asking for clarification on how multiple inheritance is viewed

Nothing in that post implies it was a question directed at >>61876375 , nor is there any mention of single inheritance.

Points though, for calling me an ESL pleb when you can't figure out what your own post means

>> No.61877278

how do I make my own proglang

>> No.61877376

>>61877278
assuming proglang is short for programming language
write a parser + compiler/interpreter

that's it
implementing a basic scheme implementation for example is easy as fuck
all you really need are:
define
lambda
cond
if
else
and
or
quote
inc
dec
cons
cdr
car
null?
number?

and a few other things I'm forgetting
most of the other scheme functions can be defined in terms of the above
+ is just repeated inc
* is just repeated +
let is just a lambda
etc....

>> No.61877413

>>61877376
how do I write a Lisp sexp parser?

>> No.61877435
File: 145 KB, 800x533, t3_6diw4m.png [View same] [iqdb] [saucenao] [google] [report]
61877435

>>61875133
working on banging ur mom lol

>> No.61877468

>>61875133
I've just learned that I can put a static array inside a struct, so I can copy the entire array with only one assignment.
Pretty cool trick!

>> No.61877470

>>61877413
I'm not going to spoonfeed you
go see how others do it
go look into parsing in general
google it for fucks sake

you'll learn nothing if I tell you everything

>> No.61877490

>>61875133
It is nice that whoever made this image thinks "backend" and "web development" are two different categories and that "backend" belongs with "scripting".

>> No.61877501

>>61877468
in what case would this be helpful?
if you're passing to a function you're already copying, that's just how functions work
if you're not passing to a function and you're just working with it, why copy it
what use cases does this help exactly?

>> No.61877506

Wrote dependency resolution algorithm using preorders. The time complexity is probably terrible but it works well (and in this case n is usually small)
It's fairly elegant

;; evaluate a preorder using reflexivity + transitivity
(define (dep<=? p1 p2) (dep>=? p2 p1))
(define (dep>=? p1 p2)
(or (equal? p1 p2)
(ormap (λ (p1-) (dep>=? p1- p2))
(hash-ref preorders p1 null))))

;; sort paths by preorder and return corresponding asts
(map cdr (sort asts dep<=? #:key car))

>> No.61877519

>>61877490
the entire thing was made ~4 threads back for the sole purpose of pissing people off

the guy that made it used it as the OP image for the last 3 threads

>> No.61877544

>>61877519
>>61877490

The only reason people have deviated from the old yuki image was pissing people off. I still remember the dpt image wars

>> No.61877598

>>61877501
arrays aren't copied when passed to functions

>> No.61877603

>>61877413
Literally the easiest parser there is. Start with an empty list and read each symbol.

Open paren -> create new list, append to parent, this is now the current list
Close paren -> append the current list to the parent list. Parent list is now the current list
any other symbol -> append it to the current list

Fun fact: for reasons of tradition lisp parsers are generally called "readers"

>> No.61877637

>>61877468
Seems wierd unless you knew what the largest such array could ever be or every such array had the same number of elements.

>> No.61877646

Should I proceed with CS degree or math degree if I want to work in crypto?

>> No.61877654

>>61877603
do you know of a lisp reader example written in C?

I've created s-exp readers in dynamic languages before but it's much, much easier there due to the ease of string manipulation

>> No.61877671

>>61877646
Do both. You'd probably have enough paper overlap that there is not much extra work at all. Are the departments separate where you are studying?

>> No.61877686

>>61877598
???
then why does this work?
#include <iostream>
using namespace std;

void prtarr (int v[10]) {
for (int i = 0; i < 10; i++) {
cout << v[i];
}
}

int main () {
int b[10];
for (int i = 0; i < 10; i++) {
b[i] = i;
}
prtarr (b);
return 0;
}

>> No.61877723

>>61877686
That declaration is deceptive and v decays to an int pointer.

https://stackoverflow.com/questions/1461432/what-is-array-decaying

If you want to enforce the size of the input array you can do something like this (in C99), but it still decays to a pointer to something like `sizeof(v)` will be the size of an int pointer so be wary.

void prtarr (int v[static 10]) {
for (int i = 0; i < 10; i++) {
cout << v[i];
}
}


This will give an error if an array which cannot be determined at compile-time to contain 10 elements is passed. More elements is still fine so its not exact.

>> No.61877735

>>61877723
didn't notice you were using C++. Look at http://en.cppreference.com/w/cpp/container/array

>> No.61877746

>>61877671
Yes. Math crypto course is 3rd year and CS security is also 3rd year, both with long prerequisites.

>> No.61877767

>>61877723
ah, I see. the compiler does shit to try to help you, but in your use case it just gets in the way. yeah?

>> No.61877778

>>61877654
There are plenty of examples, I know the steel Bank CL interpreter is written in C but it's full featured, there's a lot of code there, you'll have to do some digging (which is not a bad thing, great way to learn, just work).

Are there any issues with string manipulation you're having in particular? It's definitely a lot more ceremony to mess around with strings in C but it's not fundamentally different.

>> No.61877781

Clojure is amazing!

>> No.61877808
File: 20 KB, 332x304, 5819995642.jpg [View same] [iqdb] [saucenao] [google] [report]
61877808

Do you fags write actual useful programs or just meme sample code to show off here?

>> No.61877818
File: 316 KB, 500x556, 1497484828388.png [View same] [iqdb] [saucenao] [google] [report]
61877818

quick, post a fizzbuzz using 5 stars and a cyclic linked lists written in ANSI C

>> No.61877838

>Fixed-length arrays must have their size determined at compile time.

so why I can do this?

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

int main(){
int size;
scanf("%d", &size);
int array[size];

for(int i = 0; i < size; i++){
array[i] = i;
}
for(int i = 0; i < size; i++){
printf("%d\n", array[i]);
}

return 0;
}

>> No.61877839

>>61877778
in a dynamic language, my usual parsing routine would consist of reading a big string from file, splitting it on space, using a regular language to classify the tokens, and then running a parsing algorithm on the token list, either a custom recursive descent parser, a generated one or an Earley with a custom grammar fed to it

It's been so long since I used C I don't even know how to load data from files anymore, so I just hardcoded a simple Lisp program in the source code. I don't know how to split this shit either, I don't have regular language support either... I'm basically fucked

>> No.61877849

>>61877838
>scanf("%d", &size);
> int array[size];

>> No.61877861

>>61877838
https://en.wikipedia.org/wiki/Variable-length_array

>> No.61877862

>>61877849
yes, why can I do it

>> No.61877871

>>61877808
I mostly keep busy with my CS assignments and programming book exercises
once i git gud at C, scheme, and the SDL library I'll start work towards my first personal project tho

>> No.61877873

>>61877862
Do you know what the user will type in during compile time?

>> No.61877879

>>61877778
I can't find a single C file in SBCL's repository

>> No.61877881

Clojure us amazing!

>> No.61877882

>>61877808
I generally just write programs to fulfil my needs as I go. The last programs I wrote recently were one to search a list of directories for duplicate files and offer an option to delete either of them in a way that's fully scriptable and isn't slow as hell, and one to delete files/directories without regard for NTFS file permissions/attributes because I don't like being told I'm not allowed to delete files on my own computer.

>> No.61877887
File: 75 KB, 844x1440, su___garnet_by_shyrstyne-d8rye7e.png [View same] [iqdb] [saucenao] [google] [report]
61877887

ruby vs python vs perl

which should i learn to replace bash shell scripting for more power?

>> No.61877923

>>61877887
Ruby is great for Unix scripting, it's essentially a better perl. Has less libraries though.

Python has a shit ton of useful libraries of greatly varying quality from 10/10 to utter crap.

Perl is write-only programming language and is essentially Unix duct tape. A lot of libraries as well, but it's losing momentum compared to Python and even systems like Node.

>> No.61877950

>>61877882
What did you use to find the duplicates, MD5?
I remember trying to do that years ago, but it was slow a fuck.

>> No.61877960

>>61877861
I've never heard people talking about that before. I guess it is because it is not an ansi c thing

>> No.61877964

>>61877839
That's still pretty much the process. You know each step, you can look up how to do them.

Splitting strings means walking through the string, keep an index at where you start, advance until you find the next token you want to split on, copy between the current location and the previous index into the output list, and advance both indices to the same place. It's annoying if you're used to more robust string operations being part of the language but it's nothing to get intimidated by.

For token classification you can use a regex library or it's simple enough that you can do it yourself, you only need to recognize quotes, numerics, and parens to get something off the ground.

It'll be a lot of wrestling with C but it's the best way to learn.

>> No.61877981

>>61877879
https://sourceforge.net/p/sbcl/sbcl/ci/master/tree/src/runtime/runtime.c

>> No.61878000

>>61877960
its part of C99 and optional in C11

it's not really used since unbounded stack storage isn't usually a great idea

>> No.61878103

>>61878000
do you happen to know if C Programming: A Modern Approach talk about this kind of thing? I was looking for a book to get to know more about how C works and I feel like I'll be missing some features if I get C Programming Language

>> No.61878104

>>61877960
>>61878000
I use them quite often. They shouldn't be used for unbounded and untrustworthy input, though.
There are many situations where you can reason about the max length of the array and safely use them, giving you much more performant code.

>> No.61878152

>>61877950
Yeah, it seems fast enough. I can search 280MiB across 1,958 files and 264 directories in ~1.5s. The hashing itself is about 300-400MiB/s. I experimented with some other hashing functions but couldn't get a significant speed increase and MD5 is simple enough for me to write my own implementation for, which probably helps with any licensing issues if I were to ever release the program as well as just the fact that it feels nice to write everything yourself.

>> No.61878246
File: 6 KB, 240x184, lol.png [View same] [iqdb] [saucenao] [google] [report]
61878246

>>61877950

Use CRC32. If it detects duplicates, use SHA1 or MD5 on the duplicates to re-confirm.

Ya dig?

>> No.61878292

>>61878152
>>61878246
I don't know how I managed to fuck up a simple program like that. It was taking 500 ms to compare two relativity small files.
Maybe I will give it a try again when I've got some time.

>> No.61878342

>>61875133

In C how do I get the program to read one character from standard input and discard any others that are entered? I'm trying to do a simple y/n loop to continue without it sperging out if you enter more than one incorrect entry at a time.

>> No.61878400

>>61878246
With modern CPUs (anything from the last 10 years) I imagine you're probably being bottlenecked by how fast you can read the data rather than the speed of the hash calculation, even on an SSD.

>> No.61878430

>>61878342
with a while loop

>> No.61878432

>>61878342
Read a whole line, ignore the rest of it and use the first character.

You have to consume the extra characters in order for them not to get fed into your next std input usage.

>> No.61878442

>>61878432
Or validate based on the whole line, your choice. But the point is you have to consume the other characters.

>> No.61878446

>>61878432

Aite I got it so getchar() then (ch=getchar()) != '\n'?

>> No.61878496

>>61878446
Yep, or you can use fgets to do it automatically. Keep in mind fgets puts the newline into your read string.

>> No.61878532
File: 52 KB, 280x438, 884142.gif [View same] [iqdb] [saucenao] [google] [report]
61878532

>>61878496
>fgets
HAHAHAHAHA

>> No.61878536
File: 1.10 MB, 1120x642, 000090-Essentials_ Brian Kernighan on Associative Arrays - Computerphile - YouTube.png [View same] [iqdb] [saucenao] [google] [report]
61878536

>brian kernighan is left handed

>> No.61878537

what are the most mystical, ethereal programming languages? scheme? haskell?

also, why does /dpt/ hate rust? it was the most loved language on stackoverflow

https://insights.stackoverflow.com/survey/2017#most-loved-dreaded-and-wanted

>> No.61878621

>>61876628
>because I'm kind of used to pass-by-reference in sepples
Sepples is no different, retard.

>> No.61878633

>>61876818
The best way to get better at C is to learn another language and then come back to C.

>> No.61878677

The average /wdg/ poster gets more stuff done than /dpt/ combined!

>> No.61878706

>>61878677
>/wdg/
>>>/reddit/

>> No.61878719

>>61878532
What's your solution?

>> No.61878722

why are programming books so expensive?

>> No.61878741

>>61878722

College textbooks.

>> No.61878750
File: 40 KB, 303x566, 478895.jpg [View same] [iqdb] [saucenao] [google] [report]
61878750

>>61878719
Faggots.

>> No.61878816

>>61878750
Stupid frogposter

>> No.61878835

There is literally nothing wrong with programming in Python and anyone who disagrees is a pseudo-intellectual.

>> No.61878879

>>61878536
>tfw right-handed brainlet

>> No.61878942

>>61878835
>abysmal performance in general
>no TCO
>can't use assignment inside expressions
>conditionals can't be used as lvalues
>no native ropes
>no native support for O(1) array slicing

>> No.61878952

>>61878942
>conditionals can't be used as lvalues
That's a good thing. Doing so results in poor, unclear code.

>> No.61878956

>>61878942
also, __dict__

>> No.61878961

I just learned that in C the assignment operetion returns a value so I can do
a=b=c=d=e=f=g=10

>> No.61878966

trying to learn c.

Can someone tell me what wrong with this, other than possible shit coding practices?
#include <stdio.h>
const int CONVERSION = 60;
const float DEC = .01;
int main(){
int begin_min, hour, ans_min, mod_min, temp;
char user_min[3];

printf("Enter mins: ");
fgets(user_min, sizeof(user_min), stdin);
sscanf(user_min, "%d", &begin_min);

hour = begin_min/CONVERSION;
mod_min = begin_min%CONVERSION;
temp = mod_min*.01;
ans_min = temp * CONVERSION;

printf(" Answer is %d hour and %d mins", hour, ans_min);
return(0);
}

>> No.61878971

>>61875195
I would like a Big Mac, Pepsi and fries.

>> No.61879012

>>61878952
way to not respond to everything else I said. everyone who uses python does the exact same logic except uglier, setting the assigned expression outside an if and then using if statements for each one. because they have to, thanks to guido's enlightenment.

other problems include not knowing statically if basic property accesses have side effects, an issue shared with several other languages.

>> No.61879029

>>61878966

Increased your buffer size because its not like you are strapped for memory.
Your conversion also is wrong and you only need to take the mod_min as your seconds. I think the following is what you want.
Also, you want to specify main as taking a single void parameter. Not specifying any parameters in C actually means something different (okay in C++ though).

#include <stdio.h>

const int CONVERSION = 60;

int main(void) {
int begin_min, hour, mod_min;
char user_min[32];

printf("Enter mins: ");
fgets(user_min, sizeof(user_min), stdin);
sscanf(user_min, "%d", &begin_min);

printf("%d\n", begin_min);

hour = begin_min / CONVERSION;
mod_min = begin_min % CONVERSION;

printf(" Answer is %d hour and %d mins\n", hour, mod_min);
return 0;
}

>> No.61879053

>>61878633
really?
that seems counter-intuitive

>> No.61879128

who the hell thought Hy was a good idea?

>> No.61879172

>>61879029
So was my issue (besides the incorrect conversion) was that the array was too small?

>> No.61879200

>>61879172
>>61879029
wowowow im retarded, i essentially tried to do what the modulas does already

>> No.61879211

>>61877808
I write a different FizzBuzz solution every week in Scheme.

>> No.61879234

>>61879200
nvm im triple retarded i haven't done remainders since elementary.

>> No.61879303

Continuing my quest through all the models in our simulation. Currently making sure our atmosphere model isn't retarded.

>> No.61879312

>>61879211
you too!?

>> No.61879315
File: 89 KB, 164x265, 000021-Twitch.png [View same] [iqdb] [saucenao] [google] [report]
61879315

>>61879303
(spoiler: it does)

>> No.61879375

>>61879312
Yes, wrote one using macros today.

>> No.61879554

>>61875159
pandoc
idris
agda

>> No.61879571

>>61879315
i hate it when my model does retarded too

>> No.61879573

>>61875159
https://github.com/jameysharp/corrode

>> No.61879606

>>61879571
no hablo englando

>> No.61879689

>>61879303
Whatcha simulating?

>> No.61879767

>>61879689
Guided bombs. Most of the sim was developed by a bunch of GNC monkeys so we're having to go through and fix all the fuckery.

>> No.61879824
File: 61 KB, 535x577, sad_wojak.jpg [View same] [iqdb] [saucenao] [google] [report]
61879824

>>61878536
>ywn be left handed
Why is being left handed the master race?

>> No.61879827

what are classes used for in c++?

>> No.61879849

>>61879827
to encapsulate state and state change of a particular type of object

>> No.61879860

>>61879827
is this your first time programming?

>> No.61879874

>>61879827
job security

>> No.61879877

>>61879860
yes

is writing classes as projects something great to do in order to learn programming? seems like a good first stop.

>> No.61879887

>>61879877
do basic procedural programming before you even think about OOP

>> No.61879921

>>61879887
This. Eventually you'll start writing things complex enough that classes and such become the natural next step. They're not really a good starting point.

>> No.61879938

>>61879887
>>61879921
Okay. Gonna write something and post it when I'm done to get a rating.

>> No.61879953

>>61879877
OOP in the modern context is a pretty tried-and-failed concept for the most part. It's only useful in huge companies where swaths of low-credential employees that don't collaborate efficiently need to be protected from one another.
Learn basic procedural programming first, maybe something like C or Python. Then some basic functional after that.

>> No.61879965

I have to make an algorithm that takes a dictionary.txt file with a list of words separated by new lines and find the anagram that occurs the most.

It has to be O(M N) complexity, so using radix sort with counting sort I can achieve this.

Could anyone help me with how they'd do it? I'm struggling to get a grasp on the logic behind it as a sorted list will put all anagrams next to each other but they won't have been counted...

>> No.61879970

>>61879877
oop being a data abstraction technique, it shouldn't come first

>> No.61879978
File: 40 KB, 400x400, fedora.jpg [View same] [iqdb] [saucenao] [google] [report]
61879978

>>61879573
Do you wear a fedora too?

>> No.61880028

>>61879938
>>61879921
>>61879887
#include <iostream>

using namespace std;

int addition(int a, int b);


int main()
{
int a, b, product;
cout << "Enter 2 integers" << endl;
cin >> a >> b;

product = addition(a, b);

cout << "product: " << product << endl;

return 0;
}

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


Am I ready yet or should I just continue with increasing complexity?

>> No.61880051

>>61880028
>int addition(int a, int b)
>multiplies
???
Also keep doing more, this is basic shit.

>> No.61880064

>>61880051
oops did it too fast i guess. and okay. what should I do?

>> No.61880093

>>61879965

Rough pseudo code for the idea. Use a dictionary with a default value of 0 (i.e. a defaultdict in python).

m = defaultdict()
max_entry = 0
max_word = ""

for word in words:
w = sorted(word)
m[w] += 1
if m[w] >= max_entry:
max_word = w

>> No.61880108

>>61880093
need to set max_entry along with max_word but i think you get the idea

>> No.61880110

>>61880064
Make a game of tic-tac-toe.

>> No.61880123

>>61880093
Can't use dictionary because it's worst-case retrieve and input is O(n) when every value is indexed at the same hash :(

>> No.61880125

/g/uys its raining im excited

>> No.61880136

>>61875520
>Trying to wrap my head around how C handles headers.
C handles headers (and all includes, the extension does not matter) by simple text concatenation. It simply adds the stuff from the included file right on the line it's included at. For instance, let's say we have two files, a.h and a.c:

/* a.h */

int
do_something()
{
return 0;
}


/* a.c */

#include "a.h"

int main(int argc, char **argv)
{
return do_something();
}


If we compile an object file with "a.c" as the source, it will actually look like this after the preprocessing:

int
do_something()
{
return 0;
}

int main(int argc, char **argv)
{
return do_something();
}


There's no magic there, just code being added to where ever you asked the compiler to add it.

>> No.61880155

>>61880136
This is the simple part, it becomes a headache when you start worrying about linkage.

>> No.61880163

What does ERROR_H *actually* define in a header file, like below?
#ifndef ERROR_H
#define ERROR_H
/* eprintf.h: error wrapper functions */
void eprintf(char *, ...);
char *estrdup(char *);
void *emalloc(size_t);
void * erealloc(void *, size_t);
void setprogname(char *);
char * progname(void);
#endif

>> No.61880177

>>61880110
how would i go about doing that?

>> No.61880181

>>61880163
It defines the symbol for the preprocessor with no value. Any substitution later will be empty but the only important thing for a header guard is that the symbol is defined.

>> No.61880186

>>61880163
That's an include guard. The value of the define doesn't matter, all that matters is that it is actually defined. If it is, then the ifndef directive will skip over the body of the header file and avoid duplicate-definition errors in case the header is included a second time.
It's a common pattern, sometimes the #pragma once directive is used instead though.

>> No.61880215

>>61880177
That's for you to find out. You know how to read text, you know how to print text and you should know some looping and conditional constructs. That's enough to implement the rules of a simple game like tic-tac-toe.

>> No.61880218

>>61880155
Only if you make it unnecessarily complicated by declaring everything in different files. Just remember that since its all simple string concatenation, you can include a file anywhere, not just at the top of the file (for example, after having defined your data structures).

Generally I think people have a tendency to keep their source files unnecessarily small and that leads to those headaches you're referring to, not to mention actual performance issues of not being able to inline some functions for instance, simply due to bad project structure.

>> No.61880234

>>61880123
a hashmap is amortized O(1), this doesn't matter and i don't think you should care about it, you can't do any better

>> No.61880303

>>61880125
/g/uys there is lightning now i dont know what to do

>> No.61880327

>>61880125
>>61880303
it's pretty dull sunny weather here, trade?

>> No.61880407

>>61880181
>>61880186
How come when I try to do an empty define in a function it prints an error?
#include <stdio.h>

#define HELLO

int main(int argc, char *argv[])
{
printf("%d\n", HELLO);
return 0;
}

>> No.61880420

>>61880407
After preprocessing, the file will look like this.
printf();
// other definitions from stdio.h.

int main(int argc, char *argv[])
{
printf("%d\n", );
return 0;
}

You can't have an empty argument like that.

>> No.61880424

>>61873052
I see. I agree that I'd like more of that. Perhaps not for a beginner book but it's certainly a very important step in learning software.
Find some open source Java project and look into it. Start with something small and gradually work up to enterprise Java.

>> No.61880442

>>61880327
no sorry i live in a desert this water needs to last us until winter its just very overwhelming sometimes

>> No.61880670

I'm trying to submit some java code to an online thing as homework, but the thing doesn't accept the format I give it, saying
***Runtime error***
Error: Could not find or load main class XXX

regardless of what I name the main class "XXX". Since I'm just entering the code from the .java file, I guess it doesn't know what the main class should be called. If I try just entering the code within the class then it tells me I've got invalid syntax, so I know I'm nearly there, it's just getting hung up on the class name. In this case, is there some simple workaround or default name for the main class I could try? I'm not expecting a thorough tutorial or anything, just for someone to clue me into something stupid that I've probably missed.

>> No.61880774

alright Cfags

https://github.com/esmil/musl/blob/master/src/internal/syscall.h#L42

how the FUCK is this macro counting the number of arguments and selecting the right syscallN function to call?

this is pure wizardry

>> No.61880778

So how do we fix some of the type declaration syntax in C?
Here are some changes I think would be good.
int[] arr; //instead of int arr[]
int[5] arr; //instead of int arr[5];
int* a, b, c; //a, b and c are of type int* instead of *a being of type int.
int a, b, *c //is a compile error now

int*()(int, void*)* fp; //Not really sure about this syntax

The only thing I don't really know a nice syntax for is function pointers without introducing a new keyword

>> No.61880791

>>61880774
>#define __syscall_cp0(n) (__syscall_cp)(n,0,0,0,0,0,0)
#define __syscall_cp1(n,a) (__syscall_cp)(n,__scc(a),0,0,0,0,0)
#define __syscall_cp2(n,a,b) (__syscall_cp)(n,__scc(a),__scc(b),0,0,0,0)
#define __syscall_cp3(n,a,b,c) (__syscall_cp)(n,__scc(a),__scc(b),__scc(c),0,0,0)
#define __syscall_cp4(n,a,b,c,d) (__syscall_cp)(n,__scc(a),__scc(b),__scc(c),__scc(d),0,0)
#define __syscall_cp5(n,a,b,c,d,e) (__syscall_cp)(n,__scc(a),__scc(b),__scc(c),__scc(d),__scc(e),0)
#define __syscall_cp6(n,a,b,c,d,e,f) (__syscall_cp)(n,__scc(a),__scc(b),__scc(c),__scc(d),__scc(e),__scc(f))


Ah yes, C is action.

>> No.61880793
File: 174 KB, 562x389, fragzeichen2.png [View same] [iqdb] [saucenao] [google] [report]
61880793

>>61875133
Is there a super-minimal, modular version of TeX that can be easily embedded with one's preferred packages?

I've made what I think is a really useful program for normies, but it's handicapped by the fact that it depends on an extant LaTeX installation. It'd be really nice if I could just distribute a standalone binary.

>> No.61880818

>>61880793
>Is there a super-minimal, modular version of TeX that can be easily embedded with one's preferred packages?
Yes. Read the pdf made by Donald. He explain everything.

>> No.61880821

>>61880774
>>61880791

I mean this:

#define __syscall_cp0(n) (__syscall_cp)(n,0,0,0,0,0,0)
#define __syscall_cp1(n,a) (__syscall_cp)(n,(long)(a),0,0,0,0,0)
#define __syscall_cp2(n,a,b) (__syscall_cp)(n,(long)(a),(long)(b),0,0,0,0)
#define __syscall_cp3(n,a,b,c) (__syscall_cp)(n,(long)(a),(long)(b),(long)(c),0,0,0)
#define __syscall_cp4(n,a,b,c,d) (__syscall_cp)(n,(long)(a),(long)(b),(long)(c),(long)(d),0,0)
#define __syscall_cp5(n,a,b,c,d,e) (__syscall_cp)(n,(long)(a),(long)(b),(long)(c),(long)(d),(long)(e),0)
#define __syscall_cp6(n,a,b,c,d,e,f) (__syscall_cp)(n,(long)(a),(long)(b),(long)(c),(long)(d),(long)(e),(long)(f))

#define __syscall_cp(...) __SYSCALL_DISP(__syscall_cp,__VA_ARGS__)
#define syscall_cp(...) __syscall_ret(__syscall_cp(__VA_ARGS__))


how the hell does it count arguments

>> No.61880828

>>61880778
>So how do we fix some of the type declaration syntax in C?
C needs no fixing.

>> No.61880876

>>61880821
#define __SYSCALL_NARGS_X(a,b,c,d,e,f,g,h,n,...) n
#define __SYSCALL_NARGS(...) __SYSCALL_NARGS_X(__VA_ARGS__,7,6,5,4,3,2,1,0,)
#define __SYSCALL_CONCAT_X(a,b) a##b
#define __SYSCALL_CONCAT(a,b) __SYSCALL_CONCAT_X(a,b)
#define __SYSCALL_DISP(b,...) __SYSCALL_CONCAT(b,__SYSCALL_NARGS(__VA_ARGS__))(__VA_ARGS__)


It's a clever trick I have to admit.

>> No.61880889

>>61880778
I say we leave it as it is considering it makes complete sense.

>> No.61880926

>>61880778
This is wrong because int[3][6] foo; is indexed as foo[5][2];

>>61880889
Returning a function pointer is a nightmarish clusterfuck.

>> No.61880927

>>61880876
can you explain how it works

>> No.61880960

>>61880926
You didn't really offer any improvement for function pointers. In fact, I think you made it more ambiguous for more difficult function pointers.

>>61880927
Here's how I see it:
#define __SYSCALL_NARGS_X(a,b,c,d,e,f,g,h,n,...) n
#define __SYSCALL_NARGS(...) __SYSCALL_NARGS_X(__VA_ARGS__,7,6,5,4,3,2,1,0,)


__SYSCALL_NARGS("hello") becomes __SYSCALL_NARGS_X("hello",7,6,5,4,3,2,1,0,)
and with named arguments: __SYSCALL_NARGS_X(a="hello",b=7,c=6,d=5,e=4,f=3,g=2,h=1,n=0,), so the result of this macro is 0 since n=0

__SYSCALL_NARGS("hello","world") becomes __SYSCALL_NARGS_X("hello","world",7,6,5,4,3,2,1,0,)
and with named arguments: __SYSCALL_NARGS_X(a="hello",b="world",c=7,d=6,e=5,f=4,g=3,h=2,n=1,...), so the result of this macro is 1 since n=1

That about sums it up.

>> No.61880984

>>61880960
At a guess I'd choose a style like int(int, int) fptr; to declare a function pointer but I'm not sure if that's any better. I haven't thought it through.

>> No.61881010

>>61880984
I think that with something like this you'll run into clearly ambiguous syntax with pointer to function that returns pointer to function that returns pointer to function.

>> No.61881072

>>61881010

int i;
char c;
short s;
double(int)(char)(short) fptr = getFptr();
double(char)(short) fptr2 = fptr(i);
double(short) fptr3 = fptr2(c);
double d = fptr3(s);

>> No.61881085

>>61881072
Now you're asking for way more than just a new syntax for function declaration.

>> No.61881103

>>61881085
>>61881072
And in addition to that, you haven't even demonstrated a function that returns a pointer to function. All your functions return double and you just used your new feature you came up with that creates a function that returns double from another function that returns double.

>> No.61881137

>>61881072
You misunderstand what I'm trying to express here.
a value of type double(int)(char)(short) is a function pointer that takes an int and returns a function pointer which takes a char and returns a function pointer which takes a short and returns a double. In other words:
int i;
char c;
short s;
double(int)(char)(short) fptr = getFptr();
double d = fptr(i)(c)(s);


This is all speculative shit I don't really know what I'm doing. I'm not the original person who complained about C declarator-style syntax.

>> No.61881146

>>61881085 >>61881103
not >>61881072
but like I said in >>61880778 function pointers are just hard to think up a new fitting syntax for.

>> No.61881174

>>61881146
Yeah, and my point is suggested "improvements" to C are not actually improvements at all, since what we have now makes no less sense than your suggestions.

>> No.61881195

>>61881137 is directed towards >>61881085 >>61881103

I dunno, it makes sense to me.

>> No.61881231

>>61881137
>>61881195
I know perfectly well what you're doing. You're suggesting the way Haskell handles function arguments. Calling a func(a,b) with just one argument creates a new function, func(b). There are plenty of reasons why this has no place in C, but that's not even the point. A function that returns pointer to the function is not what you are suggesting. A function that accepts 2 arguments can as a result of its execution return a pointer to a function that accepts 10 arguments.

>> No.61881300

>>61881231
I don't know Haskell and have only a vague idea of functional programming concepts. For me this is just a novice with a thought experiment.
>Calling a func(a,b) with just one argument creates a new function, func(b)
No, there isn't currying or partial application. A function call would be complete just like in C, void(int)(int) requires two distinct calls and void(int, int) requires one. Nothing changes but the syntax for types.

>> No.61881338

Came back from work a few moments ago. Rate my 9th C++ program.
#include <iostream>
#include <cstdlib>
using namespace std;

int generate_random_value()
{
return (rand() % 100) + 1;
}

int get_int()
{
int result;
cin >> result;
return result;
}

/*
* Returns 1 if y, else 0
*/
int get_yn()
{
char input;
cin >> input;
if (input == 'y' || input == 'Y') return 1;
else return 0;
}

void check_loop(const int determined_val)
{
cout << "Cheat: it's " << determined_val << endl;
cout << "Enter your guess [1-100]: " << endl;
while (true) {
int response = get_int();

if (response > determined_val) {
cout << "Too big!" << endl;
continue;
} else if (response < determined_val) {
cout << "Too small!" << endl;
continue;
} else if (response == determined_val) {
cout << "Correct!" << endl;
break;
} else {
cout << "Error detected, exiting..." << endl;
exit(0);
}
}
}

int main()
{
cout << "Welcome to the number guessing game. " << endl;
while (true) {
int random_value = generate_random_value();
check_loop(random_value);
cout << "Do you wish to continue? [y/N] :";
if (get_yn() == 0) {
break;
}
}
return 0;
}

>> No.61881363

>>61881300
All right, I did misunderstand then.

So
void(int,int,int,int,int,int,int,int,int,int)(int,int) func
would be a function that accepts 2 arguments and returns a pointer to a function that accepts 10 arguments (returning void). I'll think about it.

>> No.61881393

>>61881338
What is your current occupation?

>> No.61881401

>>61881393
employed haskell programmer

>> No.61881409

>>61881363
It's the other way around, actually. It accepts 10 arguments and returns a fptr that accepts 2 arguments.
int i;
void(int,int)(int) fptr;
fptr(i, i)(i);

I still think that specifying the types based on how you use them is a good idea. It talked about how it gets confusing with arrays here >>61880926 if you do it in a "dumb" way by just popping off the right hand side rather than making the declaration match the usage like in C.
You'd declare a pointer to int as *int ptr; to int* ptr; too.

>> No.61881421

>>61881393
I work as a bartender

>> No.61881462

>>61881338
be more consistent with bracketing

>> No.61881474

>>61881462
I thought I was following the K&R style...

>> No.61881512

>>61881474
you are. don't listen to that anon

>> No.61881532

>>61881231
not >>61881137 but I assume it works like:

double first(short, int) {
return 1.0;
}

double(short, int) second(char, int) {
return &first;
}

double(short, int)(char, int) third(short, char, int) {
return &second;
}

int main(int argc, char *argv[]) {
int i1, i2, i3;
char c1, c2;
short s1. s2;
double(short, int)(char, int)(short, char, int) fptr1 = &third;
double(short, int)(char, int) fptr2 = fptr1(s1, c1, i1);
double(short, int) fptr3 = fptr2(c2, i2);
double value = fptr3(s2, i3);
double value2 = fptr1(s1, c1, i1)(c2, i2)(s2, i3);
}


>>61881409
Your way makes zero sense.

>> No.61881559

>>61881532
I don't think you declare a function pointer like that.
A pointer to first would look like
double (*fptr)(short, int);

>> No.61881565

>>61881559
it's speculating about an alternative.

>> No.61881570

>>61881565
My bad.

>> No.61881574

>>61881409
Right. That way you declare the function and use it with same order, func(10 args)(2 args).

>> No.61881585

>>61881565
>2017
>still adamantly refusing to use decent syntax because it's from type theory and you hate academics

double -> (short, int)

(char, int) -> (double -> (short,int))

>> No.61881606

>>61881585
whoops

(short, int) -> double
i got confused because C function type syntax is backwards

>> No.61881625
File: 827 KB, 858x1200, 1502126194359.png [View same] [iqdb] [saucenao] [google] [report]
61881625

Here is my first line of code. What do you guys think?
#define female female(male)/* traps are not gay */

>> No.61881627

>>61881606
You got confused because you are generally just a confused person. My suggestion for you is to get your shit together.

>> No.61881637

>>61881627
No, I got confused because no sane person would want output(input)

>> No.61881643

61881625,

That definitely looks like someone's first line of code.

Anon.

>> No.61881654
File: 143 KB, 833x696, 1479883677181.jpg [View same] [iqdb] [saucenao] [google] [report]
61881654

>>61881643

>> No.61881657

>>61881637
At some point you have to stop being confused. You may think you have all the time in the world, but that's not actually the case.

>> No.61881696

>>61881657
What are you even talking about?

>> No.61881697

>>61880793
#lang racket/scribble

>> No.61881700

>>61881696
Take your time.

>> No.61881707

>>61881700
You have a really roundabout way of trying to pretend C has good syntax for function types

>> No.61881741

>>61881707
Those are levels of confusion that even I did not predict.

>anons are talking about a new syntax for C function pointer type declaration
>this means they must really think C has good syntax for function types

>> No.61881751

>>61881741
I know, and your proposed syntax is just as bad.

>> No.61881771

>>61881751
1. It's not mine.
2. You're still a very confused person, even more so after >>61881707.

>> No.61881779

>>61881771
You are just posting dribble.
It's you who's confused.

>> No.61881789

>>61881779
A perfect example of dribble is >>61881707.

>> No.61881899

I've only learned how to ""program"" recently. I made my own version of Conway's game of life yesterday.

>> No.61881900
File: 144 KB, 600x678, 1488475745114.jpg [View same] [iqdb] [saucenao] [google] [report]
61881900

Is there a way to get instant volume change notifications? I was thinking of setting inotify to watch whatever amixer writes to but it doesn't seem like it writes to a file. I'm probably going to end up writing to a file when I press the volume change keys and watching that instead but I would like a less hacky way if it's possible.

>> No.61881934
File: 26 KB, 842x647, cwgol.png [View same] [iqdb] [saucenao] [google] [report]
61881934

>>61881899
pic related

>> No.61881948

>>61881934
Looks like HTML+CSS+Javascript.

>> No.61881972
File: 5 KB, 429x410, 1275349948732.png [View same] [iqdb] [saucenao] [google] [report]
61881972

>>61881948
Ya got me. Hence the quotation marks.

>> No.61881990

>>61881972
Well, I got nothing against JS. Apart from few very silly quirks, it's a fine language, and HTML+CSS is a great tool for making UI.

>> No.61881996

>>61881990
undefined is not a fine language.

>> No.61882000

>>61876049
I haven't done C++ in a while but, for starters, you might want to replace that switch with an array of strings.
E.g:
string get_type_string(monster_t m){
string[] name = {
"ogre",
"orc",
"dragon",
"Giant spider",
"slime"
};

return name[m];
}

Even then, you might want to take that list out of the function and have it be global or in its own header or something.

>> No.61882005

>>61881996
Are you ok?

>> No.61882046

Starting off my journey on Scala.

>> No.61882050

>>61875133
>one sperg's opinions
>"/dpt/ recommended"

Scheme is cool, but irdis and shen are fucking useless, and learning both is even more useless. Irdis is slow with a shitty syntax. Shen isn't all too bad, but it's not necessary when you can just use Scheme in it's place.

>> No.61882057

>>61882046
I implore you to watch this before making a big mistake.
https://www.youtube.com/watch?v=4jh94gowim0

>> No.61882112
File: 47 KB, 850x655, sudk.png [View same] [iqdb] [saucenao] [google] [report]
61882112

>>61881934
Also this, in similar fashion.

>> No.61882182
File: 17 KB, 486x899, comfy_merge.png [View same] [iqdb] [saucenao] [google] [report]
61882182

Is my merge sort implementation comfy?

>> No.61882199

>>61882182
It's not done yet btw, I still want to add function pointer and remove the initial value.

>> No.61882205

> software engineering, theory and practice, and will include some programming exercises.

How do I prepare for an interview containing questions about "software engineering theory and practice"?

Do they mean OOP?

>> No.61882206

>>61882182
please stop using pure colors, especially black on white.
Your eyes fatigue faster.

>> No.61882213

>>61882206
that's yellow

>> No.61882244

>>61882213
needs to be a little darker though.

>> No.61882245

>>61882182
Is this acme?

>> No.61882305

>>61882206

Dark themes are stupid.

>> No.61882352

>>61882245
It is sam.

>> No.61882424

>>61882305
bright themes are stupid.

>> No.61882470

>>61882424
No they aren't. The human system likes nature and nature is full of pale colors, so something you’re going to look at all day is best served if it were also in relaxing shades.

>> No.61882522
File: 399 KB, 762x990, bearsuit lain.png [View same] [iqdb] [saucenao] [google] [report]
61882522

https://scratch.mit.edu/projects/18997849/

>> No.61882544

>>61882305
This, but I resort to dark themes otherwise I cannot read yellow/red text.

>> No.61882565

>>61882522
lain is cute
i love lain

>> No.61882568

>>61882470
>nature is full of pale colors
Nature is also full of dark and saturated colors, as well as J-Pop bright and bold colors.
Whats your point?

>> No.61882577
File: 312 KB, 480x360, suicide.gif [View same] [iqdb] [saucenao] [google] [report]
61882577

>>61882565
>ynw have lain as a gf

>> No.61882588

>>61882577
>wanting a spaced & depressed gf
no you dont lad, trust me.

>> No.61882594

How many of you are actual pajeets?

>> No.61882595

>>61882577
w-what is she doing to that gun

>> No.61882599

>>61882470
text colors are harder to distinguish with a bright color scheme than with a dark one, making working with it more straining. furthermore, small characters or marks like dots are more difficult to perceive when blurred (through e.g. poor eyesight) on a bright background compared to a dark one.

>> No.61882609

>>61882522
>lisp
meh

>> No.61883020

>>61882182
>I'm a big boy who doesn't need syntax highlighting

>> No.61883047

>>61883020
>I'm a big boy who refuses to take off his training wheels

>> No.61883058

>>61883047
>making shitty analogies

>> No.61883059

>>61883047
>I'm a big boy because I refuse to use anything useful that helps me

>> No.61883066

I have no hands. Can I still be a programmer?

>> No.61883082

>>61883066
2 foot pedals are enough for machine code

>> No.61883083

>>61883059
>>61883058
Doesn't constitute arguments. Stay triggered kids

>> No.61883100

>>61883083
>My posts contain arguments but yours don't because I'm a big boy and you're not

>> No.61883121

>>61883100
Ask your mom to put a diaper on your head, shit-for-brains.

>> No.61883140

>>61883121
Nice argument, big boi

>> No.61883155

>>61883140
>>61883121
>>61883100
>>61883083
>>61883082
>>61883066
>>61883059
>>61883058
>>61883047
>>61883020
Are these my future co-workers?

>> No.61883169

>>61883155
better fucking start praying

>> No.61883174

>>61883155
I worked at 3 places so far, and none had people acting like that. There were some assholes but even those were polite.

>> No.61883257
File: 8 KB, 520x236, キャプチャ.png [View same] [iqdb] [saucenao] [google] [report]
61883257

>>61883155
What did you mean by this?

>> No.61883277

>>61883257
He meant he would really dislike for you to be his coworker, a sentiment I happen to share with him.

>> No.61883296

>>61883277
Don't worry. If you're anything like the average deepeeteér, you probably won't work with me, or anywhere for that matter.

>> No.61883300

Guys I wanna learn c++ more thoroughly, aside from code academy and solo learn what other books should I read?

>> No.61883388

>>61883300
More "thoroughly"? C++ Primer (not the one by Prata) is pretty thorough.

>> No.61883416

>>61883296
I know. I'm the person who wrote >>61883174.

>> No.61884350

>>61879827
disgusting stateful programming

>> No.61884476

>>61882522
>>61882565
>>61882577
>Not capitalising the "L"
Damn it. For a second, I was doubting whether her name was Lain for Iain.
I know a few Iains.

>> No.61884501
File: 295 KB, 700x704, 1474074445126.gif [View same] [iqdb] [saucenao] [google] [report]
61884501

>>61884476
there is only one lain whom we all love

>> No.61884632

Does C++ execute all code in a file? Tried to initialize some static members for a class and it forced me to do it outside of the class, worked fine just below it.

>> No.61884761

>>61884632
I don't know what you mean.

>> No.61884780

>>61884632
Static members are like namespaced globals.

>> No.61884793

>>61884632
>Does C++ execute all code in a file
They say that there are no stupid questions, but there are, and this definitely is one of them.

>>
Name (leave empty)
Comment (leave empty)
Name
E-mail
Subject
Comment
Password [?]Password used for file deletion.
Captcha
Action