www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - [D1] capitalize cannot be interpreted at CT

reply strtr <strtr sp.am> writes:
Could somebody please explain this error to me.

----
import std.uni : toUniUpper;
import std.string : capitalize;

void main()
{
	const char[] name = `test`;

	// C:\dmd\src\phobos\std\string.d(983): Error: _aApplycd2 cannot be
interpreted at compile time, because it has no available source code
	const char[] name_c = capitalize(name);

	// my partial solution
	const char[] name_c2 = cast(char)toUniUpper(name[0]) ~ name[1..$];
}
----
Jul 21 2010
parent reply Ellery Newcomer <ellery-newcomer utulsa.edu> writes:
On 07/21/2010 09:09 PM, strtr wrote:
 Could somebody please explain this error to me.
evidently ctfe can't eat foreach(i, dchar d; s){ } Bleach. Make sure it's in bugzilla.
Jul 21 2010
next sibling parent strtr <strtr sp.am> writes:
== Quote from Ellery Newcomer (ellery-newcomer utulsa.edu)'s article
 On 07/21/2010 09:09 PM, strtr wrote:
 Could somebody please explain this error to me.
evidently ctfe can't eat foreach(i, dchar d; s){ } Bleach. Make sure it's in bugzilla.
Thanks, found it: http://d.puremagic.com/issues/show_bug.cgi?id=3512
Jul 21 2010
prev sibling parent reply Don <nospam nospam.com> writes:
Ellery Newcomer wrote:
 On 07/21/2010 09:09 PM, strtr wrote:
 Could somebody please explain this error to me.
evidently ctfe can't eat foreach(i, dchar d; s){ } Bleach. Make sure it's in bugzilla.
CTFE currently doesn't work on *any* functions which are implemented in druntime, because it doesn't have access to their source code.
Jul 21 2010
parent reply BCS <none anon.com> writes:
Hello Don,

 Ellery Newcomer wrote:
 
 On 07/21/2010 09:09 PM, strtr wrote:
 
 Could somebody please explain this error to me.
 
evidently ctfe can't eat foreach(i, dchar d; s){ } Bleach. Make sure it's in bugzilla.
CTFE currently doesn't work on *any* functions which are implemented in druntime, because it doesn't have access to their source code.
Why don't they have access? -- ... <IXOYE><
Jul 22 2010
parent reply Jonathan M Davis <jmdavisprog gmail.com> writes:
On Thursday, July 22, 2010 06:53:30 BCS wrote:
 Hello Don,
 
 Ellery Newcomer wrote:
 On 07/21/2010 09:09 PM, strtr wrote:
 Could somebody please explain this error to me.
evidently ctfe can't eat foreach(i, dchar d; s){ } Bleach. Make sure it's in bugzilla.
CTFE currently doesn't work on *any* functions which are implemented in druntime, because it doesn't have access to their source code.
Why don't they have access?
All you have for druntime are .di files (so basically header files rather than full-on source files) and the library file with the compiled source, so you don't have the source. Now, as to _why_ that's all you have, I don't know (the .d files come with phobos). But you need the .d files for the full source, and without them, you won't be able to use CTFE with the functions in them. - Jonathan M Davis
Jul 22 2010
parent "Steven Schveighoffer" <schveiguy yahoo.com> writes:
On Thu, 22 Jul 2010 13:25:04 -0400, Jonathan M Davis  
<jmdavisprog gmail.com> wrote:

 On Thursday, July 22, 2010 06:53:30 BCS wrote:
 Hello Don,

 Ellery Newcomer wrote:
 On 07/21/2010 09:09 PM, strtr wrote:
 Could somebody please explain this error to me.
evidently ctfe can't eat foreach(i, dchar d; s){ } Bleach. Make sure it's in bugzilla.
CTFE currently doesn't work on *any* functions which are implemented in druntime, because it doesn't have access to their source code.
Why don't they have access?
All you have for druntime are .di files (so basically header files rather than full-on source files) and the library file with the compiled source, so you don't have the source. Now, as to _why_ that's all you have, I don't know (the .d files come with phobos). But you need the .d files for the full source, and without them, you won't be able to use CTFE with the functions in them.
Well, it's somewhat different than that. For something like foreach(i, dchar d; s), the compiler recognizes this as a special runtime function and replaces it with a call to the special function that handles that. I don't think the code for running it is any .di file in druntime. -Steve
Jul 22 2010