<p dir="ltr">On 5 Apr 2014 21:31, "Iain Buclaw" <<a href="mailto:ibuclaw@gdcproject.org">ibuclaw@gdcproject.org</a>> wrote:<br>
><br>
> On 5 Apr 2014 19:55, "Johannes Pfau" <<a href="mailto:nospam@example.com">nospam@example.com</a>> wrote:<br>
> ><br>
> > Am Sun, 6 Apr 2014 02:51:28 +1000<br>
> > schrieb "Daniel Murphy" <<a href="mailto:yebbliesnospam@gmail.com">yebbliesnospam@gmail.com</a>>:<br>
> ><br>
> > > "Johannes Pfau" wrote in message<br>
> > > news:lhp8h4$2j38$1@digitalmars.com...<br>
> > ><br>
> > > > But we'd want this to work/inline nevertheless, right?:<br>
> > > > ------------<br>
> > > > void test(const(char)[] a)<br>
> > > > {<br>
> > > > }<br>
> > > ><br>
> > > > char[] abc;<br>
> > > > test(abc);<br>
> > > > ------------<br>
> > > ><br>
> > > > Then we still need to tell GCC that const(char)[] is a variant of<br>
> > > > char[] or it won't inline.<br>
> > ><br>
> > > Can you just strip all const/immutable/etc when the type is passed to<br>
> > > the backend?<br>
> > ><br>
> ><br>
> > This would impact debug info which is also emitted by the backend. GCC<br>
> > supports 'variants' of types which means only different qualifiers but<br>
> > the same apart from type qualifiers. We just need to set the variant<br>
> > information correctly (e.g. const(char)[] should be recognized as a<br>
> > variant of char[])<br>
><br>
> Right, and not having const applied to the type means that gcc might miss an optimisation opportunity.<br>
><br>
> In this case however I think that parameters declared in should not be mapped to C-style 'const'. The 'in' keyword is close, but something other.</p>
<p dir="ltr">FORTRAN for instance has intent attributes.</p>
<p dir="ltr">---<br>
intent(in) - yes, pass by value, so changes of this are not reflected in outside code.</p>
<p dir="ltr">intent(out) - pass somehow by reference, in fact a return argument</p>
<p dir="ltr">intent(inout) - pass by reference, normal in/out parameter.<br>
---</p>
<p dir="ltr">These are interesting concepts that allows more aggressive optimisation than using C/C++ const/ref type variants. I think gdc should go down this route, but I've never experimented too much round this area.</p>