▶ No.872056
▶ No.872057
▶ No.872060>>872629
foo bar
Any language worth its salt doesn't require parens around function calls.
▶ No.872067>>872075 >>872468 >>872632
Which is it?
foo; bar; baz;
or
foo; bar; baz
hint: the semicolon is a binary operator
▶ No.872071
▶ No.872075>>872080
▶ No.872076
>>872053 (OP)
int foo
(
<tab> int bar
)
{
... function body...
}
▶ No.872077
▶ No.872078
>>872053 (OP)
foo {
bar
};
▶ No.872080>>872083 >>872087
>>872075
That's not C, the semicolon is not an operator in C.
▶ No.872083
>>872080
It should have been.
▶ No.872086
foo bar
In OCaml those parentheses could be omitted.
▶ No.872087>>872127
>>872080
Isn't comma an operator in C tho?
▶ No.872103
▶ No.872108
▶ No.872127>>872468
▶ No.872132
▶ No.872133
▶ No.872144>>887231
>>872053 (OP)
foo(bar){
like_this();
}
▶ No.872150
**** COMMODORE 64 BASIC V2 ****
64K RAM SYSTEM 38911 BASIC BYTES FREE
READY.
10 FOO$
20 BAR$
30 PRINT FOOBAR
▶ No.872175
>>872053 (OP)
foo (((bar)))
▶ No.872223
▶ No.872405
>>872053 (OP)
foo[ bar; ];
been dabbling in inform 6 lately
▶ No.872413>>872467
▶ No.872465
>>872053 (OP)
Function definition:
int foo(bar)
{
...
}
For statement:
for (i = 0; i < bar; ++i) {
...
}
▶ No.872467>>872680
▶ No.872468>>887221
>>872067
>the semicolon is a binary operator
No, it's not an operator at all. It's just punctuation (statement termination delimiter, to be specific).
>>872127
>there's no comma operator in C
Wrong, there is one. Not every comma in C code is the comma operator though (the commas separating functions parameters aren't as they are punctuation similar to the semicolon, while the commas in a for statement are).
▶ No.872490
▶ No.872517
▶ No.872518
FUNCALL "{\"function\":\"foo\",\"argList\":[{\"varName\":\"bar\"}]}"
▶ No.872536>>872870
lol u take him 2 da foo bar|
▶ No.872548>>872572
int
/** Brief description.
* Detailed description.
* @param a The first parameter
* @param b The second parameter
* @return The result
*/
foo(int a, int b) {
if (a != b)
return a%b;
if (a + b == 2) {
b = a + 2;
a %= b;
}
bar(a, b);
while (a < b) {
a = baz(a, b);
quux(b, a);
}
return a*14730;
}
TL;DR documentation between return type and signature, function calls and declarations have no space between ident and parens, if/while/switch (keywords) have a space before the paren, Java-style braces.
▶ No.872552
▶ No.872556
▶ No.872572>>875605
>>872548
>Java-style braces.
the absolute state of /tech/
▶ No.872629>>872636
>>872060
>doesn't require parens
I hope you mean purely functional languages with currying, where such syntax rises from function application being most tightly binging operator denoted by space.
And not brain-dead retardation that is perl & ruby syntax.
▶ No.872631
▶ No.872632>>872666
▶ No.872636>>872640
>>872629
>his whitespace has side effects
oh no where are your endofunctors now
▶ No.872640
>>872636
>function application is side effect
Please stop sniffing solvent before it's too late
▶ No.872648
>space after function call
▶ No.872666>>872667 >>872668
>>872632
[code] int foo, bar, baz;
▶ No.872667>>872668
>>872666
[code] int foo, bar, baz;[code]
▶ No.872668>>872669
>>872666
>>872667
goddammit how do I write code?
▶ No.872669>>872672 >>872673
>>872668
kode with karlie
▶ No.872672>>872674
>>872669
add a slash before the second code
▶ No.872673
>>872669
how do I use [code] tag?
[code] syntax plox
▶ No.872674
>>872672
>add a slash before the second code
that was my next guess.
int foo, bar, baz;
▶ No.872680>>872698
▶ No.872698>>872707 >>875623
>>872680
#include <stdio.h>
int main()
{
char input;
printf("Please input characters: ");
scanf("%[?]", input);
if (input == 'BAR FOO') {
puts("Did you say \"barefoot\"?");
puts("Because if you say \"BAR FOO\" five times fast");
puts("it sure af sounds like \"barefoot\"!");
}
return 0;
}
I just realize I don't know how to do character inputs yet because I haven't gotten that far in the book :-(
▶ No.872707>>872711
>>872698
I was writing in FORTH. FOO would have stack effect ( x -- x') and BAR is what would be operated on
▶ No.872711>>872815 >>873200 >>875626
>>872707
>FORTH
interesting. I hadn't heard of that language until now. May I ask why? I mean, it seems like an obscure language, so I'd be interested to know why you decided to learn it.
I'm trudging through C right now. In a couple years, I'll be another wannabe programmer fluent in a language or two working in a coffee shop, is my guess. Kinda depressing, but I've got to give it a shot. I'm really starting to wonder whether I would want to do this for a job, though. I think I'd rather do server maintenance than code... I think. I guess I just can't imagine what the actual job would be like at this point.
>>872708
should've seen that coming...
▶ No.872785
There's a unifying theme to a lot of my Haskell style, and it is this: be explicit and use names. Why pervasively use record fields? I'm being explicit about the purpose of those pieces of data by giving those fields a name. Why qualify imports? I'm being explicit about their provenance by giving their provenance a name. Why use functions or records of functions instead of typeclasses? I'm being explicit about what functionality I'm dispatching to by giving that functionality a name. A related theme is: optimize for reading code later. If it takes longer to write or uses more lines or more variable names, but it's going to be clearer to another person reading my code---or to me, coming back to that source file in a month or a year—I will absolutely take the time to write the longer code.
But also, like a mediocre high-school essay writer, I want to reiterate what I wrote at the beginning: this is one of many styles, and it has its own tradeoffs! (Verbosity being a big one here.) Your style might be (and probably is) different, and that's a good thing: in fact, I'd be interested in reading analogous posts to this one that describe the specifics of and motivation for other people's Haskell styles! I don't think there's a "wrong way" to write Haskell: there's a multiplicity of possibilities, and we as Haskell users should embrace that!
…well, unless y'all use TypeInType, in which case you're clearly depraved in ways that medical science cannot fix.
▶ No.872815>>873221
>>872711
Cause programming is fun and Forth is fun. And it's way more powerful than C and the gang, just lacking in libraries (especially now it's basically dead). I write my own scripts in a dialect called Retro Forth
▶ No.872870
>>872536
>user was banned for this post
▶ No.872872
>>872053 (OP)
Neither. It's
foo(bar);
/thread
▶ No.873200>>873221 >>873372
>>872711
>FORTH
Because it's machine-code level of abstraction. If your other option is using assembly - FORTH might be a more productive choice. If your other option is BASIC - FORTH is only correct choice. If you have something as fancy as C compiler on your platform - you are out of FORTH use case.
For fun/educational purposes, write FORTH VM. It's simple enough that you can make decent one in one evening. Then write for it.
▶ No.873217
-[--->+<]>-.[---->+++++<]>-.---.--[--->+<]>-.++[->+++<]>+.------.++++++++++++.--------.[->+++<]>-.
▶ No.873221>>873235 >>873372
>>872815
>>873200
well, I'm just 1wk/4ch into C programming. I went with it because it seemed like the most useful place to start and the best for the job market. I won't have a CS and I'm not sure how to get experience in the field, though, so idk if I'll ever get a job. I have degrees, just not in CS. trying to make a career switch
▶ No.873235>>873237
>>873221
you could start by doing a poo in the loo pajeet
▶ No.873237
>>873235
If I were a pajeet. I wouldn't have lost my career for being le ebul wyt mail blonde nazi jewkiller cishet patriarchal rape culturist
▶ No.873273>>873365
>>872053 (OP)
Trick question. People who waste time on this bullshit instead of fixing the real problems in their code are unemployable.
▶ No.873365>>873371
>>873273
>not adhering to a code style that is both sane and consistent is not a real problem
▶ No.873371
>>873365
Your format should follow the convention set by the lead developer. This is a trivial problem for your code formatting software. This is the reason why it's meaningless to think about formatting beyond what the lead developer says.
▶ No.873372
>>873200
FORTH is more productive for most software, once you think outside the C-like mindset.
>>873221
Learn C++ if you want a job.
▶ No.873482
▶ No.875332
▶ No.875578
▶ No.875605>>887231
>>872572
>/.*java.*/i
<REEEEEEEEEE REEEEEEEEEEE JAVA JAVA JAVA GTFO PAJEEET REEEEEEEEEEEEEEE
I want /g/ to backsodus.
▶ No.875623>>876136
>>872698
This should give you the functionality without any buffer overflows (although I could be wrong since I'm still a C scrub)
#include <stdio.h>
#define BUFFER_SIZE 10
#define BAR_FOO_STR "BAR FOO"
int main()
{
char input[BUFFER_SIZE];
printf("Please input characters: ");
if (fgets(input, BUFFER_SIZE, stdin) != NULL && strlen(BAR_FOO_STR) == strnlen(input, BUFFER_SIZE) && strncmp(input, BAR_FOO_STR, BUFFER_SIZE) == 0)
{
printf("Did you say \"barefoot\"?");
printf("Because if you say \"BAR FOO\" five times fast");
printf("it sure af sounds like \"barefoot\"!");
}
return 0;
}
▶ No.875626
>>872711
Look up the history of the CRPG "Starflight" (published by Electronic Arts on 1989). Forth is good for making smallest compact code. Very usedul for microcontrollers and such.
▶ No.876136>>876138
>>875623
Just use readline(3).
▶ No.876138
>>876136
Sounds like dependency bloat for something so simple.
▶ No.876144>>876168
How do you faggots ever get any work done if you squabble over the pettiest shit like fucking intervals between brackets?
▶ No.876168
>>876144
It's as if they've never heard of code formatting programs.
▶ No.887145
▶ No.887221
>>872468
Oh yeah, you're right, forgot about the for loop comma
▶ No.887231
>>872144
Best method.
>>875605
>I want /g/ to backsodus
Agreed. Pack your things and leave, Javanigger.
▶ No.895399
type foo(bar, baz)
type bar;
type baz;
{
return baz;
}
▶ No.895423
foo(bar)
This thread is brainlet central
▶ No.895427
.section .data
op:
.ascii "fag"
.section .text
.globl func
.type func, @function
func:
movl $4, %eax
movl $1, %ebx
movl $op, %ecx
movl $3, %edx
int $0x80