Re: Linker error with one particular function

2013-08-15 Thread Jacob Carlborg
On 2013-08-15 20:54, Jesse Phillips wrote: I don't have an answer, but in case you are not familiar with cryptic linker: On Wednesday, 14 August 2013 at 13:21:49 UTC, Gary Willoughby wrote: But when i import it and use the getUnixTime function i get the following linker error: Undefined symbol

Re: Places a TypeTuple can be used

2013-08-15 Thread Jonathan M Davis
On Thursday, August 15, 2013 21:14:03 Ali Çehreli wrote: > I know of three places a TypeTuple can be used at: > > 1) Function parameter list > > 2) Template parameter list > > 3) Array literal element list > > Are there more? > > import std.typetuple; > > void foo(int, string, double) > {} >

Re: Places a TypeTuple can be used

2013-08-15 Thread Jonathan M Davis
On Thursday, August 15, 2013 23:09:55 Ali Çehreli wrote: > On 08/15/2013 10:39 PM, Meta wrote: > > On Friday, 16 August 2013 at 04:14:04 UTC, Ali Çehreli wrote: > >> 1) Function parameter list > >> > >> 2) Template parameter list > >> > >> 3) Array literal element list > >> > >> Are ther

Re: Places a TypeTuple can be used

2013-08-15 Thread Ali Çehreli
On 08/15/2013 10:39 PM, Meta wrote: > On Friday, 16 August 2013 at 04:14:04 UTC, Ali Çehreli wrote: >> 1) Function parameter list >> >> 2) Template parameter list >> >> 3) Array literal element list >> >> Are there more? > I'm not sure if it should be considered a separate case, but there is t

Re: Places a TypeTuple can be used

