Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Computers are not intelligent. They only think they are.


devel / comp.lang.c / Re: pp-numbers

SubjectAuthor
* pp-numbersThiago Adams
+* Re: pp-numbersKeith Thompson
|+- Re: pp-numbersThiago Adams
|+* Re: pp-numbersThiago Adams
||`* Re: pp-numbersKeith Thompson
|| +- Re: pp-numbersThiago Adams
|| `- Re: pp-numbersTim Rentsch
|`* Re: pp-numbersTim Rentsch
| `- Re: pp-numbersKeith Thompson
`* Re: pp-numbersKaz Kylheku
 `- Re: pp-numbersThiago Adams

1
pp-numbers

<d83772bb-d64d-4f22-bc1c-09da72b04a4cn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=28462&group=comp.lang.c#28462

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a05:622a:18a1:b0:412:2954:3451 with SMTP id v33-20020a05622a18a100b0041229543451mr22052qtc.0.1693427697213;
Wed, 30 Aug 2023 13:34:57 -0700 (PDT)
X-Received: by 2002:a05:6870:8c26:b0:1bf:5a7d:3738 with SMTP id
ec38-20020a0568708c2600b001bf5a7d3738mr273184oab.2.1693427696833; Wed, 30 Aug
2023 13:34:56 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Wed, 30 Aug 2023 13:34:56 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=189.6.249.106; posting-account=xFcAQAoAAAAoWlfpQ6Hz2n-MU9fthxbY
NNTP-Posting-Host: 189.6.249.106
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <d83772bb-d64d-4f22-bc1c-09da72b04a4cn@googlegroups.com>
Subject: pp-numbers
From: thiago.a...@gmail.com (Thiago Adams)
Injection-Date: Wed, 30 Aug 2023 20:34:57 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1435
 by: Thiago Adams - Wed, 30 Aug 2023 20:34 UTC

I was trying to find the history of pp-numbers.
I find them initially at C89 draft.

pp-numbers are "very open" and I was trying to find the reason
or justification for that.

Since the begging the objective seems be to map integer
and floating constants, but since C89 the definition allows much
more than integer and floating constants.

Can anyone see a reason for that?
Maybe it is just a matter of
"this is the way the first guy implemented it."?

Re: pp-numbers

<87bkeo9rk7.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=28464&group=comp.lang.c#28464

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c
Subject: Re: pp-numbers
Date: Wed, 30 Aug 2023 13:57:28 -0700
Organization: None to speak of
Lines: 42
Message-ID: <87bkeo9rk7.fsf@nosuchdomain.example.com>
References: <d83772bb-d64d-4f22-bc1c-09da72b04a4cn@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="c1c8ce4c37b1e802642b7baee24e084b";
logging-data="3037489"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18Mph5/cIwwsuzOwKIEqG46"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:kbrVjM8WOICfg89fR9/fQMvtE4I=
sha1:/y5E4RnChjNeMDFQt8NDqIZdbvc=
 by: Keith Thompson - Wed, 30 Aug 2023 20:57 UTC

Thiago Adams <thiago.adams@gmail.com> writes:
> I was trying to find the history of pp-numbers.
> I find them initially at C89 draft.
>
> pp-numbers are "very open" and I was trying to find the reason
> or justification for that.
>
> Since the begging the objective seems be to map integer
> and floating constants, but since C89 the definition allows much
> more than integer and floating constants.
>
> Can anyone see a reason for that?
> Maybe it is just a matter of
> "this is the way the first guy implemented it."?

This is addressed in the ANSI C Rationale:
The notion of preprocessing numbers has been introduced to
simplify the description of preprocessing. It provides a means
of talking about the tokenization of strings that look like
numbers, or initial substrings of numbers, prior to their
semantic interpretation. In the interests of keeping the
description simple, occasional spurious forms are scanned as
preprocessing numbers --- 0x123E+1 is a single token under the
rules. The Committee felt that it was better to tolerate such
anomalies than burden the preprocessor with a more exact, and
exacting, lexical specification. It felt that this anomaly was
no worse than the principle under which the characters a+++++b
are tokenized as a ++ ++ + b (an invalid expression), even though
the tokenization a ++ + ++ b would yield a syntactically correct
expression. In both cases, exercise of reasonable precaution
in coding style avoids surprises.
https://www.lysator.liu.se/c/rat/c1.html#3-1-8

