220 41225 <CAOU91OOsk6-3cHUYiFA7UGtcNrpjbNdSROQ3PqeAJW=H06rgYA@mail.gmail.com> article
Path: news.gmane.org!.POSTED!not-for-mail
From: =?UTF-8?Q?Klaim_=2D_Jo=C3=ABl_Lamotte?= <mjklaim@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Modules and preambule, just why?
Date: Wed, 5 Dec 2018 22:53:44 +0100
Lines: 103
Approved: news@gmane.org
Message-ID: <CAOU91OOsk6-3cHUYiFA7UGtcNrpjbNdSROQ3PqeAJW=H06rgYA@mail.gmail.com>
References: <e3f7a8a5-8e78-49f5-97df-139951f5d07a@isocpp.org>
 <CAOU91OPMe-0PU7zEfKKPSQNMwtaf8cw+q24XAes9pZTJqPGrcg@mail.gmail.com>
 <16989401-2f0d-4200-997e-0ac60b47bec3@isocpp.org> <CAOU91ONR5v9ujCaM5Riu5Dc39cejV4VcMEdieF3O6b_edy+Y7g@mail.gmail.com>
 <a8310d69-20cb-48ba-8a8e-c62c09d4cd94@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Trace: blaine.gmane.org 1544047181 12199 195.159.176.226 (5 Dec 2018 21:59:41 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Wed, 5 Dec 2018 21:59:41 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBD3NR2WQQ4IBBDESUHQAKGQEDCCHYJA@isocpp.org Wed Dec 05 22:59:37 2018
Return-path: <std-proposals+bncBD3NR2WQQ4IBBDESUHQAKGQEDCCHYJA@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-vk1-f200.google.com ([209.85.221.200])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBD3NR2WQQ4IBBDESUHQAKGQEDCCHYJA@isocpp.org>)
	id 1gUfCi-000314-Au
	for gclcip-std-proposals@m.gmane.org; Wed, 05 Dec 2018 22:59:36 +0100
Original-Received: by mail-vk1-f200.google.com with SMTP id k8sf4449805vke.6
        for <gclcip-std-proposals@m.gmane.org>; Wed, 05 Dec 2018 14:01:47 -0800 (PST)
ARC-Seal: i=2; a=rsa-sha256; t=1544047306; cv=pass;
        d=google.com; s=arc-20160816;
        b=rH265vJjXe/PuP3k3KHoUHwIp6Ww7UnmvuU58RXStPSevScql7Jgod0CDYAjyhiqNJ
         aFqC9Z7sl3ULf09uODtZj45JHWO9LBC+H83+u5tEgGDnd51vn6XgpWdS9iw7GpNRqC3m
         Kx+HK8i9oUMrUSsHai4dKTLq1lNgwu/sMCLdyY5M1dUk5fH5AYIJiaNt7szVk/CL8As/
         XufHQiT9tRZ0sy8tvWFF2eDj3CKrHX3rVL+6G3Y+rUuS7GXOpfLpKpAZySDRFJFFFlL5
         RttHUz2+DW1st7HuMESAdWLtzL7f1FzU7W5vvYx8Iq+y3x1CzMZmGNulNecU4et5KKSe
         /Pew==
ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post
         :list-id:mailing-list:precedence:reply-to:content-transfer-encoding
         :to:subject:message-id:date:from:in-reply-to:references:mime-version
         :dkim-signature;
        bh=OtwQtdTZZ9kQTx1nb4KpSN8vXNVfpn3ThzyD1MoKhMI=;
        b=Tg1EZAXUURBIYvO8K/6om8fnbZ2w5l6BfMFjSOMSXx9Of2ZifZ+b3Zc5o5334em72o
         /jeVayVIPA0/oCdKS5pUrQAqKDus6ectmE2ZxfeIVG32eiduiY4Et9PfVXMt2GcS0B0Q
         EFHmyXXQ14u1ObiO5FJD+edJQkLsYYejMPo/TEwyFE7/F5t6ktCCwLHRMC04TTEvrjT9
         C5YGUO4l4aXy+9K0kc0uKMNi4/hXYFLHSrKm88Ao2uHlm/SBvgkrz1iJuvfUuV3kXRUj
         OBj84ExPy6fmDguSvKdV0FD0CcV9feDLWenmod72Isn4Y0lhTMV48HG3c3pH3ArNvN36
         pMgw==
ARC-Authentication-Results: i=2; mx.google.com;
       dkim=pass header.i=@gmail.com header.s=20161025 header.b="e/LWPNYY";
       spf=pass (google.com: domain of mjklaim@gmail.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=mjklaim@gmail.com;
       dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=mime-version:references:in-reply-to:from:date:message-id:subject:to
         :content-transfer-encoding:x-original-sender
         :x-original-authentication-results:reply-to:precedence:mailing-list
         :list-id:list-post:list-help:list-archive:list-subscribe
         :list-unsubscribe;
        bh=OtwQtdTZZ9kQTx1nb4KpSN8vXNVfpn3ThzyD1MoKhMI=;
        b=tOFHO/FFXs1tLlzZamarAj44F8S3Exsa3DsyfS2A0aeQXSu5IduWof2wRgpAX4XSRT
         jpLa+4TE3lHB6k4qlzGBGwRx5dXgOiz8I85BuGjliOjP1WbwRDDZ0xYHV6NvRGZUR4lx
         0x8J8ls4uRo/aHmy7BfYE8LuY7As9k9n1H5fw8z17dtLCx8cPCVNCfFTp3LVn45PXon1
         V82KM0xCQSPhbkk0HYPLFCAhLMVukyfLcTXVQ1IJqYPd5P3mKfYduC1aEz8JxrFlYwLL
         79LKTuB33lWykc44AjYO0yoftg7sqB/MvqB8pRL3VYvMjPhNZ1fRTgd41n+2xIe0YTrE
         RUPw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:mime-version:references:in-reply-to:from:date
         :message-id:subject:to:content-transfer-encoding:x-original-sender
         :x-original-authentication-results:reply-to:precedence:mailing-list
         :list-id:x-spam-checked-in-group:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=OtwQtdTZZ9kQTx1nb4KpSN8vXNVfpn3ThzyD1MoKhMI=;
        b=KQbTifXOQHYT31Z4+e0Ra8XdVjaYk4BxFXu5OF2fqBtT1A/Pi2nKWqi1N1+KbvmjdG
         Mqq4zjqkrRPNG+fS4YMaTaKZIijWk7uJlvajPj1UR3E25SbVZ0QEIlXDYTBpseDzFegJ
         1vt1jeKu14OmLR5FZOgdBgGC5iHlnAVB2iLbVA9U3VRjswXtVLoNfs/Xpt3ILgbtCQUn
         ynLBN6/+s4pUwfAVZdyZK9ievNygi03GtZruuPC121rwwBpEjOqDparMVJ2+JQgI1PrO
         hmPYEQlDsqlPcQek7OOSlM0/bncXR1gJCkhiEHmkLFoRxivukFGd1nWjruU7uw/RiAsc
         c9O 
X-Gm-Message-State: AA+aEWaDNqoiOgVuY3Lcxn2Po0JGNQlyeKdn+ZEkg2/9hJvHfWSQeWUY
	1g4861oWsG+lZKiGbYiOOO2m9Q==
X-Google-Smtp-Source: AFSGD/WCVwGYjEFHIR3FeRb59Jgk/sc+w3yL8U7To6GJgvYlHLWVksXOA6R6zbWz8LO1FswGMDIMYA==
X-Received: by 2002:a67:4b50:: with SMTP id y77mr23160130vsa.13.1544046861012;
        Wed, 05 Dec 2018 13:54:21 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 2002:a67:810a:: with SMTP id c10ls4424660vsd.4.gmail; Wed, 05 Dec
 2018 13:54:19 -0800 (PST)
X-Received: by 2002:a67:7341:: with SMTP id o62mr11548572vsc.223.1544046859760;
        Wed, 05 Dec 2018 13:54:19 -0800 (PST)
ARC-Seal: i=1; a=rsa-sha256; t=1544046859; cv=none;
        d=google.com; s=arc-20160816;
        b=EUgDBlyZWCy9VhfOQwXhPPM5eaos33CUVdaN08oUicxdlZKEnz3g3+J4o1IiYumde2
         vZKLJRnv3W7IaUTqIY08WBOyPkdBLgMZ1Tmowo1H/ctGFKLZyV2rP+kxb/Y0m7zrecvX
         l3/52I2w6CfJPCZw6+uZvanwjq7316kI3T5r5cSvWdJ0FW9nsk7SRTvmWRxtyqoNf/kv
         jFw1oxrUIUcfukI7nCx+MtHS0g9GWHUX7jb58mAkDaoI+AIRkoFrbc1ydB3FkmoOUqOV
         A/j24/MMmVKVhcWbCoIdnb9BvlUtImjslfEs29PbZpzfSW5Z1Ph4KcZpoKLDYKuWw6il
         B/1g==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=content-transfer-encoding:to:subject:message-id:date:from
         :in-reply-to:references:mime-version:dkim-signature;
        bh=PTN0FLmob38sAXrpfPiQaJsDEXQeGO4NqNOoeDNNpAo=;
        b=0U8LerbpcHN9RJZgAQ5UwpoJOEK2uf3GEWF3akGb75O0qhJ1mC/9RlxYoW/GLn3IgE
         vYzThk03Hu5iuQWKJM/dsG93c15A8ZbfahwdE1hNcggB/y62JtVhHDmQNWWmny5cT6F5
         BPZJb9+XOc7Ed7O7YfzmA7vygT7y2TIdbGXuqLB6cT5t4pubbK0RHNWXzW1p2FlJreFN
         3IOcb0F0UQ6p2AES0O6qEIKUUjKPSk+TcU+CdO1AH0yxfjMGiJZrc0ifHOh0LJOWOGXB
         quVOxBrVW6fi8ouF81H/6z6W90o1VQIjde924jjmdK/jg/Xbm5i8ISfFFsW49VlT+dgr
         Y9sA==
ARC-Authentication-Results: i=1; mx.google.com;
       dkim=pass header.i=@gmail.com header.s=20161025 header.b="e/LWPNYY";
       spf=pass (google.com: domain of mjklaim@gmail.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=mjklaim@gmail.com;
       dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com
Original-Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41])
        by mx.google.com with SMTPS id w14sor12496593vsa.44.2018.12.05.13.54.19
        for <std-proposals@isocpp.org>
        (Google Transport Security);
        Wed, 05 Dec 2018 13:54:19 -0800 (PST)
Received-SPF: pass (google.com: domain of mjklaim@gmail.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41;
X-Received: by 2002:a67:41c2:: with SMTP id x63mr12051306vsf.185.1544046858921;
 Wed, 05 Dec 2018 13:54:18 -0800 (PST)
In-Reply-To: <a8310d69-20cb-48ba-8a8e-c62c09d4cd94@isocpp.org>
X-Original-Sender: mjklaim@gmail.com
X-Original-Authentication-Results: mx.google.com;       dkim=pass
 header.i=@gmail.com header.s=20161025 header.b="e/LWPNYY";       spf=pass
 (google.com: domain of mjklaim@gmail.com designates 209.85.220.41 as
 permitted sender) smtp.mailfrom=mjklaim@gmail.com;       dmarc=pass (p=NONE
 sp=QUARANTINE dis=NONE) header.from=gmail.com
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <std-proposals.isocpp.org>
X-Spam-Checked-In-Group: std-proposals@isocpp.org
X-Google-Group-Id: 399137483710
List-Post: <https://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <https://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <https://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:std-proposals+subscribe@isocpp.org>
List-Unsubscribe: <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>,
 <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:41225
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/41225>

Adding to Ville's comments:
On Wed, 5 Dec 2018 at 19:47, <masse.nicolas@gmail.com> wrote:
> Still, one question remains for me:
> If for example you wanna ship a library.
> As of today, you generally with the library the headers so that people us=
ing the library will be able to compile their code and make use of the libr=
ary you made.

You are focusing specifically on the shared-library case, ok. Just
note that it's not always the best solution for all libraries or
users.

> But how does it work if you wanna use modules? do you ship a module file =
together with the lib? And if so, how do you intend to generate this module=
 file?

Just ship a module interface unit that only contain the exported names
marked, if implemented separately, as exported/imported symbols too.
That's where it's interesting to have a module interface unit only
contain the exported names+symbols.

///////////////////////////////////////////////////////////////////////////=
/
//// Module interface: mymodule.mxx

export module mymodule;

// MYMODULE_API does the export/import dance, or look at build2's
__symexport as another way to do this.

export namespace mymodule { // export all the names in this namespace scope

    class Kikoo; // Name exported but not symbol import/export: we
don't want the user to use it's interface, just see it's name because
it's used in other interfaces

    MYMODULE_API Kikoo& foo();  // name exported but also symbol import/exp=
ort
    MYMODULE_API void bar(Kikoo&);  // name exported but also symbol
import/export


    template<class T>
    struct Lol { ... }; // Template, so no need to export symbols, it
might benefit from less compile time for the user though.

}

//////////////////////////////////////////////////
////// Module implementation : mymodule.cpp
module mymodule:impl; // If I remember correctly, that's a module
partition, not sure about the syntax

// Just implement everything here.
namespace mymodule{
   class Kikoo { ... };

   Kikoo& foo() { ... }
   void bar(Kikoo&) { ... }

}

//////////////////////////////////////////////////////

I'm not sure of the exact syntax so bear with me, but basically once
you build that in a shared library, you just have to provide
mymodule.mxx to the user, with the shared library binary (and maybe a
..lib on Windows).
You can try that in the library example using build2+msvc I linked to,
just move the implementation in a separate module file with the same
module name but not exporting.
The test is setup to link with the library, shared mode by default, so
if the test work, it correctly only used the module interface and
linked to it.

> Also note that even if I better understand the proposal now, my doubts ab=
out it and the need of declaring the module explicitly remains.

No problem with that, we can probably help clarifying or maybe you can
find a pain point before it gets standardized.

> In fact, I would have prefer an approach where the exported symbols are d=
educed from the code instead of having to declare it explicitly.

As pointed before, modules aren't related with linking. Though once
they are available, we will finally have a clearer way to specify in
C++ the boundaries of a library.
With this, it might be possible later to help with the symbol
export/import, but that seems complicated as it imply specifying some
stuffs that are currently unspecified.

A. Jo=C3=ABl Lamotte

--=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/CAOU91OOsk6-3cHUYiFA7UGtcNrpjbNdSROQ3PqeAJW%3DH0=
6rgYA%40mail.gmail.com.

.
