Re: spell check in code

2011-03-17 Thread Moritz Lenz


On 03/17/2011 09:55 PM, Darren Duncan wrote:
> It occurs to me, both from my own experience in writing code as well as seeing
> some production code by others, that spell-checking may be useful in 
> programming
> languages.
> 
> To be specific, often user-defined entities such as variable or routine names 
> or
> attribute names or type names may be declared with dictionary words, but
> sometimes they may be misspelled, and programmers may not always spot this.
> 
> I think it would be useful for programming language implementations to 
> provide 
> the option to flag entity names that appear to be mis-spelled dictionary
> words for programmers.

Depends on what you mean by "programming language implementations". If
you are talking about tools like lint, I fully agree. If are talking
about the compiler, I'm afraid I have to disagree -- it's not their job.

The good news is that we already have STD.pm6, which gives you parse
tree and makes it rather easy to extract identifiers. You can write such
a tool today.

And even better, since niecza uses STD.pm6 for bootstrapping (*), you
can even write such a tool in Perl 6 today. Have fun!

(*) actually a slightly simplified version, but still quite the same in
structure

Cheers,
Moritz


spell check in code

2011-03-17 Thread Darren Duncan

It occurs to me, both from my own experience in writing code as well as seeing
some production code by others, that spell-checking may be useful in programming
languages.

To be specific, often user-defined entities such as variable or routine names or
attribute names or type names may be declared with dictionary words, but
sometimes they may be misspelled, and programmers may not always spot this.

I think it would be useful for programming language implementations to provide 
the option to flag entity names that appear to be mis-spelled dictionary

words for programmers.

This could also be in text editors, but it could be useful in the compiler also.

What would make this different from applying a generic spell checker, is that 
the code-savvy one would know to take entity names and recognize 
underscore-separated or mixed-caps or mixed letters and numbers etc and parse 
out the component words, so to evaluate those components, rather than looking at 
words as just entire strings delimited by non-alphanumeric characters.


Not applicable everywhere, but useful in some places.

Of course, this would be an extension feature, not a core feature.

-- Darren Duncan