I'll note that the proprocessor has to *evaluate* integer constants and
expressions, but it only has to *recognize* floating-point constants and
expressions, leaving evaluation to translation phase 7 (or to execution
time).

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Will write code for food.
void Void(void) { Void(); } /* The recursive call of the void */

Re: pp-numbers

<a217b7fe-2193-4b95-a105-cbb9c957396bn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=28465&group=comp.lang.c#28465

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:ad4:58a5:0:b0:63f:c0b9:e07a with SMTP id ea5-20020ad458a5000000b0063fc0b9e07amr22620qvb.13.1693430554209;
Wed, 30 Aug 2023 14:22:34 -0700 (PDT)
X-Received: by 2002:a05:6808:23d0:b0:3a8:7543:ca00 with SMTP id
bq16-20020a05680823d000b003a87543ca00mr405794oib.5.1693430553848; Wed, 30 Aug
2023 14:22:33 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Wed, 30 Aug 2023 14:22:33 -0700 (PDT)
In-Reply-To: <87bkeo9rk7.fsf@nosuchdomain.example.com>
Injection-Info: google-groups.googlegroups.com; posting-host=189.6.249.106; posting-account=xFcAQAoAAAAoWlfpQ6Hz2n-MU9fthxbY
NNTP-Posting-Host: 189.6.249.106
References: <d83772bb-d64d-4f22-bc1c-09da72b04a4cn@googlegroups.com> <87bkeo9rk7.fsf@nosuchdomain.example.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <a217b7fe-2193-4b95-a105-cbb9c957396bn@googlegroups.com>
Subject: Re: pp-numbers
From: thiago.a...@gmail.com (Thiago Adams)
Injection-Date: Wed, 30 Aug 2023 21:22:34 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 3224
 by: Thiago Adams - Wed, 30 Aug 2023 21:22 UTC

On Wednesday, August 30, 2023 at 5:57:46 PM UTC-3, Keith Thompson wrote:
> Thiago Adams <thiago...@gmail.com> writes:
> > I was trying to find the history of pp-numbers.
> > I find them initially at C89 draft.
> >
> > pp-numbers are "very open" and I was trying to find the reason
> > or justification for that.
> >
> > Since the begging the objective seems be to map integer
> > and floating constants, but since C89 the definition allows much
> > more than integer and floating constants.
> >
> > Can anyone see a reason for that?
> > Maybe it is just a matter of
> > "this is the way the first guy implemented it."?
> This is addressed in the ANSI C Rationale:
> The notion of preprocessing numbers has been introduced to
> simplify the description of preprocessing. It provides a means
> of talking about the tokenization of strings that look like
> numbers, or initial substrings of numbers, prior to their
> semantic interpretation. In the interests of keeping the
> description simple, occasional spurious forms are scanned as
> preprocessing numbers --- 0x123E+1 is a single token under the
> rules. The Committee felt that it was better to tolerate such
> anomalies than burden the preprocessor with a more exact, and
> exacting, lexical specification. It felt that this anomaly was
> no worse than the principle under which the characters a+++++b
> are tokenized as a ++ ++ + b (an invalid expression), even though
> the tokenization a ++ + ++ b would yield a syntactically correct
> expression. In both cases, exercise of reasonable precaution
> in coding style avoids surprises.
> https://www.lysator.liu.se/c/rat/c1.html#3-1-8
>
> I'll note that the proprocessor has to *evaluate* integer constants and
> expressions, but it only has to *recognize* floating-point constants and
> expressions, leaving evaluation to translation phase 7 (or to execution
> time).
>
Thanks!

Re: pp-numbers

<644df2e0-1d20-448b-aed6-665658cd0c35n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=28466&group=comp.lang.c#28466

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a05:620a:880a:b0:76d:8919:2036 with SMTP id qj10-20020a05620a880a00b0076d89192036mr22416qkn.2.1693430950126;
Wed, 30 Aug 2023 14:29:10 -0700 (PDT)
X-Received: by 2002:a05:6808:1b11:b0:3a7:392a:7405 with SMTP id
bx17-20020a0568081b1100b003a7392a7405mr383611oib.2.1693430949798; Wed, 30 Aug
2023 14:29:09 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Wed, 30 Aug 2023 14:29:09 -0700 (PDT)
In-Reply-To: <87bkeo9rk7.fsf@nosuchdomain.example.com>
Injection-Info: google-groups.googlegroups.com; posting-host=189.6.249.106; posting-account=xFcAQAoAAAAoWlfpQ6Hz2n-MU9fthxbY
NNTP-Posting-Host: 189.6.249.106
References: <d83772bb-d64d-4f22-bc1c-09da72b04a4cn@googlegroups.com> <87bkeo9rk7.fsf@nosuchdomain.example.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <644df2e0-1d20-448b-aed6-665658cd0c35n@googlegroups.com>
Subject: Re: pp-numbers
From: thiago.a...@gmail.com (Thiago Adams)
Injection-Date: Wed, 30 Aug 2023 21:29:10 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1238
 by: Thiago Adams - Wed, 30 Aug 2023 21:29 UTC

