Topic: constexpr functions as AST macros
Author: snk_kid <korcanh@gmail.com>
Date: Sun, 16 Nov 2014 03:04:28 -0800 (PST)
Raw View
------=_Part_2077_1246409745.1416135868339
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:
>
> 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, etc check=
=20
> here if interested:
>
> https://github.com/rsdn/nemerle/wiki/Macros-tutorial
>
>
--=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_2077_1246409745.1416135868339
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;">On Monday, November 10, 2014 2:23:45 AM UTC, Joel Falcou wrote:</span=
><blockquote class=3D"gmail_quote" style=3D"font-size: 13.1428575515747px; =
margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(2=
04, 204, 204); border-left-style: solid; padding-left: 1ex;"><div bgcolor=
=3D"#FFFFFF" text=3D"#000000">I am very interested by this ideas. As an avi=
d expression tempalte/meta-programming (ab)user, such a work could make tho=
se 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 Prot=
o 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"c=
ite"><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 & generate code all in the same language as code wri=
tten 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++ expressio=
n into an AST instead of being executed at compile-time.<br></li><li>Splici=
ng operator - to decompose/compose ASTs.</li><li>Hygienic Identifier genera=
tor - generate & use variables names inside of code gen.</li></ul><p>Ad=
ditionally support for case/match pattern matching may simplify the manipul=
ation of ASTs.<br></p><p>I believe the hardest and biggest part of adding t=
his 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 lan=
guage, 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/Macr=
os-tutorial</a><br></p></div><br></blockquote></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" 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_2077_1246409745.1416135868339--
.