On Thursday, April 26, 2012 23:52:48 bearophile wrote:
> Jonathan M Davis:
> > I don't even know the last time that I saw an unused
> > variable left in code (except for on purpose in something like
> > isInputRange).
>
> So if the compiler warns you of unused variables, this will not
> cause your
On 26/04/2012 22:52, bearophile wrote:
For uncommon situations like isInputRange a specific annotation
solves the problem cleanly.
As does the compiler swallowing warnings in the content of an IsExpression as I already
suggested.
How many C/C++ programmers do you know that use lints? I t
Jonathan M Davis:
I don't even know the last time that I saw an unused
variable left in code (except for on purpose in something like
isInputRange).
So if the compiler warns you of unused variables, this will not
cause your code almost no warnings. No troubles for you. For
uncommon situatio
On Thursday, April 26, 2012 19:46:38 Stewart Gordon wrote:
> I can begin to see why it makes errors for unused variables a bad idea. But
> why no warnings? Obviously the user wouldn't like to see warnings thrown
> at them when they try using templates with such constraints. But:
The existence of -
On Thu, 26 Apr 2012 14:46:38 -0400, Stewart Gordon
wrote:
I can begin to see why it makes errors for unused variables a bad idea.
But why no warnings? Obviously the user wouldn't like to see warnings
thrown at them when they try using templates with such constraints. But:
- The averag
On 26/04/2012 15:05, Stewart Gordon wrote:
http://d.puremagic.com/issues/show_bug.cgi?id=7989
From JMD:
"The fact that isInputRange and isForwardRange rely on
declaring variables which aren't used being legal. It would be really annoying
for unused local variables to be illegal when dealing wi
On 26/04/2012 08:26, Timon Gehr wrote:
template isInputRange(R)
{
enum bool isInputRange = is(typeof(
{
R r; // can define a range object
if (r.empty) {} // can test for empty
r.popFront(); // can invoke popFront()
auto h = r.front; // can declare an unused variable
}()));
}
This is indeed a
Timon Gehr:
Andrej Mitrovic:
Keeping variables clean
is the responsibility of the programmer and not the compiler.
If it doesn't affect the semantics of code the compiler should
shut up. Please don't turn the compiler into a reincarnation
of Clippy.
+1.
I think currently the D compiler d
Stewart Gordon:
But one possible design for languages like these is to allow
indentation to be either entirely spaces or entirely tabs, but
not a mixture. This would also be a good way for linters for a
variety of languages to behave.
Among the arguments of the Python2.6 interpreter there i
On 26/04/2012 08:26, Timon Gehr wrote:
Another thing: It might not be unused in every static code path.
One way to deal with this would be to do the checking before conditional compilation.
That said, I've a feeling that mixin expansion might get in the way of this.
Even more important:
t
On 04/25/2012 06:10 PM, Andrej Mitrovic wrote:
On 4/25/12, Stewart Gordon wrote:
Even if it's left over from debugging, it
looks silly, and
might lead other people reading the code to believe something's wrong.
There's about a million ways to make code unreadable, and nobody
writes pitch-perf
On 25/04/2012 12:30, Stewart Gordon wrote:
On 21/04/2012 17:26, Andrej Mitrovic wrote:
Next thing you know the compiler will start warning me when I indent
my code with uneven number of spaces!
Or more usefully, warn if you have a mishmash of tab and space indentation.
How do indent-sensitiv
On 4/25/12, Stewart Gordon wrote:
> What is the distinction you're making exactly?
> You mean an empty if body should trigger something? Or shouldn't?
I'm saying those are exactly the cases presented in the docs and I
don't want them to warn by default but have a setting. I mean, the
first case
On 25/04/2012 21:12, Andrej Mitrovic wrote:
I'm really only talking about:
void a() {
int x;
}
What is the distinction you're making exactly?
And of course:
void a() {
bool state;
...
if (state) { }
}
You mean an empty if body should trigger something? Or shouldn't?
OK, so I can see a si
On Wednesday, April 25, 2012 22:12:02 Andrej Mitrovic wrote:
> I'd like the warnings to be individually selectable, just like in GCC.
Having sets of warnings that you can explicitly enable makes a lot of sense,
because it enables the programmer to have the compiler warn about stuff that
they car
On Wed, Apr 25, 2012 at 04:03:04PM -0400, Jonathan M Davis wrote:
[...]
> increasingly I agree with Walter's take on warnings (that they
> shouldn't exist at all - something is an error or it isn't; none of
> this halfway stuff). Warnings are problematic in that a good
> programmer will _never_ lea
On 4/25/12, Andrej Mitrovic wrote:
> I'm really only talking about
Although I'm not a fan of warnings for unused variables, I would be a
fan of this: http://d.puremagic.com/issues/show_bug.cgi?id=3507
But again, other people might not like that. But if it was an option..
On 4/25/12, Stewart Gordon wrote:
> So you think that
>
> import std.stdio;
> void main() {
> int a, b;
> a + b;
> return;
> writefln("Hello, world!");
> }
>
> should generate no errors or warnings whatsoever?
I'm really only talking about:
void a() {
int x;
}
And of course:
On Wednesday, April 25, 2012 20:10:18 Stewart Gordon wrote:
> On 25/04/2012 17:10, Andrej Mitrovic wrote:
> > On 4/25/12, Stewart Gordon wrote:
> >> Even if it's left over from debugging, it
> >> looks silly, and
> >> might lead other people reading the code to believe something's wrong.
> >
> > T
On 25/04/2012 17:10, Andrej Mitrovic wrote:
On 4/25/12, Stewart Gordon wrote:
Even if it's left over from debugging, it
looks silly, and
might lead other people reading the code to believe something's wrong.
There's about a million ways to make code unreadable, and nobody
writes pitch-perfect
On 4/25/12, Stewart Gordon wrote:
> Even if it's left over from debugging, it
> looks silly, and
> might lead other people reading the code to believe something's wrong.
There's about a million ways to make code unreadable, and nobody
writes pitch-perfect code that has absolutely no leftover code
On Wed, 25 Apr 2012 13:30:09 +0200, Stewart Gordon
wrote:
On 21/04/2012 17:26, Andrej Mitrovic wrote:
Next thing you know the compiler will start warning me when I indent
my code with uneven number of spaces!
Or more usefully, warn if you have a mishmash of tab and space
indentation.
On 21/04/2012 17:26, Andrej Mitrovic wrote:
Next thing you know the compiler will start warning me when I indent
my code with uneven number of spaces!
Or more usefully, warn if you have a mishmash of tab and space indentation.
How do indent-sensitive languages (Haskell, Python, whatever else)
On 21/04/2012 19:24, H. S. Teoh wrote:
In finished code, it's obviously a bad thing to have unused variables
(unless the compiler optimizes them away,
Whether the compiler optimises it away or not, an unused variable is a code smell.
Complaining about unused variables serves as a warning to t
On Saturday, April 21, 2012 18:26:52 Andrej Mitrovic wrote:
> On 4/21/12, H. S. Teoh wrote:
> > It would be a major pain if every
> > single time you need to temporarily suppress a section of code, you also
> > have to hunt down every last stray variable that's now no longer
> > referenced in the
On Sat, Apr 21, 2012 at 06:26:52PM +0200, Andrej Mitrovic wrote:
> On 4/21/12, H. S. Teoh wrote:
> > It would be a major pain if every single time you need to
> > temporarily suppress a section of code, you also have to hunt down
> > every last stray variable that's now no longer referenced in the
On Sat, Apr 21, 2012 at 06:42:06PM +0200, bearophile wrote:
> H. S. Teoh:
>
> >>Why do you want to be able to declare local variables and then
> >>never use them?
> >[...]
> >
> >It happens a lot when you're debugging code (temporarily comment out
> >some stuff for testing purposes). It would be a
H. S. Teoh:
Why do you want to be able to declare local variables and then
never use them?
[...]
It happens a lot when you're debugging code (temporarily
comment out
some stuff for testing purposes). It would be a major pain if
every
single time you need to temporarily suppress a section of
On 4/21/12, H. S. Teoh wrote:
> It would be a major pain if every
> single time you need to temporarily suppress a section of code, you also
> have to hunt down every last stray variable that's now no longer
> referenced in the function and comment them out as well.
Next thing you know the compil
On Sat, Apr 21, 2012 at 01:03:13PM +0100, Stewart Gordon wrote:
> On 20/04/2012 01:53, Andrej Mitrovic wrote:
[...]
> >It is an error to declare a local variable that is never referred to.
> >Dead variables, like anachronistic dead code, are just a source of
> >confusion for maintenance programmers
On 20/04/2012 01:53, Andrej Mitrovic wrote:
Can I remove this section from the D docs, in functions? :
"
Local Variables
It is an error to use a local variable without first assigning it a
value. The implementation may not always be able to detect these
cases. Other language compilers sometimes
On Friday, April 20, 2012 02:53:25 Andrej Mitrovic wrote:
> Can I remove this section from the D docs, in functions? :
>
> "
> Local Variables
> It is an error to use a local variable without first assigning it a
> value. The implementation may not always be able to detect these
> cases. Other lan
Can I remove this section from the D docs, in functions? :
"
Local Variables
It is an error to use a local variable without first assigning it a
value. The implementation may not always be able to detect these
cases. Other language compilers sometimes issue a warning for this,
but since it is alwa
33 matches
Mail list logo