C++ Logo

sg15

Advanced search

Re: [isocpp-core] Named modules, macros, and re-exporting header units

From: Gabriel Dos Reis <gdr_at_[hidden]>
Date: Wed, 21 Dec 2022 19:38:15 +0000
[GDR]

> The terms "translation unit" and "translated translation unit" are not defined anywhere - as in "italicized terms".



Sorry, "translation unit" is defined, but not "translated translation unit".



"translation unit" is NOT defined as "a sequence of tokens" that are (only) lexically valid. Rather, the definition is in terms of source files, and headers, 5.1/1<https://eel.is/c++draft/lex.separate#1>:



A source file together with all the headers and source files included via the preprocessing directive #include, less any source lines skipped by any of the conditional inclusion preprocessing directives, is called a translation unit.



And that, to some degree, conflicts with the description in 6.6/1<https://eel.is/c++draft/basic.link#nt:translation-unit>


A program<https://eel.is/c++draft/basic.link#def:program> consists of one or more translation units<https://eel.is/c++draft/lex.separate#def:translation_unit> linked together.<https://eel.is/c++draft/basic.link#1.sentence-1> A translation unit consists of a sequence of declarations.<https://eel.is/c++draft/basic.link#1.sentence-2>



And given that headers are not assumed to be source files or even contain C++ program fragments, it is an interesting circle to square. Also, a program does not seem to include instantiation units?



-- Gaby





-----Original Message-----
From: Core <core-bounces_at_[hidden]> On Behalf Of Gabriel Dos Reis via Core
Sent: Wednesday, December 21, 2022 11:03 AM
To: Jens Maurer <jens.maurer_at_[hidden]>; core_at_[hidden]
Cc: Gabriel Dos Reis <gdr_at_[hidden]>; sg15_at_[hidden]
Subject: Re: [isocpp-core] Named modules, macros, and re-exporting header units



[Jens]

> A "translation unit" is a sequence of tokens that are (only) lexically valid.



Interesting.

In that case, the sentence "The resulting tokens are syntactically and semantically analyzed and translated as a translation unit." could use a clarification.

The terms "translation unit" and "translated translation unit" are not defined anywhere - as in "italicized terms".



> Maybe such a thing doesn't exist in your implementation.



Yes, but that should be irrelevant :-)



-- Gaby



-----Original Message-----

From: Jens Maurer <jens.maurer_at_[hidden]<mailto:jens.maurer_at_[hidden]>>

Sent: Sunday, December 18, 2022 2:02 AM

To: Gabriel Dos Reis <gdr_at_[hidden]<mailto:gdr_at_[hidden]>>; core_at_[hidden]<mailto:core_at_[hidden]>

Cc: sg15_at_[hidden]<mailto:sg15_at_[hidden]>

Subject: Re: [isocpp-core] Named modules, macros, and re-exporting header units



On 18/12/2022 04.19, Gabriel Dos Reis wrote:

> [Jens]

>> This clearly refers to "translation units", and translation units are a phase 7 concept per [lex.phases] p7:

>> "Whitespace characters separating tokens are no longer significant. Each preprocessing token is converted

>> into a token (5.6). The resulting tokens are syntactically and semantically analyzed and translated as a

>> translation unit."

>

> In that case, what is the difference between "translation units" and "translated translation units"?



A "translation unit" is a sequence of tokens that are (only) lexically valid.



Looking at phase 8 (template instantiation), a "translated translation unit" is some

unspecified intermediate thing where all non-dependent constructs have been semantically

analyzed, but no templates have been instantiated yet. Maybe such a thing doesn't exist

in your implementation.



Jens

_______________________________________________

Core mailing list

Core_at_[hidden]<mailto:Core_at_[hidden]>

Subscription: https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.isocpp.org%2Fmailman%2Flistinfo.cgi%2Fcore&data=05%7C01%7Cgdr%40microsoft.com%7C7d27b07b5a9b49fcf12808dae3861224%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638072462229258872%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=s7C4aJfJBak5%2BVitacYmXFxLIu2%2Bir2byhxaJ%2Fz%2FQBc%3D&reserved=0

Link to this post: https://nam06.safelinks.protection.outlook.com/?url=http%3A%2F%2Flists.isocpp.org%2Fcore%2F2022%2F12%2F13678.php&data=05%7C01%7Cgdr%40microsoft.com%7C7d27b07b5a9b49fcf12808dae3861224%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638072462229258872%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=ptC%2FbZ6BcTDMoytfbGZGpK9pZgzibNYMSYaYYaKAZCk%3D&reserved=0

Received on 2022-12-21 19:38:19