I am thinking is just make pp-number as

(6.4.8) pp-number:
integer-constant
floating-constant

Re: pp-numbers

<877cpc9nis.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=28469&group=comp.lang.c#28469

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c
Subject: Re: pp-numbers
Date: Wed, 30 Aug 2023 15:24:43 -0700
Organization: None to speak of
Lines: 26
Message-ID: <877cpc9nis.fsf@nosuchdomain.example.com>
References: <d83772bb-d64d-4f22-bc1c-09da72b04a4cn@googlegroups.com>
<87bkeo9rk7.fsf@nosuchdomain.example.com>
<644df2e0-1d20-448b-aed6-665658cd0c35n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="e8d899b8fafb490ef1d8e527231431ae";
logging-data="3062256"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19vyXnzrzO9r2CZjJvxyzK3"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:jK0pz2vS/OG82BS9lyakq+1sAZk=
sha1:CgzdMavn/ydNhJfxHFypSJ0RLF8=
 by: Keith Thompson - Wed, 30 Aug 2023 22:24 UTC

Thiago Adams <thiago.adams@gmail.com> writes:
> I am thinking is just make pp-number as
>
> (6.4.8) pp-number:
> integer-constant
> floating-constant

I agree that that would make sense, and I suspect that's how it would be
specified if the language were being defined from scratch today.

I think the idea is that parsing floating constants, and rejecting
invalid floating constants, is a bit complex. Given that the
preprocessor is a separate program from the compiler proper, and the
compiler has to reject something like 0x123E+1 anyway. It slightly
reduces the burden on the preprocessor -- something that may have been
more significant in 1989 than it would be today.

There's probably not much point in changing it now. It would mean that
0x123E+1 would be parsed as 0x123E + 1 rather than as a syntax error,
but that's not much of an advantage, since a programmer should just use
spaces in the first place.

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Will write code for food.
void Void(void) { Void(); } /* The recursive call of the void */

Re: pp-numbers

<e0568914-1046-4f59-a074-a1dbff9da658n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=28473&group=comp.lang.c#28473

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a05:622a:7103:b0:412:2b59:dc10 with SMTP id jb3-20020a05622a710300b004122b59dc10mr28471qtb.1.1693441296851;
Wed, 30 Aug 2023 17:21:36 -0700 (PDT)
X-Received: by 2002:a05:622a:1813:b0:40f:e2a5:3100 with SMTP id
t19-20020a05622a181300b0040fe2a53100mr38967qtc.6.1693441296643; Wed, 30 Aug
2023 17:21:36 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Wed, 30 Aug 2023 17:21:36 -0700 (PDT)
In-Reply-To: <877cpc9nis.fsf@nosuchdomain.example.com>
Injection-Info: google-groups.googlegroups.com; posting-host=189.6.249.106; posting-account=xFcAQAoAAAAoWlfpQ6Hz2n-MU9fthxbY
NNTP-Posting-Host: 189.6.249.106
References: <d83772bb-d64d-4f22-bc1c-09da72b04a4cn@googlegroups.com>
<87bkeo9rk7.fsf@nosuchdomain.example.com> <644df2e0-1d20-448b-aed6-665658cd0c35n@googlegroups.com>
<877cpc9nis.fsf@nosuchdomain.example.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <e0568914-1046-4f59-a074-a1dbff9da658n@googlegroups.com>
Subject: Re: pp-numbers
From: thiago.a...@gmail.com (Thiago Adams)
Injection-Date: Thu, 31 Aug 2023 00:21:36 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 3064
 by: Thiago Adams - Thu, 31 Aug 2023 00:21 UTC

