Anyone know why this CTFE isn't working?

Rory McGuire rmcguire at neonova.co.za
Fri Jul 16 02:46:48 PDT 2010



import std.stdio;

struct State {
  string s; string getString() { return s; }
  static State opCall(string s) {
  State ret;
  ret.s = s;
  return ret;
  }
}

void main() {
  auto s = State("adf");
  pragma(msg, s.getString());
}

dmd Output: (line 14 is the pragma statement)

struct.d(14): Error: variable s cannot be read at compile time
struct.d(14): Error: cannot evaluate s.getString() at compile time
s.getString()

www.neonova.co.za: http://cf.neonova.co.za/9Tdf
View: https://mail1.clearformat.com/vcard.php?uid=11&pid=10
Beta Test Advert: http://fwd.clearformat.com/9Tdd
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20100716/ba03aa47/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: logo.jpg
Type: image/jpeg
Size: 4855 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20100716/ba03aa47/attachment-0002.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ff2d54b.jpg
Type: image/jpeg
Size: 7452 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20100716/ba03aa47/attachment-0003.jpg>


More information about the Digitalmars-d-learn mailing list