[comp.lang.misc] Hyphen as identifier characters

sommar@enea.se (Erland Sommarskog) (02/20/90)

Norman K. Shelley (shelley@atc.sps.mot.com) writes:
>I would like to propose that the hyphen be added to the default alphabet for
>identifiers and that the hyphen take over the accepted use of the
>underscore for separating words in an identifier.
>
>Page 240 of "Eiffel: The Language" states that "internal upper-case letters ...
>as in putAtRight, contradicts the standard conventions of English ...
>and is not part of the recommended style."  I agree BUT must note that the
>underscore ('_') as a word separator is NOT English either.  A whitespace
>is the accepted standard but computers have troubles with whitespace in
>names/labels so what do we do?  Common Lisp uses hypens ('-') as a
>separator and this has more acceptance in English than an underscore.

Since hyphens are used for minus signs to, introducing them
is not trivial, particulary not in an existsing language. E.g,
      c:=a-b;
would suddenly be ambiguous. Now, I stopped writing my code like
that many years ago, but I know too many who haven't.

It's correct that the underscore is not a word separator normally,
but one could think of it as a space. Hyphens on the other hand
has a meaning of it's own. If I could chose I might call a variable
end-of-file_mark, and thus use the hyphen as in normal language.
It would be more fun if we make the compilers handle space in names,
I agree.

Finally, there are situations where case shifts definitely are better
than underscores or hyphens, to wit: when you have a limited number
of significant characters. A case shift says the same in zero
characters as an underscore does in one.



-- 
Erland Sommarskog - ENEA Data, Stockholm - sommar@enea.se

freek@fwi.uva.nl (Freek Wiedijk) (02/20/90)

In article <776@enea.se> sommar@enea.se (Erland Sommarskog) writes:
 >Since hyphens are used for minus signs to, introducing them
 >is not trivial, particulary not in an existsing language. E.g,
 >      c:=a-b;
 >would suddenly be ambiguous.

In Ada it would be worse! :-)

	n:=n-foo-bar--subtract foo-bar from n

--
Freek "the Pistol Major" Wiedijk                  Path: uunet!fwi.uva.nl!freek
#P:+/ = #+/P?*+/ = i<<*+/P?*+/ = +/i<<**P?*+/ = +/(i<<*P?)*+/ = +/+/(i<<*P?)**

tainter@cbnewsd.ATT.COM (johnathan.tainter) (02/21/90)

In article <776@enea.se> sommar@enea.se (Erland Sommarskog) writes:
>Norman K. Shelley (shelley@atc.sps.mot.com) writes:
>>I would like to propose that the hyphen be added to the default alphabet for
>>identifiers and that the hyphen take over the accepted use of the
>>underscore for separating words in an identifier.

This would (in a reasonable design) preclude the use of '-' for arithmetic,
set notation and other operators then.  Design such a language if you want
but also give it only prefix operators or postfix operators.

>>as in putAtRight, contradicts the standard conventions of English ...
>>and is not part of the recommended style."  I agree BUT must note that the
>>underscore ('_') as a word separator is NOT English either.  A whitespace
>>is the accepted standard but computers have troubles with whitespace in
>>names/labels so what do we do?  Common Lisp uses hypens ('-') as a
>>separator and this has more acceptance in English than an underscore.

Well, since underscore isn't used as a typesetting character unto itself then
foo_bar must be foo, an underlined space, and then bar.  Why one would
underline just the space in "english" I can't imagine but I don't think it
violates any "rules".  In C it is quite sensable.  I find this analog to
"english" just as acceptable as hyphen when you look at what it really is.

>Erland Sommarskog - ENEA Data, Stockholm - sommar@enea.se


--johnathan.a.tainter--
   att!ihlpb!tainter

sommar@enea.se (Erland Sommarskog) (02/25/90)

Freek Wiedijk (freek@fwi.uva.nl) writes:
>I said:
> >Since hyphens are used for minus signs to, introducing them
> >is not trivial, particulary not in an existsing language. E.g,
> >      c:=a-b;
> >would suddenly be ambiguous.
>
>In Ada it would be worse! :-)
>
>	n:=n-foo-bar--subtract foo-bar from n

I don't understand what would make things worse in Ada. OK,
I see that postponing the semi-colon to the next line you can
mess it up with the comment delimiter.

Incidently, if I'm not totally confused, the comment 
   subtract foo-bar from n
is perfectly correct Cobol, including the hyphen.
-- 
Erland Sommarskog - ENEA Data, Stockholm - sommar@enea.se

harrison@necssd.NEC.COM (Mark Harrison) (02/28/90)

In article <810@enea.se>, sommar@enea.se (Erland Sommarskog) writes:

> Incidently, if I'm not totally confused, the comment 
>    subtract foo-bar from n
> is perfectly correct Cobol, including the hyphen.

as is 
     compute n = n - foo-bar.
       or
     compute n = n + -foo-bar.

Cobol requires spaces around arithmetic operators.