On Wednesday, August 30, 2023 at 7:25:01 PM UTC-3, Keith Thompson wrote:
> Thiago Adams <thiago...@gmail.com> writes:
> > I am thinking is just make pp-number as
> >
> > (6.4.8) pp-number:
> > integer-constant
> > floating-constant
> I agree that that would make sense, and I suspect that's how it would be
> specified if the language were being defined from scratch today.
>
> I think the idea is that parsing floating constants, and rejecting
> invalid floating constants, is a bit complex. Given that the
> preprocessor is a separate program from the compiler proper, and the
> compiler has to reject something like 0x123E+1 anyway. It slightly
> reduces the burden on the preprocessor -- something that may have been
> more significant in 1989 than it would be today.
>
> There's probably not much point in changing it now. It would mean that
> 0x123E+1 would be parsed as 0x123E + 1 rather than as a syntax error,
> but that's not much of an advantage, since a programmer should just use
> spaces in the first place.

My idea is a long term plan to move preprocessor phase to compiler phase.
Starting with removing phase 2( the line slicing) and removing pp-number.
I think it a simplification.
An optimisation that could be done is a different rule
inside inactive preprocessor regions, where #endif etc.. is what the preprocessor
is looking for to close.
the active regions will have to parse the numbers anyway, so having these p-numbers
only makes code more complicated instead of simplification.

one way to think in a long term C is emitting warnings in code that uses pp-number or
line slicing in a way not compatible with the future view.

Re: pp-numbers

<20230830235416.878@kylheku.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=28479&group=comp.lang.c#28479

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 864-117-...@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.c
Subject: Re: pp-numbers
Date: Thu, 31 Aug 2023 07:41:47 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 83
Message-ID: <20230830235416.878@kylheku.com>
References: <d83772bb-d64d-4f22-bc1c-09da72b04a4cn@googlegroups.com>
Injection-Date: Thu, 31 Aug 2023 07:41:47 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="70d02f2c57901333f8c8fdfdb470c4f7";
logging-data="3326628"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+26GzxqoYccSFo2fgcVxNIMD5pGNfQXN0="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:AB5hzVBAC2fHOMkGVwKPRBDgtOs=
 by: Kaz Kylheku - Thu, 31 Aug 2023 07:41 UTC

On 2023-08-30, Thiago Adams <thiago.adams@gmail.com> wrote:
> I was trying to find the history of pp-numbers.
> I find them initially at C89 draft.
>
> pp-numbers are "very open" and I was trying to find the reason
> or justification for that.

[ ... ]

> Can anyone see a reason for that?
> Maybe it is just a matter of
> "this is the way the first guy implemented it."?

Initially, back in the late 1970's, the C preprocessor was
an add-on program run in front of the compiler.

It did only very light lexical analysis. For instance,
you could interpolate macros into character constants:

#define X A
'X'

would turn into

'A'

From the start, the preprocessor had its own idea of how to scan, and it
took shortcuts, not doing it exactly the same way as the underlying
language, but only well enough for its purposes.

In the language, you never have a meaningful combination of tokens like
123 abc; there is no phrase of the syntax in which that occurs.
Therefore there is no concern that input 123abc has to be unraveled into
two preprocessor tokens 123 abc. So the preprocessor can get away
with treating that as one item.

From that point of departure, preprocessing was a bit of a zoo, with
different people's preprocessors implementations things slightly
differently.

It could only be tightened so much without causing breakages
for users.

If you were doing a clean redesign of the preprocessing from scratch
today, unhampered by backward compatibility (and for some strange reason
still wanted a token-level macro preprocessor, instead of a structural
one), you would probably not have a token syntax that is different from
the language being preprocessed.

You would make sure that your preprocessor accurately handles the
precise token syntax of the language.

In fact, you would stick the preprocessor just behind the lexical
analyzer of the language implementation so that it works with the actual
tokens of that language, and not its own preprocessor tokens.

However, the looseness in the preprocessor has some benefits in the area
of language development. For instance, let's consider that in 1989's
ANSI C, the token 1ULL was already a pp-number. So when C99 gave that
suffix a meaning, it could do so without having to change the pp-number
syntax, thus requiring no change in the early translation phases in
order to support that token.

Let's look at a language that doesn't have a C-like preprocessor: Common
Lisp. Yet, ANSI Common lisp has a curious section:

2.3.1.1 Potential Numbers as Tokens

To allow implementors and future Common Lisp standards to extend the
syntax of numbers, a syntax for potential numbers is defined that is
more general than the syntax for numbers. A token is a potential
number if it satisfies all of the following requirements:

https://clhs.lisp.se/Body/02_caa.htm [note: self-signed SSL cert!]

Sound familiar? C's pp-numbers do something like this. They define a
syntax for numbers that is more general, and has been used for future
extension.

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca

