Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C Programming (http://www.velocityreviews.com/forums/f42-c-programming.html)
-   -   would it be possible to use minus in identifiers ? (http://www.velocityreviews.com/forums/t961562-would-it-be-possible-to-use-minus-in-identifiers.html)

fir 06-09-2013 02:36 PM

would it be possible to use minus in identifiers ?
 
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?)


Xavier Roche 06-09-2013 02:43 PM

Re: would it be possible to use minus in identifiers ?
 
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;" ?


Noob 06-09-2013 03:14 PM

Re: would it be possible to use minus in identifiers ?
 
fir wrote:

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


-> comp.compilers is over there.


fir 06-09-2013 04:32 PM

Re: would it be possible to use minus in identifiers ?
 
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


Ivan Shmakov 06-09-2013 04:50 PM

Re: would it be possible to use minus in identifiers ?
 
>>>>> fir <profesor.fir@gmail.com> 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

fir 06-09-2013 05:29 PM

Re: would it be possible to use minus in identifiers ?
 
>
>
> > "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


glen herrmannsfeldt 06-09-2013 05:43 PM

Re: would it be possible to use minus in identifiers ?
 
fir <profesor.fir@gmail.com> 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

BartC 06-09-2013 05:50 PM

Re: would it be possible to use minus in identifiers ?
 


"fir" <profesor.fir@gmail.com> wrote in message
news:6e9936d7-e82f-469a-98df-7a8a8120775e@googlegroups.com...
> 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


none 06-09-2013 06:19 PM

Re: would it be possible to use minus in identifiers ?
 
In article <Kf3tt.22437$RF7.7946@fx07.am4>, BartC <bc@freeuk.com> wrote:
>"fir" <profesor.fir@gmail.com> wrote in message
>news:6e9936d7-e82f-469a-98df-7a8a8120775e@googlegroups.com...
>>
>> 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

fir 06-09-2013 06:35 PM

Re: would it be possible to use minus in identifiers ?
 
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





All times are GMT. The time now is 04:06 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.