On Wed, 09 May 2012 10:19:08 -0700, Jonathan M Davis <[email protected]>
wrote:
On Wednesday, May 09, 2012 10:05:36 Adam Wilson wrote:
On Wed, 09 May 2012 08:58:56 -0700, Nicolas Sicard <[email protected]>
wrote:
> On Wednesday, 9 May 2012 at 14:30:33 UTC, Andrei Alexandrescu wrote:
>>
http://www.reddit.com/r/programming/comments/telhj/voldemort_types_in_d/
>>
>> Andrei
>
> One drawback of Voldemort types, is that they are incompatible with
the
> generation of .di files (option -H).
>
> See http://d.puremagic.com/issues/show_bug.cgi?id=5461.
>
> Nicolas
This pull fixes this problem and a bunch of others:
https://github.com/D-Programming-Language/dmd/pull/928. However, it
currently fails to build on Linux and fails the unittests on Windows
thanks to a problem with the dur template function in std.datetime. The
solution used by this pull is to include the function body of the
auto-function as that was needed to allow Phobos to build correctly
using
the DRT DI files. This is the only workable solution as DMD does not
know
the type of an auto-function when DI files are generated. No semantic
analysis has been performed and since semantic analysis could change the
layout of a module you wouldn't want it to be
performed.
Actually, dur is in core.time (which is publicly imported by
std.datetime),
but regardless, what's wrong with it? It's incredibly straightforward.
- Jonathan M Davis
All of this is a result of using the above mentioned 928 pull.
This from core.time.d:
Duration dur(string units)(long length) @safe pure nothrow
if(units == "weeks" ||
units == "days" ||
units == "hours" ||
units == "minutes" ||
units == "seconds" ||
units == "msecs" ||
units == "usecs" ||
units == "hnsecs" ||
units == "nsecs")
{
return Duration(convert!(units, "hnsecs")(length));
}
Gets translated to this in core.time.di:
template dur(string units) if (units == "weeks" || units == "days" ||
units == "hours" || units == "minutes" || units == "seconds" || units ==
"msecs" || units == "usecs" || units == "hnsecs" || units == "nsecs")
{
pure nothrow @safe Duration dur(long length)
{
return Duration(convert!(units,"hnsecs")(length));
}
}
Which results in this error from DMD (HEAD):
../druntime/import/core/time.di(218): Error: this cannot be interpreted at
compile time, because it has no available source code
std/net/curl.d(187): called from here: dur(2L)
make[1]: *** [generated/linux/release/32/libphobos2.a] Error 1
make: *** [release] Error 2
But DMD, there *IS* source code to read! Even if it is just a function
call...
Note the above D->DI translation is the same without the patch, I checked
on a vanilla DMD 2.059 install. Also, I don't know near enough about
core.time to begin to guess what D is whining about here... It all looks
good to me.
--
Adam Wilson
IRC: LightBender
Project Coordinator
The Horizon Project
http://www.thehorizonproject.org/