Re: pp-numbers

<5b4aa8c4-2777-4cfb-8b79-9e2e4dd07d9en@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=28489&group=comp.lang.c#28489

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a05:622a:189d:b0:403:aa87:d220 with SMTP id v29-20020a05622a189d00b00403aa87d220mr61395qtc.0.1693479378561;
Thu, 31 Aug 2023 03:56:18 -0700 (PDT)
X-Received: by 2002:a17:902:e745:b0:1bc:2547:b17c with SMTP id
p5-20020a170902e74500b001bc2547b17cmr941700plf.1.1693479378208; Thu, 31 Aug
2023 03:56:18 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Thu, 31 Aug 2023 03:56:17 -0700 (PDT)
In-Reply-To: <20230830235416.878@kylheku.com>
Injection-Info: google-groups.googlegroups.com; posting-host=170.231.44.126; posting-account=xFcAQAoAAAAoWlfpQ6Hz2n-MU9fthxbY
NNTP-Posting-Host: 170.231.44.126
References: <d83772bb-d64d-4f22-bc1c-09da72b04a4cn@googlegroups.com> <20230830235416.878@kylheku.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <5b4aa8c4-2777-4cfb-8b79-9e2e4dd07d9en@googlegroups.com>
Subject: Re: pp-numbers
From: thiago.a...@gmail.com (Thiago Adams)
Injection-Date: Thu, 31 Aug 2023 10:56:18 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 4494
 by: Thiago Adams - Thu, 31 Aug 2023 10:56 UTC

On Thursday, August 31, 2023 at 4:42:02 AM UTC-3, Kaz Kylheku wrote:
> On 2023-08-30, Thiago Adams <thiago...@gmail.com> wrote:
> > I was trying to find the history of pp-numbers.
> > I find them initially at C89 draft.
> >
> > pp-numbers are "very open" and I was trying to find the reason
> > or justification for that.
> [ ... ]
> > Can anyone see a reason for that?
> > Maybe it is just a matter of
> > "this is the way the first guy implemented it."?
> Initially, back in the late 1970's, the C preprocessor was
> an add-on program run in front of the compiler.
>
> It did only very light lexical analysis. For instance,
> you could interpolate macros into character constants:
>
> #define X A
> 'X'
>
> would turn into
>
> 'A'
>
> From the start, the preprocessor had its own idea of how to scan, and it
> took shortcuts, not doing it exactly the same way as the underlying
> language, but only well enough for its purposes.
>
> In the language, you never have a meaningful combination of tokens like
> 123 abc; there is no phrase of the syntax in which that occurs.
> Therefore there is no concern that input 123abc has to be unraveled into
> two preprocessor tokens 123 abc. So the preprocessor can get away
> with treating that as one item.
>
> From that point of departure, preprocessing was a bit of a zoo, with
> different people's preprocessors implementations things slightly
> differently.
>
> It could only be tightened so much without causing breakages
> for users.
>
> If you were doing a clean redesign of the preprocessing from scratch
> today, unhampered by backward compatibility (and for some strange reason
> still wanted a token-level macro preprocessor, instead of a structural
> one), you would probably not have a token syntax that is different from
> the language being preprocessed.
>
> You would make sure that your preprocessor accurately handles the
> precise token syntax of the language.
>
> In fact, you would stick the preprocessor just behind the lexical
> analyzer of the language implementation so that it works with the actual
> tokens of that language, and not its own preprocessor tokens.
>
> However, the looseness in the preprocessor has some benefits in the area
> of language development. For instance, let's consider that in 1989's
> ANSI C, the token 1ULL was already a pp-number. So when C99 gave that
> suffix a meaning, it could do so without having to change the pp-number
> syntax, thus requiring no change in the early translation phases in
> order to support that token.

Now in C23, true and false were added into preprocessor, so adding things
Is not a problem in my view.

#if true
#else
#endif

Instead of big breaking changes I want to something this works as it is today, maybe
in a way that is already conceived in the mind of programmers and which
maybe implementation does not match. Like slicing identifiers tokens in the middle, that is
allowed but I am sure programmers don't think in to do that.
I am sure 99,99% of the programmers don't think in terms of pp-numbers.

Re: pp-numbers

