News for hackers. Stuff that matters.
Re:On VBScript by bArray on Wednesday December 19, 2018 @11:47PM (#18722585)
And this is why I tend to use a slightly smaller subset of some of the features that C-family languages support, along with an abundance of brackets.

If I remember rightly, there is the example:

    a = {-1, -1}
    x = 0
    a[++x] = x
    print(a[0] + " " + a[1])
Depending on the language (and sometimes even if you have optimizations set for those that compile to binaries), you'll get a different answer.

I always love (read sarcasm) to see awesome code, such as:

    z = a & b > c | d
or:

    z = a > b ? c < d ? e : f : g ? h : i
And then of course, the statement: "my code doesn't need comments because the code comments itself"...
Re:On VBScript by lern_too_spel on Thursday December 20, 2018 @12:36AM (#18722741)
Don't do that. The behavior is explicitly undefined in C. http://c-faq.com/expr/seqpoints.html
Re:On VBScript by oblio on Thursday December 20, 2018 @05:38AM (#18723822)
Don't do what, precisely? He listed several examples.

And I think he's agreeing with you, he's just sarcastic.

Re:On VBScript by lern_too_spel on Thursday December 20, 2018 @06:06PM (#18730064)
He said, "this is why I tend to use a slightly smaller subset of some of the features that C-family languages support, along with an abundance of brackets."

C does not support his first example. The standard states that the behavior is undefined.

Re:On VBScript by bArray on Saturday December 29, 2018 @10:02AM (#18783862)
> If I remember rightly [..]

You're probably not wrong, but I specifically remember there was something you could do in order to trick the compiler to allow modification on the left hand side to happen. It could possibly be by having two variable names referencing the same variable - for example.

Besides, the whole point was that it's usually not clever "trying to be clever". It just creates confusion. I don't personally believe the majority of people need to test the entire C spec to it's absolute boundary. A subset serves most people perfectly well.

Re:On VBScript by zbentley on Thursday December 20, 2018 @08:58AM (#18724888)
> z = a > b ? c < d ? e : f : g ? h : i

That's stylistically ugly but not hard to predict; at some point I had it beaten into my head that ternaries are always at the bottom of the single-character operator precedence stack (I really hope all languages stick to that). I'd expect most people to know this.

> z = a & b > c | d

That is harder to predict. I wouldn't expect most people to know this one without looking up a precedence list.

Re:On VBScript by pjmlp on Thursday December 20, 2018 @09:35AM (#18725176)
It gets better when you compile that C code as C++, as ?: has a different precedence level.
Re:On VBScript by quickthrower2 on Thursday December 20, 2018 @05:37AM (#18723820)
I've recently started working on a code base with great comments and they are worth their weight in gold. Especially class and method level description comments. And doubly especially the class level ones.

Also there is none of the code golf in there that you have just given as an example.