ISO Studies of underscores vs MixedCase in Ada or C++

P

Peter Ammon

Wes said:
Does Dylan prevent having variables named Max,
Max-Iterations, & Iterations in the same scope?

No. Whitespace is more important in Dylan than in a language like C.

Max-Iterations <-- variable name
Max - Iterations <-- Max minus Iterations

Other strange characters can appear in Dylan variable names. This
allows for some nice naming conventions without the nastiness of
something like Hungarian Notation. See
http://www.gwydiondylan.org/gdref/tutorial/naming-conventions.html

-Peter
 
S

Steve

If you happen to be use GNAT (GNU Ada), the compiler does do some degree of
spell checking.

gcc -c dointxor.adb
dointxor.adb:30:28: "b_valu" is undefined
dointxor.adb:30:28: possible misspelling of "b_value"
gnatmake: "dointxor.adb" compilation error

If you use the GPS for programming Ada, you'll get a little wrench icon next
to the error in the output window. If you click on the wrench it corrects
the spelling error.

If you're really interested in having comments spell checked, the folks at
ACT (Ada Core Techologies) would probably add the feature for a fee.

Steve
(The Duck)


[snip]
 
M

Matt Gregory

James said:
(I usually rewind a file with "lseek(fd, 0L, 0)" because I can't
remember if 0 is SEEKSET or SEEK_SET.)

The Vim editor is cool for things like this because you can add your
own words to the syntax highlighting. I write Windows programs and
I have over a hundred typedef's and constants in my word list.
Actually, Vim's C syntax file comes with the standard C constants
and typedef's highlighted.
 
M

Matt Gregory

Peter said:
Agreed! I wish that more languages allowed hyphen use in identifiers.
Dylan is the only one I can think of off the top of my head.

Lisp and Scheme.
 
L

Leif Roar Moldskred

Steve said:
If you happen to be use GNAT (GNU Ada), the compiler does do some degree of
spell checking.

gcc -c dointxor.adb
dointxor.adb:30:28: "b_valu" is undefined
dointxor.adb:30:28: possible misspelling of "b_value"
gnatmake: "dointxor.adb" compilation error

That's not really spell-checking though - it doesn't check "b_value" to see
if "value" is a proper word in English.
 
L

Leif Roar Moldskred

Kevin Morenski said:
Let's say you had a variable named "tHTa," for example. With respect to
your concept, this would be a misspelling of the word "that." Now, a lot of
programmers--myself included--use letters to represent certain things in
variable names. tHTa could mean "type HTa" or anything else a programmer
could think of. How could a program possibly differentiate between
conventions in the naming of variables?

In the same way that spell-checkers for ordinary text today handles names and
other words that are correct, but not in the dictionary: When detecting the
unknown word the first time, ask the user what to do with it - whether to
correct it, accept this instance, accept all instances in this document or
add it to your private dictionary. (For a spell-checking of source-code we'd
probably also want the option "accept all instances with this case.")

This really isn't any different from the same problem in regular text,
except that your programming convention might cause a lot of unknown
words to appear. If that's a major headache, just don't spell-check.
 
J

Jakob Bieling

Leif Roar Moldskred said:
That's not really spell-checking though - it doesn't check "b_value" to see
if "value" is a proper word in English.


But it is that kind of word-matching I would personally like to see in
more compilers (specifically C++ compilers).