2013-08-15 Thread Meta
On Friday, 16 August 2013 at 04:14:04 UTC, Ali Çehreli wrote: I know of three places a TypeTuple can be used at: 1) Function parameter list 2) Template parameter list 3) Array literal element list Are there more? import std.typetuple; void foo(int, string, double) {} struct S(T, float f) {

Places a TypeTuple can be used

2013-08-15 Thread Ali Çehreli
I know of three places a TypeTuple can be used at: 1) Function parameter list 2) Template parameter list 3) Array literal element list Are there more? import std.typetuple; void foo(int, string, double) {} struct S(T, float f) {} void main() { // 1) Function parameter list: May not con

Re: UFCS and function scope

2013-08-15 Thread bearophile
ixid: This is not OK: int fun5(int n) { int fun6(int n) { return n + 1; } return n.fun6; } Unfortunately this is by design, and at the moment it's unlikely to change. And I think it's done this way to avoid troubles with code in class methods. Bye,

Re: object.Exception@std/stdio.d(1321): Enforcement failed - I must be doing something wrong?

2013-08-15 Thread Colin Grogan
I've decided whats the point in printing a time that the file closed at, the last message will probably tell me that anyway if theres an error to find. Your suggestions worked perfectly, I've obviously a lot to learn on how to use the intricacies of D. Thanks very much! On Thursday, 15 Augu

UFCS and function scope

2013-08-15 Thread ixid
Why does UFCS seem to require that functions be defined in a higher (global being the highest) scope than themselves while the normal function syntax works fine? This is OK: int fun1(int n) { return n + 1; } int fun2(int n) { return n.fun1; } This is also OK: int fun3(int n) {

Re: object.Exception@std/stdio.d(1321): Enforcement failed - I must be doing something wrong?

2013-08-15 Thread monarch_dodra
On Thursday, 15 August 2013 at 18:09:21 UTC, monarch_dodra wrote: This doesn't fix everything though, and you should also rework your "logLevel" functions to not allocate: For example, by making "log" accept two strings. Another issue is that printing a time will always allocate a string, so

Re: Linker error with one particular function

2013-08-15 Thread Jesse Phillips
I don't have an answer, but in case you are not familiar with cryptic linker: On Wednesday, 14 August 2013 at 13:21:49 UTC, Gary Willoughby wrote: But when i import it and use the getUnixTime function i get the following linker error: Undefined symbols for architecture x86_64: The linker i

Re: object.Exception@std/stdio.d(1321): Enforcement failed - I must be doing something wrong?

2013-08-15 Thread monarch_dodra
On Thursday, 15 August 2013 at 17:41:00 UTC, Colin Grogan wrote: this(LogLevel minLevel = LogLevel.Info, string fileName="logfile.log") { this.minLevel = minLevel; logFile = File(fileName, "w"); this.writeMsg(format("Opened file for writing at [%s]", currTimestam

Re: object.Exception@std/stdio.d(1321): Enforcement failed - I must be doing something wrong?

2013-08-15 Thread Colin Grogan
I should have put this here too: My main function. import std.stdio; import utils.log; void main() { Logger log = new Logger(LogLevel.Info, "somefile.log"); log.logDebug("Test"); } When creating the log file, it prints the text in the constructor as expected, but the call to log.logDebu

Re: object.Exception@std/stdio.d(1321): Enforcement failed - I must be doing something wrong?

2013-08-15 Thread Colin Grogan
Hi Ali, Heres my full Logger class. module utils.log; import std.stdio; import std.string; import std.datetime; public enum LogLevel {Fatal=0, Severe=1, Info=2, Debug=3, Verbose=4}; public class Logger{ public: this(LogLevel minLevel = LogLevel.Info, string fileName="logfile.log"){

Re: object.Exception@std/stdio.d(1321): Enforcement failed - I must be doing something wrong?

2013-08-15 Thread Ali Çehreli
On 08/15/2013 10:03 AM, Colin Grogan wrote: > I've done this a million times (I thought!) but I'm getting a strange > error I cant figure out. > > The code: > > void writeMsg(string msg){ >logFile.writeln(msg); What is logFile? > } > > is failing with this error: > > object.Exception@st

object.Exception@std/stdio.d(1321): Enforcement failed - I must be doing something wrong?

2013-08-15 Thread Colin Grogan
Hi all, I've done this a million times (I thought!) but I'm getting a strange error I cant figure out. The code: void writeMsg(string msg){ logFile.writeln(msg); } is failing with this error: object.Exception@std/stdio.d(1321): Enforcement failed ./tester(pure @safe b

Re: strings and ranges

2013-08-15 Thread monarch_dodra
On Thursday, 15 August 2013 at 00:49:00 UTC, Jason den Dulk wrote: Also, does this mean that if I'm creating an output range for char[], will I need to implement a put(dchar) as well as a put(char)? Unfortunately, right now, yes. "put" doesn't know how to convert on the fly to the right type.

Re: std.json: why no constructors

2013-08-15 Thread David
Am 15.08.2013 11:19, schrieb Ivan Kazmenko: > Why doesn't JSONValue have constructors for the types it can store? > Like these: > https://github.com/GassaFM/icfpc2013/blob/master/icfputil/icfplib.d#L76-L112 > > > Or did I entirely miss the One Right Way to do that? > > I know there is std.seria

std.json: why no constructors

2013-08-15 Thread Ivan Kazmenko
Why doesn't JSONValue have constructors for the types it can store? Like these: https://github.com/GassaFM/icfpc2013/blob/master/icfputil/icfplib.d#L76-L112 Or did I entirely miss the One Right Way to do that? I know there is std.serialization on its way, but for now, it was just more conven

Re: strings and ranges

2013-08-15 Thread Jonathan M Davis
On Thursday, August 15, 2013 02:48:58 Jason den Dulk wrote: > Hello. > > When working with my code I noticed that if I use front on a > char[], it yields a dchar. Am I correct in concluding that it > does a UTF-8 to UTF-32 conversion and popFont will skip the whole > character, not just a code uni

Re: double.init is real.nan, is it a bug?

2013-08-15 Thread Jonathan M Davis
On Thursday, August 15, 2013 08:20:01 bsd wrote: > For some reason I thought ('var' is double.nan) did this isNaN > check, sort of like (key in AA) ... but 'in' is in and 'is' is, > well, just is. The is operate does a bitwise comparison, so it's checking whether the bits are identical or not. Th

Re: Templated structs / variant values

2013-08-15 Thread Jacob Carlborg
On 2013-08-15 00:29, Marek Janukowicz wrote: I need to have a generalized "settings" functionality that should work like this: * I need to be able to add this to a class * each setting has its name, description, type and default value * I need to iterate over all settings for given object API wo