swap doesn't work in CTFE?
Jonathan M Davis
jmdavisProg at gmx.com
Tue Jul 5 12:52:24 PDT 2011
On 2011-07-05 12:10, Ary Manzana wrote:
> On 7/4/11 11:39 PM, Daniel Murphy wrote:
> > "bearophile"<bearophileHUGS at lycos.com> wrote in message
> > news:iut093$1bjg$1 at digitalmars.com...
> >
> >> Daniel Murphy:
> >>> Same thing happens with pointers. Reduced:
> >> Pointers to structs in CTFE will work in DMD 2.054 :-)
> >
> > When they don't crash the compiler, that is.
> > http://d.puremagic.com/issues/show_bug.cgi?id=6250
>
> Is there any point in implementing CTFE in the compiler when LLVM
> already allows you to define functions and JIT compile them? Why write
> yet another "JIT compiler" that in fact doesn't optimize anything and
> just interprets everything as it comes? I'm sure with LLVM you can do
> all of what DMD currently does and more.
CTFE has a major impact on how programs are compiled. It wouldn't make any
sense to try and take it out the compiler itself. Not only does it affect what
you can initialize module and static variables to, but you can use it in
conditional compilation and template instantiation. It's an integral part of
the language itself and an integral part of the compilation process. Splitting
it out wouldn't work. Not to mention, CTFE happens in the _frontend_ of the
compiler, not the backend, and LLVM is the backend of LDC. dmd, gdc, and LDC
all share the same frontend. So, unless the JIT compiler were in the frontend,
it wouldn't matter on whit how good it is, because it couldn't be used in the
frontend - which is where CTFE needs to happen.
- Jonathan M Davis
More information about the Digitalmars-d-learn
mailing list