Topic: constexpr AST macros
Author: snk_kid <korcanh@gmail.com>
Date: Sun, 16 Nov 2014 03:13:06 -0800 (PST)
Raw View
------=_Part_1999_922676057.1416136386066
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.
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.
>
>
> snk_kid wrote:
>
> 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
> - 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.
>
> 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.
>
> 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=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_1999_922676057.1416136386066
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div>What would you like to discuss about it?</div><div><b=
r></div><div>Regarding your comment about Proto as a base for an AST/Compil=
er internals library, not 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 hav=
e to implement).</div><div><br></div><div>For me Proto solves a different b=
ut very related problem, I don=E2=80=99t think it is necessary (or even des=
irable) for an AST/Compiler internals library to need any template metaprog=
ramming and/or expressions templates so long as all the classes/functions a=
re constexpr so they can be used in constexpr functions (which act as AST m=
acros).</div><div><br></div><div>I think maybe a simplified subset of Clang=
=E2=80=99s AST library could be used as a base for standardization.</div><d=
iv><br></div><div>Another potential benefit of standardizing such a library=
that it could also be used (as base) for runtime reflection, language tool=
ing, etc.</div><div><br></div><div>Imagine a 1 library that is used both co=
mpile-time and runtime introspection/reflection and not being an overly com=
plicated API.</div><div><br></div><span style=3D"font-size: 13.142857551574=
7px;">Joel Falcou wrote:</span><blockquote class=3D"gmail_quote" style=3D"f=
ont-size: 13.1428575515747px; margin: 0px 0px 0px 0.8ex; border-left-width:=
1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padd=
ing-left: 1ex;"><div bgcolor=3D"#FFFFFF" text=3D"#000000">I am very interes=
ted by this ideas. As an avid expression tempalte/meta-programming (ab)user=
, such a work could make those techniques first class citizen of the langua=
ge.<br>One good entry point for this library of ast is maybe reusing/recycl=
ing what Eric Niebler's Proto is achieving.<br><br>Anyway, I am up for disc=
ussign this further.<br><br><br><div>snk_kid wrote:<br></div><blockquote ty=
pe=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-prog=
ramming one which allows C++ programmers to not just execute code at compil=
e-time but also transform & generate code all in the same language as c=
ode written for run-time execution.In terms of what is needed to add such s=
upport to language I think you only need to add about 3 new language featur=
es:<ul><li>Code quotation operator - tells the compiler to convert a C++ ex=
pression into an AST instead of being executed at compile-time.<br></li><li=
>Splicing operator - to decompose/compose ASTs.</li><li>Hygienic Identifier=
generator - generate & use variables names inside of code gen.</li></u=
l><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 a=
dding 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 exc=
ellent type-safe AST macro system designed to work with a hybrid OO-functio=
nal language, used for user-defined attributes, syntax extensions<span styl=
e=3D"font-size: 13px;"> </span></p></div></blockquote></div></blockquo=
te></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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_1999_922676057.1416136386066--
.