On 9 December 2013 08:05, Jacob Carlborg <d...@me.com> wrote: > On 2013-12-07 00:56, Walter Bright wrote: > >>>> 2. D knows when functions are pure. C has to make worst case >>>> assumptions. >>> >>> >>> Does the compiler currently take advantage of this? >> >> >> dmd does. > > > Compiling the following code: > > pure int foo (immutable int a, immutable int b) > { > return a + b; > } > > void main () > { > auto a = foo(1, 2); > auto b = foo(1, 2); > auto c = a + b; > } > > With DMD 2.064.2 produce the exact same assembly code for "foo" and "main" > with our without "pure". I compiled with "dmd -O -release foo.d", am I doing > something wrong? >
Of course, it will not work unless you also pass the following options: -version=Enterprise -noboundscheck -inline -property -transition=11629 I thought everyone knew that??!?? :o)