Topic: constexpr functions for AST macro system
Author: snk_kid <korcanh@gmail.com>
Date: Sun, 16 Nov 2014 02:54:24 -0800 (PST)
Raw View
------=_Part_22_1523206799.1416135264020
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 meta-programming 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 run-time reflection, language tooling, etc.
Imagine a 1 library that is used both compile-time and run-time=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_22_1523206799.1416135264020
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 meta-programming and/or expressions templates so =
long as all the classes/functions are constexpr so they can be used in cons=
texpr functions (which act as AST macros).<br><br>I think maybe a simplifie=
d subset of Clang=E2=80=99s AST library could be used as a base for standar=
dization.<br><br>Another potential benefit of standardizing such a library =
that it could also be used (as base) for run-time reflection, language tool=
ing, etc.<br><br>Imagine a 1 library that is used both compile-time and run=
-time introspection/reflection and not being an overly complicated API.<br>=
<br>On Monday, November 10, 2014 2:23:45 AM UTC, Joel Falcou wrote:<blockqu=
ote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left=
: 1px #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 & 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 & 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" 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_22_1523206799.1416135264020--
.
Author: snk_kid <korcan.hussein@googlemail.com>
Date: Sun, 16 Nov 2014 03:01:02 -0800 (PST)
Raw View
------=_Part_2022_1407705356.1416135662445
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_2022_1407705356.1416135662445
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 style=3D"font-size: 13.1428575515747px;"><span =
style=3D"font-size: 13.1428575515747px;">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-w=
idth: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid;=
padding-left: 1ex;"><div bgcolor=3D"#FFFFFF" text=3D"#000000">I am very in=
terested by this ideas. As an avid expression tempalte/meta-programming (ab=
)user, such a work could make those techniques first class citizen of the l=
anguage.<br>One good entry point for this library of ast is maybe reusing/r=
ecycling 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 wrot=
e:<br></div><blockquote type=3D"cite"><div dir=3D"ltr">Hi, it seems to me t=
o 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 j=
ust execute code at compile-time but also transform & generate code all=
in the same language as code written for run-time execution.In terms of wh=
at is needed to add such support to language I think you only need to add a=
bout 3 new language features:<ul><li>Code quotation operator - tells the co=
mpiler 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>Hygienic Identifier generator - generate & use variables names i=
nside 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 har=
dest and biggest part of adding this is not the language additions part but=
actually standardizing a library for the abstract-syntax tree plus some mo=
re libraries features.<br></p><p>Nemerle maybe a good place to take inspira=
tion from as it has an excellent type-safe AST macro system designed to wor=
k with a hybrid OO-functional language, used for user-defined attributes, s=
yntax extensions, etc check here if interested:</p><p><a href=3D"https://gi=
thub.com/rsdn/nemerle/wiki/Macros-tutorial" target=3D"_blank">https://githu=
b.com/rsdn/<wbr>nemerle/wiki/Macros-tutorial</a><br></p></div><br></blockqu=
ote></div></blockquote></div></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_2022_1407705356.1416135662445--
.