I do agree with Kevin Morenski (that a
real spell-checker for source code is not practicable. You said that the
spell-checker would just have to ask you whether to ignore it or how else to
proceed. Have you thought about how annoying 100s or even 1000s of those
messages boxes, asking how to proceed, will be when compiling already
existing source with this spell-checker?

regards
 
G

Georg Bauhaus

: :: > Agreed! I wish that more languages allowed hyphen use in
:: identifiers. > Dylan is the only one I can think of off the top of
:: my head.
::
:: Lisp and Scheme.

: COBOL

Also a few languages, like SNOBOL4, that allow you to have
any string as a variable name,

$'The Shoemaker - page 3' = 'Once upon a time'

ML allows minus {minus} as identifiers, and also ":->" and the like,
though not ":)".


Georg
 
L

Leif Roar Moldskred

Jakob Bieling said:
But it is that kind of word-matching I would personally like to see in
more compilers (specifically C++ compilers).

I do agree with Kevin Morenski (that a
real spell-checker for source code is not practicable. You said that the
spell-checker would just have to ask you whether to ignore it or how else to
proceed. Have you thought about how annoying 100s or even 1000s of those
messages boxes, asking how to proceed, will be when compiling already
existing source with this spell-checker?

Oh, I wouldn't want it to be part of the compiler, or continiously on. Rather,
I'd just want to be able to run a command in my editor to spell-check the
source-code I'm currently working on - much like I today invoke ispell in
emacs for regular text files.
 
D

Default User

James said:
(I usually rewind a file with "lseek(fd, 0L, 0)" because I can't
remember if 0 is SEEKSET or SEEK_SET.)


The best choice for rewinding a stdio file stream is rewind().




Brian Rodenborn
 
J

Jakob Bieling

Leif Roar Moldskred said:
Oh, I wouldn't want it to be part of the compiler, or continiously on. Rather,
I'd just want to be able to run a command in my editor to spell-check the
source-code I'm currently working on - much like I today invoke ispell in
emacs for regular text files.


Ah, I did not consider this difference even. *g* My point was, checking
my own identifier names for spelling errors based on natural language rules
is a bad idea. Instead, a special code-spell-checker would be great:

a/ 'Created' identifiers are automatically added to the list of known
words (for the current compilation run only)
b/ When an identifier is used, but not found, the spell-checker tries to
find out what I meant (like any spell-checker)
c/ Comments are spell-checked like in any other word processor, except
that identifier names should also be considered

So let us assume we have this (rather useless) piece of C++ code:

1 int main ()
2 {
3 char* pRok = new char;
4 *pork = 'p';
5 delete pRok; // do not forget t delete pRok!
6 }

In line 3, the spell-checker should not question the identifier name and
try to tell me that I meant 'pork' (see a/ above). Instead, it should tell
me in line 4 that I most probably meant 'pRok' and not 'pork' (see b/
above). And last but not least, in line 5, the spell-checker should point
out the missing 'o' (ie. ".. forget to ..") but leave 'pRok' undiagnosed.

regards
 
F

Frank J. Lhota

Default User said:
The best choice for rewinding a stdio file stream is rewind().

Nah, rewind() makes me think of tapes, and that makes me feel old.
 
J

John W. Krahn

Georg said:
: :: > Agreed! I wish that more languages allowed hyphen use in
:: identifiers. > Dylan is the only one I can think of off the top of
:: my head.
::
:: Lisp and Scheme.

: COBOL

Also a few languages, like SNOBOL4, that allow you to have
any string as a variable name,

$'The Shoemaker - page 3' = 'Once upon a time'

You can do the same thing in Perl:

${'The Shoemaker - page 3'} = 'Once upon a time';

And since perl interpolates in double quoted strings you can include any
8 bit value:

${"\xFF\0\t\cV"} = 'Once upon a time';


John
 
W

William

Jim Rogers said:
"William" <[email protected]> wrote in message

Even more to the point -- any compiler should be
able to properly recognize reserved words.
Why use another tool to check what the compiler will also check?

Until we got faster machines, one of our builds could take an hour.
No fun to have the compiler detect a mispelled word 50 minutes in.
(Sure, if everyone did an incremental test build, the problem would
be avoided, but...) -Wm
 
W

William

Leif Roar Moldskred said:
In the same way that spell-checkers for ordinary text today handles names and
other words that are correct, but not in the dictionary: When detecting the
unknown word the first time, ask the user what to do with it - whether to
correct it, accept this instance, accept all instances in this document or
add it to your private dictionary. (For a spell-checking of source-code we'd
probably also want the option "accept all instances with this case.")

Well, they will if you add the entire label to the dictionary, but none I'm
aware
of will break up words based on mixed-case. Ultraedit will break up words
on underscores - didn't know that until I just tried it I can make it ignore
mixed-case words, but not break them apart. (It does support multiple user
dictionaries, so you could have a dictionary-per-project defining all the
approved labels.) -Wm
 
D

Dave Thompson

On Fri, 03 Oct 2003 15:42:20 -0700, Peter Ammon
Agreed! I wish that more languages allowed hyphen use in identifiers.
Dylan is the only one I can think of off the top of my head.
COBOL ! Only embedded, though. My compiler accepts -X as minus X with
a warning, but I don't think that's standard.

Also the usual suspects: FORTH allows everything but space (and
controls); and LISP everything but space, parens, period, quote,
backquote, and undoubled slash, if I haven't forgotten anything.

- David.Thompson1 at worldnet.att.net
 
R

Robert Stankowic

Kevin Morenski said:
Let's say you had a variable named "tHTa," for example. With respect to
your concept, this would be a misspelling of the word "that." Now, a lot of
programmers--myself included--use letters to represent certain things in
variable names. tHTa could mean "type HTa" or anything else a programmer
could think of. How could a program possibly differentiate between
conventions in the naming of variables?

It's much simpler to check the spelling of comments...programmers have
developed so many conventions for making their lives easier; a spell checker
on variable names just adds one more problem to overcome.

An editor which is capable of finding the definition of variables and
highlighting a name already defined/declared might solve that problem. VB
has that feature to a certain degree - if you use mixed case for names of
variables, functions etc. and you type a name already declared in lowercase
the editor will automatically convert it to the form in which it is
declared. If you know, the name is declared and case does not flip you know
you made a typo. IIRC Keil development system for embedded C programming has
a similar feature.

just my $0.02
Robert
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,145
Messages
2,570,826
Members
47,372
Latest member
LucretiaFo

Latest Threads

Top