Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > would it be possible to use minus in identifiers ?

Reply
Thread Tools

would it be possible to use minus in identifiers ?

 
 
fir
Guest
Posts: n/a
 
      06-09-2013
would it be possible to use minus sign in c
identifiers (I mean function names and variable
names for example

int my-foo()
{

}

int some-a-wariable = 10;

I mean would it be possible to write c
like compiler that would allow that or not?
I could without knowing it, risk the theorem
that it would be pososible but i do not know,
maybe some unavoidable syntax conflict would
arise (?) (or will they not?)

 
Reply With Quote
 
 
 
 
Xavier Roche
Guest
Posts: n/a
 
      06-09-2013
Le 09/06/2013 16:36, fir a Úcrit :
> would it be possible to use minus sign in c
> identifiers (I mean function names and variable
> names for example


No. How would you resolve "a=b-c;" ?

 
Reply With Quote
 
 
 
 
Noob
Guest
Posts: n/a
 
      06-09-2013
fir wrote:

> Would it be possible to write C like compiler that would allow [feature X] ?


-> comp.compilers is over there.

 
Reply With Quote
 
fir
Guest
Posts: n/a
 
      06-09-2013
W dniu niedziela, 9 czerwca 2013 16:43:43 UTC+2 użytkownik Xavier Roche napisał:
> Le 09/06/2013 16:36, fir a ├ęcrit :
>
> > would it be possible to use minus sign in c
> > identifiers (I mean function names and variable
> > names for example

>
>
>
> No. How would you resolve "a=b-c;" ?



"b-c" should be looked up in bag of defined
identifiers ir found b-c would be symbol name if
no b and c would be symbol names - This example
compiler could process, worse that it is 'ambiguous'
for human reader

 
Reply With Quote
 
Ivan Shmakov
Guest
Posts: n/a
 
      06-09-2013
>>>>> fir <(E-Mail Removed)> writes:
>>>>> użytkownik Xavier Roche napisał:
>>>>> Le 09/06/2013 16:36, fir a ├ęcrit :


>>> would it be possible to use minus sign in c identifiers (I mean
>>> function names and variable names for example


>> No. How would you resolve "a=b-c;" ?


> "b-c" should be looked up in bag of defined identifiers if found b-c
> would be symbol name if no b and c would be symbol names - This
> example compiler could process, worse that it is 'ambiguous' for
> human reader


... And a human writer.

Unless one always separates the operators and their operands
with whitespace, he or she could write a=b-c with an intended
meaning of /either/ a = (b) - (c) /or/ a = (b-c).

I know of no good reason to invent one another "C-like"
language, either. (Unless the implementors are backed by some
Really Big Enterprise, that is.)

--
FSF associate member #7257
 
Reply With Quote
 
fir
Guest
Posts: n/a
 
      06-09-2013
>
>
> > "b-c" should be looked up in bag of defined identifiers if found b-c
> > would be symbol name if no b and c would be symbol names - This
> > example compiler could process, worse that it is 'ambiguous' for
> > human reader

>
>
>
> ... And a human writer.
>
>
>
> Unless one always separates the operators and their operands
> with whitespace, he or she could write a=b-c with an intended
> meaning of /either/ a = (b) - (c) /or/ a = (b-c).
>


ye, youre right it maybe may be done at the big
cost of forcing of writing (sorry for my weak
english) spaces around minus signs a=b - c
- this is a big cost, so nevermind, tnx for answers

 
Reply With Quote
 
glen herrmannsfeldt
Guest
Posts: n/a
 
      06-09-2013
fir <(E-Mail Removed)> wrote:

> would it be possible to use minus sign in c
> identifiers (I mean function names and variable
> names for example


> int my-foo()
> {
>
> }


Most high-level languages, and even most assemblers, allow for the '-'
character to be used as a unary or binary operator. There is not
a requirement that one do that, though.

The TeX language allows one to redefine that category code of
characters, such that one could change the meaning of '-' to
catcode letter. (Hopefully after macros have been processed that
use it as a negation.) (TeX is interpreted in a way that the catcode
can be changed dynamically, with predictable results.)

The BCDIC character set used by the IBM 704 and successor machines
has two '-' characters: 0x0c and 0x20. (Card punch 8-4 and 11,
repectively.) The original Fortran compiler used 0x20 for program
source files, either for program input data, and 0x0c for output
from the compiled program.

There is a complicated history of character codes on the IBM
commercial and scientific computers that had to be resolved in
the definition of EBCDIC and S/360.

-- glen
 
Reply With Quote
 
BartC
Guest
Posts: n/a
 
      06-09-2013


"fir" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> would it be possible to use minus sign in c
> identifiers (I mean function names and variable
> names for example
>
> int my-foo()
> {
>
> }
>
> int some-a-wariable = 10;
>
> I mean would it be possible to write c
> like compiler that would allow that or not?
> I could without knowing it, risk the theorem
> that it would be pososible but i do not know,
> maybe some unavoidable syntax conflict would
> arise (?) (or will they not?)


Use "_" instead of "-".

There are too many ambiguities otherwise, unless minus is always surrounded
by white-space (or anything that is not part of an identifier).

So a-b-c-d-e I think could be interpreted 16 different ways. There are also
problems with the symbols "--", "->" and "-=".

And, with your idea of having a-b mean either a-b or a - b depending on
whether "a-b" is an identifier in scope, then you'd be able to
ite: -----------------, which could mean almost anything (it could be one
identifier, or N identifiers separated with minuses), depending on whether
identifiers could start with "-" or not.

It's not practical in an established language and syntax style anyway, and
probably wouldn't be a good idea in a new language. (Some languages do allow
"-" in identifiers; but not languages you'd want to use.)

--
Bartc

 
Reply With Quote
 
none
Guest
Posts: n/a
 
      06-09-2013
In article <Kf3tt.22437$(E-Mail Removed)4>, BartC <(E-Mail Removed)> wrote:
>"fir" <(E-Mail Removed)> wrote in message
>news:(E-Mail Removed)...
>>
>> would it be possible to use minus sign in c
>> identifiers (I mean function names and variable
>> names
>> int my-foo()

>...
>It's not practical in an established language and syntax style anyway,
>and probably wouldn't be a good idea in a new language. (Some languages
>do allow "-" in identifiers; but not languages you'd want to use.)


That's a bit too harsh. In LISP an identifier may consists
of just about any sequence of characters. For instance,
a-b and *c-d!?* are perfectly normal identifiers in LISP.

--
Rouben Rostamian
 
Reply With Quote
 
fir
Guest
Posts: n/a
 
      06-09-2013
W dniu niedziela, 9 czerwca 2013 19:50:20 UTC+2 użytkownik Bart napisał:
>
>
> Use "_" instead of "-".
>
> There are too many ambiguities otherwise, unless minus is always surrounded
> by white-space (or anything that is not part of an identifier).
>
> So a-b-c-d-e I think could be interpreted 16 different ways. There are also
> problems with the symbols "--", "->" and "-=".
> And, with your idea of having a-b mean either a-b or a - b depending on
> whether "a-b" is an identifier in scope, then you'd be able to
> ite: -----------------, which could mean almost anything (it could be one
> identifier, or N identifiers separated with minuses), depending on whether
> identifiers could start with "-" or not.
>
>
> It's not practical in an established language and syntax style anyway, and
> probably wouldn't be a good idea in a new language. (Some languages do allow
> "-" in identifiers; but not languages you'd want to use.)



ye, youre right

More signs in identifiers would be good, though
(in general)

More signs would help with much more expresivenes
of names in language (more expresivveness
is more readiblity and so on).

If i am not wrong c do not use three asci signs
~ ` @

maybe if one would use ` in the way like

int `anyt$hing!` = 10;

it would allow any signs in any identifier (by the negative cost of using``this time, advantage :
any symbols identifiers downside: it look
strange :C well, nevermind



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Why can function definitions only use identifiers, and not attributereferences or any other primaries? Jeremy Banks Python 12 04-24-2009 08:27 AM
Binding identifiers to known or unknown identifiers latashag@live.com Java 1 04-22-2008 04:54 AM
Overloading unary minus for use in function calls Matthew Cook C++ 6 12-20-2006 10:04 PM
how to use pyparsing for identifiers that start with a constant string phil_nospam_schmidt@yahoo.com Python 3 06-15-2005 04:36 PM
Firefox plus and minus Trond Ruud Firefox 2 12-07-2004 05:31 PM



Advertisments