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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Leif Roar Moldskred

    #46
    Re: Spell-checking source code (Was: ISO Studies of underscores...)

    "Kevin Morenski" <km@nospam.geek center.net> writes:
    [color=blue]
    > 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?[/color]

    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.

    --
    Leif Roar Moldskred

    Comment

    • Martin Dowie

      #47
      Re: ISO Studies of underscores vs MixedCase in Ada or C++

      "Matt Gregory" <bleah-no-more-spam@earthlink. net> wrote in message
      news:BPvfb.2044 5[color=blue][color=green]
      > > 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.[/color]
      >
      > Lisp and Scheme.[/color]

      COBOL


      Comment

      • Jakob Bieling

        #48
        Re: Spell-checking source code (Was: ISO Studies of underscores...)

        "Leif Roar Moldskred" <rmoldskr@onlin e.no> wrote in message
        news:86zngh5oct .fsf@huldreheim .huldreskog.no. ..[color=blue]
        > "Steve" <nospam_steved9 4@comcast.net> writes:
        >[color=green]
        > > If you happen to be use GNAT (GNU Ada), the compiler does do some degree[/color][/color]
        of[color=blue][color=green]
        > > 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.a db" compilation error[/color]
        >
        > That's not really spell-checking though - it doesn't check "b_value" to[/color]
        see[color=blue]
        > if "value" is a proper word in English.[/color]


        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 (news:3f7df3af_ 2@nntp2.nac.net ) 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
        --
        jb

        (replace y with x if you want to reply by e-mail)


        Comment

        • Corey Murtagh

          #49
          Re: ISO Studies of underscores vs MixedCase in Ada or C++

          Martin Dowie wrote:
          [color=blue]
          > "Matt Gregory" <bleah-no-more-spam@earthlink. net> wrote in message
          > news:BPvfb.2044 5
          >[color=green][color=darkred]
          >>>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.[/color]
          >>
          >>Lisp and Scheme.[/color]
          >
          > COBOL[/color]

          Isn't there a variation of Godwin's Law covering COBOL? :>

          --
          Corey Murtagh
          The Electric Monk
          "Quidquid latine dictum sit, altum viditur!"

          Comment

          • CBFalconer

            #50
            Re: ISO Studies of underscores vs MixedCase in Ada or C++

            Matt Gregory wrote:[color=blue]
            > Peter Ammon wrote:[color=green]
            > > Programmer Dude wrote:
            > >[/color][/color]
            .... snip ...[color=blue][color=green][color=darkred]
            > >>
            > >> (In proportional fonts, hyphens are usually skinnier than
            > >> underscores and (to my eye) make the text more readable.
            > >> It's not as noticable with monospace fonts, but I think the
            > >> lower example looks better (read: more readable :-).)[/color]
            > >
            > > 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.[/color]
            >
            > Lisp and Scheme.[/color]

            Cobol

            --
            Chuck F (cbfalconer@yah oo.com) (cbfalconer@wor ldnet.att.net)
            Available for consulting/temporary embedded and systems.
            <http://cbfalconer.home .att.net> USE worldnet address!


            Comment

            • Georg Bauhaus

              #51
              Re: ISO Studies of underscores vs MixedCase in Ada or C++

              >>>>> "Martin" == Martin Dowie <martin.dowie@b topenworld.com> writes:

              : "Matt Gregory" <bleah-no-more-spam@earthlink. net> wrote in message
              : news:BPvfb.2044 5
              :: > 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

              Comment

              • Leif Roar Moldskred

                #52
                Re: Spell-checking source code (Was: ISO Studies of underscores...)

                "Jakob Bieling" <netsurf@gmy.ne t> writes:
                [color=blue]
                > 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 (news:3f7df3af_ 2@nntp2.nac.net ) 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?[/color]

                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.

                --
                Leif Roar Moldskred

                Comment

                • Default User

                  #53
                  Re: ISO Studies of underscores vs MixedCase in Ada or C++

                  James Dow Allen wrote:
                  [color=blue]
                  > (I usually rewind a file with "lseek(fd, 0L, 0)" because I can't
                  > remember if 0 is SEEKSET or SEEK_SET.)[/color]


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




                  Brian Rodenborn

                  Comment

                  • Jakob Bieling

                    #54
                    Re: Spell-checking source code (Was: ISO Studies of underscores...)

                    "Leif Roar Moldskred" <rmoldskr@onlin e.no> wrote in message
                    news:86r81s6elg .fsf@huldreheim .huldreskog.no. ..[color=blue]
                    > "Jakob Bieling" <netsurf@gmy.ne t> writes:
                    >[color=green]
                    > > But it is that kind of word-matching I would personally like to see[/color][/color]
                    in[color=blue][color=green]
                    > > more compilers (specifically C++ compilers).
                    > >
                    > > I do agree with Kevin Morenski (news:3f7df3af_ 2@nntp2.nac.net ) that[/color][/color]
                    a[color=blue][color=green]
                    > > 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[/color][/color]
                    else to[color=blue][color=green]
                    > > 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?[/color]
                    >
                    > Oh, I wouldn't want it to be part of the compiler, or continiously on.[/color]
                    Rather,[color=blue]
                    > 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.[/color]


                    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
                    --
                    jb

                    (replace y with x if you want to reply by e-mail)


                    Comment

                    • Frank J. Lhota

                      #55
                      Re: ISO Studies of underscores vs MixedCase in Ada or C++

                      "Default User" <first.last@com pany.com> wrote in message
                      news:3F7F143E.C C680533@company .com...[color=blue]
                      > The best choice for rewinding a stdio file stream is rewind().[/color]

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


                      Comment

                      • John W. Krahn

                        #56
                        Re: ISO Studies of underscores vs MixedCase in Ada or C++

                        Georg Bauhaus wrote:[color=blue]
                        >[color=green][color=darkred]
                        > >>>>> "Martin" == Martin Dowie <martin.dowie@b topenworld.com> writes:[/color][/color]
                        >
                        > : "Matt Gregory" <bleah-no-more-spam@earthlink. net> wrote in message
                        > : news:BPvfb.2044 5
                        > :: > 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'[/color]

                        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
                        --
                        use Perl;
                        program
                        fulfillment

                        Comment

                        • William

                          #57
                          Re: Spell-checking source code (Was: ISO Studies of underscores...)

                          "Jim Rogers" <jimmaureenroge rs@worldnet.att .net> wrote in message
                          news:82347202.0 310031148.1284a 52b@posting.goo gle.com...[color=blue]
                          > "William" <Reply@NewsGrou p.Please> wrote in message[/color]
                          news:<udWdnVqpx L43GeCiRVn-uw@giganews.com >...[color=blue][color=green]
                          > > Talking to myself here... I occurred to me that its syntax highlighting
                          > > makes spell checking reserved words less necessary - and the syntax
                          > > highlighting can deal with case. -Wm[/color]
                          >
                          > 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?[/color]

                          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


                          Comment

                          • William

                            #58
                            Re: Spell-checking source code (Was: ISO Studies of underscores...)

                            "Leif Roar Moldskred" <rmoldskr@onlin e.no> wrote in message
                            news:86vfr55o45 .fsf@huldreheim .huldreskog.no. ..[color=blue]
                            >
                            > In the same way that spell-checkers for ordinary text today handles names[/color]
                            and[color=blue]
                            > other words that are correct, but not in the dictionary: When detecting[/color]
                            the[color=blue]
                            > 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[/color]
                            we'd[color=blue]
                            > probably also want the option "accept all instances with this case.")[/color]

                            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



                            Comment

                            • Dave Thompson

                              #59
                              Re: ISO Studies of underscores vs MixedCase in Ada or C++

                              On Fri, 03 Oct 2003 15:42:20 -0700, Peter Ammon
                              <peter_ammon@ro cketmail.com> wrote:
                              <snip>[color=blue][color=green]
                              > > Or my preference if the tool allows
                              > >
                              > > classmethod :
                              > > access-specifier
                              > > method-type-specifier
                              > > method-return-type-specifier
                              > > method-declaration
                              > > method-body
                              > >
                              > > (In proportional fonts, hyphens are usually skinnier than
                              > > underscores and (to my eye) make the text more readable.
                              > > It's not as noticable with monospace fonts, but I think the
                              > > lower example looks better (read: more readable :-).)[/color]
                              >
                              > 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.
                              >[/color]
                              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.ne t

                              Comment

                              • Robert Stankowic

                                #60
                                Re: Spell-checking source code (Was: ISO Studies of underscores...)


                                "Kevin Morenski" <km@nospam.geek center.net> schrieb im Newsbeitrag
                                news:3f7df3af_2 @nntp2.nac.net. ..[color=blue][color=green]
                                > > // Number of misspelled words fuond so far
                                > > int noErorsInTetx = 0;
                                > >
                                > > I want to spell-check this such that I get notified both on "fuond"
                                > > for "found", "Erors" for "Errors" and "Tetx" for "Text". They are all,
                                > > after all, words in natural language, and it should be possible to
                                > > spell-check them automatically.[/color]
                                >
                                > 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[/color]
                                of[color=blue]
                                > 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...prog rammers have
                                > developed so many conventions for making their lives easier; a spell[/color]
                                checker[color=blue]
                                > on variable names just adds one more problem to overcome.[/color]

                                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


                                Comment

                                Working...