<865y4vtr5f.fsf@linuxsc.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=28490&group=comp.lang.c#28490

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: tr.17...@z991.linuxsc.com (Tim Rentsch)
Newsgroups: comp.lang.c
Subject: Re: pp-numbers
Date: Thu, 31 Aug 2023 03:58:20 -0700
Organization: A noiseless patient Spider
Lines: 14
Message-ID: <865y4vtr5f.fsf@linuxsc.com>
References: <d83772bb-d64d-4f22-bc1c-09da72b04a4cn@googlegroups.com> <87bkeo9rk7.fsf@nosuchdomain.example.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: dont-email.me; posting-host="49a0c7fba7d7c0f06cea865d80b29294";
logging-data="3436614"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX199O/N7BuGK7XaZtrMpH0EiETQb5tnEqJ8="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:C7bOXG5gCehFqEvYdj6h3FvG9hA=
sha1:/40gYBYim75HCnHKi3kOrXXvLTA=
 by: Tim Rentsch - Thu, 31 Aug 2023 10:58 UTC

Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:

[...]

> I'll note that the proprocessor has to *evaluate* integer
> constants and expressions, but it only has to *recognize*
> floating-point constants and expressions, leaving evaluation to
> translation phase 7 (or to execution time).

AFAICT there is no need for any of translation phases 1 to 6 to
recognize floating-point constants. All they need is to be able
to tell if a pp-number has the form of an integer constant, so
it can be evaluated, when in the context of some preprocessing
directives.

Re: pp-numbers

<87zg27802t.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=28508&group=comp.lang.c#28508

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c
Subject: Re: pp-numbers
Date: Thu, 31 Aug 2023 12:48:42 -0700
Organization: None to speak of
Lines: 22
Message-ID: <87zg27802t.fsf@nosuchdomain.example.com>
References: <d83772bb-d64d-4f22-bc1c-09da72b04a4cn@googlegroups.com>
<87bkeo9rk7.fsf@nosuchdomain.example.com> <865y4vtr5f.fsf@linuxsc.com>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="e8d899b8fafb490ef1d8e527231431ae";
logging-data="3600532"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/45OIq9TbFV7H8DwAnhDco"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:CKY2un/wt2QP4IFKGDzK6B1upJM=
sha1:BZa3S/0RLUKzUV19ZV7lJl/oG7o=
 by: Keith Thompson - Thu, 31 Aug 2023 19:48 UTC

Tim Rentsch <tr.17687@z991.linuxsc.com> writes:
> Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
>
> [...]
>
>> I'll note that the proprocessor has to *evaluate* integer
>> constants and expressions, but it only has to *recognize*
>> floating-point constants and expressions, leaving evaluation to
>> translation phase 7 (or to execution time).
>
> AFAICT there is no need for any of translation phases 1 to 6 to
> recognize floating-point constants. All they need is to be able
> to tell if a pp-number has the form of an integer constant, so
> it can be evaluated, when in the context of some preprocessing
> directives.

I agree.

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Will write code for food.
void Void(void) { Void(); } /* The recursive call of the void */

Re: pp-numbers

<867cp9somr.fsf@linuxsc.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=28587&group=comp.lang.c#28587

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: tr.17...@z991.linuxsc.com (Tim Rentsch)
Newsgroups: comp.lang.c
Subject: Re: pp-numbers
Date: Fri, 01 Sep 2023 12:02:36 -0700
Organization: A noiseless patient Spider
Lines: 17
Message-ID: <867cp9somr.fsf@linuxsc.com>
References: <d83772bb-d64d-4f22-bc1c-09da72b04a4cn@googlegroups.com> <87bkeo9rk7.fsf@nosuchdomain.example.com> <644df2e0-1d20-448b-aed6-665658cd0c35n@googlegroups.com> <877cpc9nis.fsf@nosuchdomain.example.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: dont-email.me; posting-host="e13a49a448cc252f76540c1a5198a3b9";
logging-data="4175704"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+9Hwstuuscftjny+iaXIJE7V94P25E1Zk="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:1Pir0YlLuLfgMPUbEVi0PW5N+GA=
sha1:UZu8h7C9r7Nm4VJha5Qejv1EJ4I=
 by: Tim Rentsch - Fri, 1 Sep 2023 19:02 UTC

Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:

> Thiago Adams <thiago.adams@gmail.com> writes:
>
>> I am thinking is just make pp-number as
>>
>> (6.4.8) pp-number:
>> integer-constant
>> floating-constant
>
> I agree that that would make sense, and I suspect that's how it
> would be specified if the language were being defined from scratch
> today.

There's an example in the Rationale document that indicates
otherwise. In C99RationaleV5.10.pdf, the example is at the
bottom of page 57, and starts "A new feature of C99:".

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor