Topic: constexpr functions for AST macro system.


Author: snk_kid <korcan.hussein@googlemail.com>
Date: Sun, 16 Nov 2014 02:56:32 -0800 (PST)
Raw View
------=_Part_2106_844942488.1416135392719
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

What would you like to discuss about it?

Regarding your comment about Proto as a base for an AST/Compiler internals=
=20
library, not to say that Proto is bad but I do think it would be overkill=
=20
for a such a library (one which every compiler vendor would have to=20
implement).

For me Proto solves a different but very related problem, I don=E2=80=99t t=
hink it=20
is necessary (or even desirable) for an AST/Compiler internals library to=
=20
need any template metaprogramming and/or expressions templates so long as=
=20
all the classes/functions are constexpr so they can be used in constexpr=20
functions (which act as AST macros).

I think maybe a simplified subset of Clang=E2=80=99s AST library could be u=
sed as a=20
base for standardization.

Another potential benefit of standardizing such a library that it could=20
also be used (as base) for runtime reflection, language tooling, etc.

Imagine a 1 library that is used both compile-time and runtime=20
introspection/reflection and not being an overly complicated API.

On Monday, November 10, 2014 2:23:45 AM UTC, Joel Falcou wrote:
>
>  I am very interested by this ideas. As an avid expression=20
> tempalte/meta-programming (ab)user, such a work could make those techniqu=
es=20
> first class citizen of the language.
> One good entry point for this library of ast is maybe reusing/recycling=
=20
> what Eric Niebler's Proto is achieving.
>
> Anyway, I am up for discussign this further.
>
>
> On 07/11/2014 12:15, snk_kid wrote:
> =20
> Hi, it seems to me to that constexpr functions could be an excellent base=
=20
> to add support for a real solution to meta-programming one which allows C=
++=20
> programmers to not just execute code at compile-time but also transform &=
=20
> generate code all in the same language as code written for run-time=20
> execution.In terms of what is needed to add such support to language I=20
> think you only need to add about 3 new language features:=20
>   =20
>    - Code quotation operator - tells the compiler to convert a C++=20
>    expression into an AST instead of being executed at compile-time.
>    - Splicing operator - to decompose/compose ASTs.
>    - Hygienic Identifier generator - generate & use variables names=20
>    inside of code gen.
>
> Additionally support for case/match pattern matching may simplify the=20
> manipulation of ASTs.
> =20
> I believe the hardest and biggest part of adding this is not the language=
=20
> additions part but actually standardizing a library for the abstract-synt=
ax=20
> tree plus some more libraries features.
> =20
> Nemerle maybe a good place to take inspiration from as it has an excellen=
t=20
> type-safe AST macro system designed to work with a hybrid OO-functional=
=20
> language, used for user-defined attributes, syntax extensions, etc check=
=20
> here if interested:
>
> https://github.com/rsdn/nemerle/wiki/Macros-tutorial
> =20
> =20
>=20

--=20

---=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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.

------=_Part_2106_844942488.1416135392719
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">What would you like to discuss about it?<br><br>Regarding =
your comment about Proto as a base for an AST/Compiler internals library, n=
ot to say that Proto is bad but I do think it would be overkill for a such =
a library (one which every compiler vendor would have to implement).<br><br=
>For me Proto solves a different but very related problem, I don=E2=80=99t =
think it is necessary (or even desirable) for an AST/Compiler internals lib=
rary to need any template metaprogramming and/or expressions templates so l=
ong as all the classes/functions are constexpr so they can be used in const=
expr functions (which act as AST macros).<br><br>I think maybe a simplified=
 subset of Clang=E2=80=99s AST library could be used as a base for standard=
ization.<br><br>Another potential benefit of standardizing such a library t=
hat it could also be used (as base) for runtime reflection, language toolin=
g, etc.<br><br>Imagine a 1 library that is used both compile-time and runti=
me introspection/reflection and not being an overly complicated API.<br><br=
>On Monday, November 10, 2014 2:23:45 AM UTC, Joel Falcou wrote:<blockquote=
 class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1=
px #ccc solid;padding-left: 1ex;">
 =20
   =20
 =20
  <div bgcolor=3D"#FFFFFF">
    I am very interested by this ideas. As an avid expression
    tempalte/meta-programming (ab)user, such a work could make those
    techniques first class citizen of the language.<br>
    One good entry point for this library of ast is maybe
    reusing/recycling what Eric Niebler's Proto is achieving.<br>
    <br>
    Anyway, I am up for discussign this further.<br>
    <br>
    <br>
    <div>On 07/11/2014 12:15, snk_kid wrote:<br>
    </div>
    <blockquote type=3D"cite">
      <div dir=3D"ltr">Hi, it seems to me to that constexpr functions
        could be an excellent base to add support for a real solution to
        meta-programming one which allows C++ programmers to not just
        execute code at compile-time but also transform &amp; generate
        code all in the same language as code written for run-time
        execution.In terms of what is needed to add such support to
        language I think you only need to add about 3 new language
        features:
        <ul><li>Code quotation operator - tells the compiler to convert a
            C++ expression into an AST instead of being executed at
            compile-time.<br>
          </li><li>Splicing operator - to decompose/compose ASTs.</li><li>H=
ygienic Identifier generator - generate &amp; use
            variables names inside of code gen.</li></ul>
        <p>Additionally support for case/match pattern matching may
          simplify the manipulation of ASTs.<br>
        </p>
        <p> I believe the hardest and biggest part of adding this is not
          the language additions part but actually standardizing a
          library for the abstract-syntax tree plus some more libraries
          features.<br>
        </p>
        <p>Nemerle maybe a good place to take inspiration from as it has
          an excellent type-safe AST macro system designed to work with
          a hybrid OO-functional language, used for user-defined
          attributes, syntax extensions, etc check here if interested:</p>
        <p><a href=3D"https://github.com/rsdn/nemerle/wiki/Macros-tutorial"=
 target=3D"_blank">https://github.com/rsdn/<wbr>nemerle/wiki/Macros-tutoria=
l</a><br>
        </p>
      </div>
      <br>
    </blockquote>
    <br>
  </div>

</blockquote></div>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

------=_Part_2106_844942488.1416135392719--

.