| Deutsch English Français Italiano |
|
<vs9dlk$1u88l$2@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail From: bart <bc@freeuk.com> Newsgroups: comp.lang.c Subject: Re: Integral types and own type definitions (was Re: Suggested method for returning a string from a C program?) Date: Sat, 29 Mar 2025 18:20:37 +0000 Organization: A noiseless patient Spider Lines: 44 Message-ID: <vs9dlk$1u88l$2@dont-email.me> References: <vrd77d$3nvtf$2@dont-email.me> <86r02roqdq.fsf@linuxsc.com> <vrh1br$35029$2@dont-email.me> <LRUCP.2$541.0@fx47.iad> <vrh71t$3be42$1@dont-email.me> <KFVCP.594649$SZca.498578@fx13.iad> <vrhb77$3frk8$1@dont-email.me> <vrru8f$174q6$1@dont-email.me> <86o6xpk8sn.fsf@linuxsc.com> <vrtmu4$2s1q2$1@dont-email.me> <20250325011327.41@kylheku.com> <20250325131110.000056bd@yahoo.com> <86bjtpjp22.fsf@linuxsc.com> <vruid4$3iuvq$1@dont-email.me> <87iknw7sz8.fsf@nosuchdomain.example.com> <vs0e6r$1avlb$2@dont-email.me> <87sen05cza.fsf@nosuchdomain.example.com> <vs0olv$1lodm$1@dont-email.me> <vs14p5$20ejf$1@dont-email.me> <87o6xn60qc.fsf@nosuchdomain.example.com> <vs1t0p$2m8ne$1@dont-email.me> <87zfh74exe.fsf@nosuchdomain.example.com> <vs9aek$1sesb$1@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Sat, 29 Mar 2025 19:20:36 +0100 (CET) Injection-Info: dont-email.me; posting-host="0456d283b45811694d58326c90c160a7"; logging-data="2040085"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19cN4TF7qhZoZwfUz/1upgH" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:y/d8L4esGWdTsZK+zoPzzUez43U= In-Reply-To: <vs9aek$1sesb$1@dont-email.me> Content-Language: en-GB Bytes: 3704 On 29/03/2025 17:25, Janis Papanagnou wrote: > On 26.03.2025 23:15, Keith Thompson wrote: >> [ dyadic and monadic minus operations, and minus sign at literals ] >> >> I don't know of any language that uses "-" for both negation (prefix, >> one operand) and subtraction (infix, two operands) and treats -5 >> as a single token rather than a unary minus operator applied to the >> constant/literal "5". > > I as well don't know. It may simplify things if the '-' is detached > from a numeric positive literal, especially for numeric expressions. > > There's certainly cases where a signed numeric token is appropriate, > thinking (for example) about a CONST declaration in Pascal, like > CONST a = -5; here you don't have expressions, just the primitive > type literals.[*] > > The point why I think that a signed literal as entity may be useful > is that it's a static (compile time) property; -5 is in that respect > different from -x, the negation operation. A negative constant does > not "cost" a run-time operation. > > Given what we recently discussed about a division by a constant, > where compilers (may) handle expressions by pre-calculating the > reciprocal for run-time efficiency, it's not that clear to me that > it matters either way. > > I suppose it's a question of whether it complicates syntax definition > or parsing. Having a single token like '-1234' is pointless. Most languages allow you to add parentheses like '-(1234)' which must give the exact same result. And many also reduce expressions like '1234+1' to '12345' at compile time. In this case you'd want '-(1234+1)' to be equivalent to '-1235'. Or there may be a named alias 'X' for 1234, and later write '-X'. So there is no advantage to it, except possibly in the special case where the N in -N is something like INT_MIN, as N could have a different type.