Re: Unused variables and bugs

2014-08-24 Thread Brendan Zabarauskas via Digitalmars-d
I use Rust a reasonable amount, and the 'unused variable', 'unused field' and 'unused item' family of lints help a great deal in picking up mistakes early, especially when refactoring. Don't ask me to cite specific examples though - because they are enabled by default the issues are usually

Re: Unused variables and bugs

2014-08-24 Thread Idan Arye via Digitalmars-d
On Sunday, 24 August 2014 at 02:23:11 UTC, ketmar via Digitalmars-d wrote: On Sat, 23 Aug 2014 15:48:03 + Idan Arye via Digitalmars-d digitalmars-d@puremagic.com wrote: How about unused arguments in lambda expressions? also, make compiler accept 'auto' in lambdas. i'm sure it should. and

Re: Unused variables and bugs

2014-08-24 Thread ketmar via Digitalmars-d
On Sun, 24 Aug 2014 19:39:31 + Idan Arye via Digitalmars-d digitalmars-d@puremagic.com wrote: Currenly foreach does not accept type-without-argument - `foreach(int; [1,2,3])` is a compiler error - so that's much bigger a change than adding argument-less type inference for lambdas. ah,

Re: Unused variables and bugs

2014-08-23 Thread Idan Arye via Digitalmars-d
On Saturday, 23 August 2014 at 04:07:58 UTC, ketmar via Digitalmars-d wrote: On Sat, 23 Aug 2014 03:50:13 + via Digitalmars-d digitalmars-d@puremagic.com wrote: - versioning refactor it, so that shared code goes to separate functions. nested functions especially helpful here. i'm used to

Re: Unused variables and bugs

2014-08-23 Thread ketmar via Digitalmars-d
On Sat, 23 Aug 2014 15:48:03 + Idan Arye via Digitalmars-d digitalmars-d@puremagic.com wrote: How about unused arguments in lambda expressions? also, make compiler accept 'auto' in lambdas. i'm sure it should. and it should accept 'auto' in foreach(). it should also allow foreach like this:

Unused variables and bugs

2014-08-22 Thread bearophile via Digitalmars-d
Apparently there is evidence that unused variables in C-like languages correlate with bugs: https://kev.inburke.com/slides/errors/#error-correlations One problem with ruling out some classes of unused variables (like unused function arguments, unused private module-level variables, unused

Re: Unused variables and bugs

2014-08-22 Thread Brian Schott via Digitalmars-d
On Friday, 22 August 2014 at 19:07:24 UTC, bearophile wrote: Another solution is to leave such tests out of the core compiler, and put them in a lint tool that you run when you think your code is in good shape. https://github.com/Hackerpilot/Dscanner The unused variable and unused parameter

Re: Unused variables and bugs

2014-08-22 Thread bearophile via Digitalmars-d
Brian Schott: The unused variable and unused parameter checks have existed since May. As far as I know it only gives false positives if mixin statements are present. Another interesting feature is similar to -Wsuggest-final-types and -Wsuggest-final-methods. They give warnings when there is

Re: Unused variables and bugs

2014-08-22 Thread Timon Gehr via Digitalmars-d
On 08/22/2014 09:07 PM, bearophile wrote: Apparently there is evidence that unused variables in C-like languages correlate with bugs: https://kev.inburke.com/slides/errors/#error-correlations ... http://xkcd.com/552/

Re: Unused variables and bugs

2014-08-22 Thread bearophile via Digitalmars-d
Timon Gehr: http://xkcd.com/552/ What better alternative do you suggest in practice? The only better solution I remember that was used for a language design is the : added to Python after some controlled experiments done on users. Relying on experimental correlations (if the analysis is

Re: Unused variables and bugs

2014-08-22 Thread Ary Borenszweig via Digitalmars-d
On 8/22/14, 6:46 PM, bearophile wrote: Currently a group of people are trying to design a language pushing to the extreme the idea of design by committee, it's future a peer reviewed language meant to be used for scientific programming. I've taken a look at its syntax and I was not happy with

Re: Unused variables and bugs

2014-08-22 Thread bearophile via Digitalmars-d
Ary Borenszweig: What language is that? I don't remember its name, of course. I have just scanned the last few months of the LambdaTheUltimate blog without success. Bye, bearophile

Re: Unused variables and bugs

2014-08-22 Thread Timon Gehr via Digitalmars-d
On 08/23/2014 01:32 AM, Timon Gehr wrote: you seemed to suggest in the OT. OP

Re: Unused variables and bugs

2014-08-22 Thread Timon Gehr via Digitalmars-d
On 08/22/2014 11:46 PM, bearophile wrote: Timon Gehr: http://xkcd.com/552/ ... My point is just that this correlation is not a strong data point supporting putting effort into elimination of unused variables. It is possible that all this will accomplish is that unused variables will no

Re: Unused variables and bugs

2014-08-22 Thread Brian Schott via Digitalmars-d
On Friday, 22 August 2014 at 23:32:54 UTC, Timon Gehr wrote: The correlation only indicates that poor code tends to have more unused variables. If one eliminates unused variables just for the sake of eliminating unused variables, code quality will most likely not magically increase. I would

Re: Unused variables and bugs

2014-08-22 Thread Timon Gehr via Digitalmars-d
On 08/23/2014 02:03 AM, Brian Schott wrote: On Friday, 22 August 2014 at 23:32:54 UTC, Timon Gehr wrote: The correlation only indicates that poor code tends to have more unused variables. If one eliminates unused variables just for the sake of eliminating unused variables, code quality will

Re: Unused variables and bugs

2014-08-22 Thread ketmar via Digitalmars-d
On Fri, 22 Aug 2014 21:46:44 + bearophile via Digitalmars-d digitalmars-d@puremagic.com wrote: What better alternative do you suggest in practice? don't declare unused variables. really, this is extremely easy. my 15+ years of expirience in writing projects of different scale shows that good

Re: Unused variables and bugs

2014-08-22 Thread via Digitalmars-d
On Saturday, 23 August 2014 at 02:48:15 UTC, ketmar via Digitalmars-d wrote: don't declare unused variables. really, this is extremely easy. my 15+ years of expirience in writing projects of different scale What about: - versioning - debugging (commenting out debugging code) - virtual

Re: Unused variables and bugs

2014-08-22 Thread ketmar via Digitalmars-d
On Sat, 23 Aug 2014 03:50:13 + via Digitalmars-d digitalmars-d@puremagic.com wrote: - versioning refactor it, so that shared code goes to separate functions. nested functions especially helpful here. i'm used to this GCC extension. - debugging (commenting out debugging code) why comment it

Re: Unused variables and bugs

2014-08-22 Thread Ola Fosheim Gr via Digitalmars-d
On Saturday, 23 August 2014 at 04:07:58 UTC, ketmar via Digitalmars-d wrote: On Sat, 23 Aug 2014 03:50:13 + via Digitalmars-d digitalmars-d@puremagic.com wrote: - versioning refactor it, so that shared code goes to separate functions. nested functions especially helpful here. i'm used to