Berengal wrote:Vempele's sig wrote:auto fib = series!("a[n-1] + a[n]")(1, 1);
Emphasis mine.
Special case: numbers. 1,1 in Finland == 1.1 nearly everywhere else. Also note it's just two arguments rather than five.
Moderators: phlip, Moderators General, Prelates
Berengal wrote:Vempele's sig wrote:auto fib = series!("a[n-1] + a[n]")(1, 1);
Emphasis mine.
Berengal wrote:Actually, a five-argument function is horrible enough without considering how the arguments are laid out anyway.
int zgtsvx_(char *fact, char *trans, long *n, long *nrhs, complex double *dl, complex double *d__, complex double *du, complex double *dlf, complex double *df, complex double *duf, complex double *du2, long *ipiv, complex double *b, long *ldb, complex double *x, long *ldx, double *rcond, double *ferr, double *berr, complex double *work, double *rwork, long *info);
phlip wrote:Well, infix notation, for one. There are more things that can be used as actual parameters besides variable names and quoted literals... and some of those can have spaces in them... <snip>
func(x, y + z) -> func(x (y + z)) or -> func x (y + z)
Xanthir wrote:That said, parens ftw.
It Should Be Real wrote:Fuck the wizard.
We're doing this manually.
namespace MyNamespace
{
class MyClass
{
public function DoSomething(string someString)
{
/*12spaces!*/
Console.Writeline(someString);
}
}
}MOVF f,W ;arbitrary commands
XORWF f
DECFSZ f,W
GOTO X
INCF f
chaosspawn wrote:Man indenting, who needs that.
- Code: Select all
MOVF f,W ;arbitrary commands
XORWF f
DECFSZ f,W
GOTO X
INCF f
int q, g, f=0, u=7;
void do_something(int a, int b, bool c){
if ((a+b)>9){
do_something_else(c);
} else {
do_something_else(a==b);
}
while(c){
do_another(c);
}
}int functionName()
{
while(conditional)
{
//large block of code
...
//is well-defined
}
if(shortConditional) shortStatement; //Save lines and read more easily
if(somewhatLongerConditionalIsToLongForOneLine)
{ multiple(); short(); statements(); } //My personal favorite
}
function someFunc(int arg1,int arg2) { if (arg1) {arg2++; return arg2;} elseif (arg2) {arg1++; return arg1;} else {arg1++; arg2++;}}EvanED wrote:be aware that when most people say "regular expression" they really mean "something that is almost, but not quite, entirely unlike a regular expression"
void main(int argc, char* argv[]) {
int variable = get_a_value();
if(variable == SOME_VALUE) do_foo();
else if(variable == SOME_OTHER_VALUE)
do_a_longer_command();
else if(variable == SOME_OTHER_VALUE-1 &&
another_condition() == TRUE)
do_something();
else if(variable == SOME_OTHER_VALUE-2 &&
another_condition() == TRUE) {
do_yet_another_command();
and_something_else++;
} else {
do_bar();
do_something_else();
}
return EXIT_SUCCESS;
}
Hammer wrote:For myself, I like Allman. However, my main requirement for style is that, whatever you decide to do, do it consistently! I regularly get handed code from beginners whose reaction to suggestions to maintain a consistent style is "Do I haaaaave to?" Then, after listening to them whine, I get to plow through code that uses three different indenting styles selected at random when they bother to indent at all. Grrrrrrrrr...
It Should Be Real wrote:Fuck the wizard.
We're doing this manually.
blob wrote:Karrion wrote:Agreed. However I would make one strong recommendation on that style: Please, please get out of the habit of omiting braces for single statement conditionals/loops. It's only a couple more keystrokes, but will save you a lot of time later trying to work out why that line you just added to a loop isn't being executed...
Which is why Python wins at syntax. Humans persistently believe that indentation has meaning, despite the fact that C/C++/Java compilers will happily throw bugs at you to prove that it doesn't. Python turns that around and says, if people think it should have meaning, why not make it so?
function a(int j) {
int i;
for (i=0;i<j;i++) {
if (i==j) {
//something
}
else {
//somethingelse
}
}
}
you sound like this was python’s fault.tommorris wrote:As is proved every time you go to a Python blog and read the comments and the crappy blog software pulls out all the spacing and indentation. Really is great fun that. Yet, somehow, the Python programmers still manage to work out what it means despite all the precious indentation disappearing off to the bit bucket.
yurell wrote:We need fewer homoeopaths, that way they'll be more potent!
(if (> x 42)
(then-clause)
(else-clause))
huangho wrote:
- Code: Select all
(if (> x 42)
(then-clause)
(else-clause))
flying sheep wrote:you sound like this was python’s fault.tommorris wrote:As is proved every time you go to a Python blog and read the comments and the crappy blog software pulls out all the spacing and indentation. Really is great fun that. Yet, somehow, the Python programmers still manage to work out what it means despite all the precious indentation disappearing off to the bit bucket.
Yakk wrote:flying sheep wrote:you sound like this was python’s fault.tommorris wrote:As is proved every time you go to a Python blog and read the comments and the crappy blog software pulls out all the spacing and indentation. Really is great fun that. Yet, somehow, the Python programmers still manage to work out what it means despite all the precious indentation disappearing off to the bit bucket.
It is python's fault. The problem of "whitespace is eaten by various tools" was a known problem prior to Python being released.
Python said "that's ok, I don't mind if the compileability of the code is fragile. I have principles."
huangho wrote:About Lisp: everyone knows that the proper way of indenting an if form is:
- Code: Select all
(if (> x 42)
(then-clause)
(else-clause))
(if (> x 42)
(then-clause)
(else-clause))
(if (> x 42) (then-clause) (else-clause))
Xanthir wrote:If you're indenting Lisp code manually, you're doing it wrong.
Xanthir wrote:I write my code using whatever default indentation my editor gives me. Then I highlight the block, right click, and select "Pretty Print" before saving.
huangho wrote:Xanthir wrote:I write my code using whatever default indentation my editor gives me. Then I highlight the block, right click, and select "Pretty Print" before saving.
Right-click? You're telling me you edit code with a mouse?![]()
Seriously, I don't see why having the editor indent it automatically the way you want is more manual than using the pretty-printer to do it. I would indeed be doing less manual work by letting the editor do it. (I'm arguing just to understand the reasoning behind this; I actually do it wrong and indent my ifs and unwind-protects manually to match Emacs' standard. I have been thinking about switching to Emacs lately, but still haven't done so.)
for (;;){
while (){
if (){
doIt();
}
}
} for (;;){
while (){
if (){
doIt();
}
}
}Users browsing this forum: No registered users and 1 guest