Using std.net.curl

2012-07-01 Thread Gary Willoughby
I'm using the built-in curl library on Linux i'm getting linker errors. I've installed libcurl4-openssl-dev and it works fine as i can successfully compile a sample program. However when using the D lib i get these errors: [quote] :!rdmd api_test.d

Re: Using std.net.curl

2012-07-07 Thread Gary Willoughby
Yeah invoking the linker manually works fine. To save me from that each time i've actually added '-L-lphobos2' to the end of 'DFLAGS' in '/etc/dmd.conf' so phobos is always before curl in the linker argument list. When the program is compiled '-L-lphobos2' appears twice in the args but that's

What was the reason for not including std.net.curl in the Windows phobos library?

2012-07-07 Thread Gary Willoughby
What was the reason for not including 'std.net.curl' in the Windows phobos library? I've added it and recompiled phobos for use but i just wondered why it was missing? For others i blogged how to recompile with curl support here: http://kalekold.net/index.php?post=19

Re: What was the reason for not including std.net.curl in the Windows phobos library?

2012-07-07 Thread Gary Willoughby
IIRC it is licencing issues, they can't include curl in the distribution without certain requirements that were deemed to awkward to implement. Ah, right.

Re: GUI development libraries in D?

2012-09-26 Thread Gary Willoughby
On Tuesday, 25 September 2012 at 21:51:40 UTC, Matthew Turner wrote: Hello, I'm wondering if there is any library for making a GUI with D. If not, what would you recommend for that? Could I just use c++ libraries? Thank you, Matt GtkD is probably your best bet. I wrote a blog post here

How to define an interator to provide array like behaviour in a class?

2012-10-16 Thread Gary Willoughby
I want to do something like this (Collection is a custom type): Collection x = new Collection(); x.add(something); x.add(somethingElse); foreach(type value; x) { writeln(value); } Collection is a class with a private array member variable which actually holds the collection data entered

Re: How to define an interator to provide array like behaviour in a class?

2012-10-17 Thread Gary Willoughby
1. Define opApply (see section labeled Foreach over Structs and Classes with opApply after here: http://dlang.org/statement.html#foreach_with_ranges) 2. Or make it a range (see http://dlang.org/statement.html#foreach_with_ranges and http://ddili.org/ders/d.en/ranges.html ), which would

Using MySql with D on Mac OS 10.8

2013-05-17 Thread Gary Willoughby
Are there any decent wrappers available for D to allow me to read data from a file and place it into a MySql database. I'm using Mac OS 10.8. Is there an official library? Has anyone used MySql with D on Mac OS? Thanks.

Is there anything in the standard library to help writing a file watcher?

2013-05-23 Thread Gary Willoughby
Is there anything in the standard library to help writing a file watcher? I want to monitor a single file for changes and if a change is detected call a function. Is there any existing libraries to do this in D as it must be cross-platform as much as possible?

Why is this code returning the wrong type?

2013-05-23 Thread Gary Willoughby
Why won't the following code compile? Here's the error: filewatcher.d(21): Error: cannot implicitly convert expression (new File(file, r)) of type File* to shared(_iobuf)* /** * Imports. */ import std.stdio; /** * A class to watch for changes in a file. */ class Example { /**

Re: Is there anything in the standard library to help writing a file watcher?

2013-05-23 Thread Gary Willoughby
Hmmm.. this is what i first thought. I think i'll implement a simple watcher based on modification times as a first iteration. Then if time allows add platform specific solutions based on the above. Thanks.

Re: Why is this code returning the wrong type?

2013-05-23 Thread Gary Willoughby
File is a wrapper around a FILE*, it's not the same as a FILE* No need for new, File is a struct, new is (normally) for classes. No need for this., although there's no harm in it. Ah yes, thanks.

Re: Why is this code returning the wrong type?

2013-05-23 Thread Gary Willoughby
Hmmm... Following your example i'm still having problems compiling this simple snippet: import std.stdio; class Example { private FILE _file; public this(string file) { this._file = File(file, r); } } Error: test.d(9): Error: cannot implicitly

Re: Why is this code returning the wrong type?

2013-05-23 Thread Gary Willoughby
you former private FILE* _file wasn't an File and your current private FILE _file is still not File because FILE and File is something differnt (case sensitive) why not write private File _file Gah! of course. Thanks. I think i better get some sleep...

Re: What xml libraries are people using?

2013-05-24 Thread Gary Willoughby
On Saturday, 2 March 2013 at 18:42:13 UTC, Andrej Mitrovic wrote: On 3/2/13, simendsjo simend...@gmail.com wrote: Which can you recommend? I use ae's lite xml library: https://github.com/CyberShadow/ae/blob/master/utils/xmllite.d It's not a monster but thanks to UFCS I can easily extend it

Any examples of using inotify with D?

2013-05-25 Thread Gary Willoughby
Is there any examples of using inotify with D? http://en.wikipedia.org/wiki/Inotify I've updated the old tango header file and tried to get something working but it seems to hang. If anyone else has code using inotify i'd love to take a look to see how you have used it. ta.

Re: Any examples of using inotify with D?

2013-05-27 Thread Gary Willoughby
On Saturday, 25 May 2013 at 21:19:30 UTC, Gary Willoughby wrote: Is there any examples of using inotify with D? http://en.wikipedia.org/wiki/Inotify I've updated the old tango header file and tried to get something working but it seems to hang. If anyone else has code using inotify i'd love

How do you guys debug large programs?

2013-05-27 Thread Gary Willoughby
This is quite an open ended question but i wondered how you guys debug your D programs (i'm talking about stepping through code, setting breakpoints, etc). The lack of nice IDE's with integrated debuggers is worrying when working with D but up until now i haven't need one. Now i've started

Why does this snippet print the enum identifiers instead of their values?

2013-05-28 Thread Gary Willoughby
Why does the following snippet print: Started name revision instead of Started my-app 1.0a? import std.stdio; enum application : string { name = my-app, revision = 1.0a, } void main(string[] arguments) { writefln(Started %s %s, application.name, application.revision); }

Where does the log get written when there's a core dump?

2013-05-28 Thread Gary Willoughby
I was trying some funky stuff with D, not real code just playing and I got a message of a seg fault and a core dump written to a log. I just wondered where these logs are written to. It's not immediately apparent where it is.

Re: Where does the log get written when there's a core dump?

2013-05-29 Thread Gary Willoughby
On Tuesday, 28 May 2013 at 21:15:55 UTC, Adam D. Ruppe wrote: On Tuesday, 28 May 2013 at 21:06:14 UTC, Gary Willoughby wrote: playing and I got a message of a seg fault and a core dump written to a log. like this? Segmentation fault (core dumped) That's actually more of a linux thing than

Re: Using custom CCS styles with ddoc

2013-06-03 Thread Gary Willoughby
On Monday, 3 June 2013 at 14:55:03 UTC, Gary Willoughby wrote: When creating documentation using ddoc there is no CSS file specified in the head of the generated HTML file. How can i tell ddoc to generate documentation and use a custom CSS file for the styles? Just found the answer here

Global extern(C) in druntime header files?

2013-06-05 Thread Gary Willoughby
I've been doing some coding and noticed something strange with core.sys.posix.signal. In the following snippet you will see that i have to decorate the handleTermination function with extern(C) to satisfy the type requirements of the bsd_signal function. import core.sys.posix.signal; import

Is the -property compiler flag broken/bad idea?

2013-06-05 Thread Gary Willoughby
I've been using the -property compiler flag when i compile programs and thought it was pretty cool but i've recently had a conversation with someone who has informed me it's broken and a bad idea. Never, ever, ever use -property. Its implementation is totally wrong and based on a flawed idea

Re: Global extern(C) in druntime header files?

2013-06-05 Thread Gary Willoughby
On Wednesday, 5 June 2013 at 18:54:45 UTC, Jesse Phillips wrote: Not going to look into the file, but I'm pretty sure bsd_signal is function for an external C library right? If that is the case, it must use C calling convention, so yes this is correct. Ah sorry i wasn't clear. The question

Re: Is the -property compiler flag broken/bad idea?

2013-06-05 Thread Gary Willoughby
You probably don't want to read it. It's huge. I'll try and summarize the situation. - Jonathan M Davis Thanks for a great overview, that's cleared things up nicely.

Re: Global extern(C) in druntime header files?

2013-06-06 Thread Gary Willoughby
You are passing a function pointer to a C library, where it will be expected that the function uses the C calling convention. So you have to declare the function as extern(C), otherwise DMD will not compile it as such. That can cause segfaults. Right ok thanks.

Re: Learning D

2013-06-07 Thread Gary Willoughby
On Friday, 7 June 2013 at 13:45:50 UTC, Daemon wrote: The only thing that remains is patience I guess. That, buy Andrei's book and ask questions here. :) http://www.amazon.co.uk/The-Programming-Language-Andrei-Alexandrescu/dp/0321635361

Clarification of @trusted attribute?

2013-06-12 Thread Gary Willoughby
I know the reason to mark a method as trusted from the docs: Trusted functions are guaranteed by the programmer to not exhibit any undefined behavior if called by a safe function. Generally, trusted functions should be kept small so that they are easier to manually verify. Undefined

Mac OS crash, details inside...

2013-06-13 Thread Gary Willoughby
I get a program crash each time running the following code on MacOS 10.8 (Lion). It seems to run ok on Ubuntu 12.04: import core.sys.posix.sys.stat; import core.sys.posix.unistd; import std.c.stdio; import std.c.stdlib; import std.process; import std.stdio; import std.string; import std.file;

Another Mac OS crash

2013-06-13 Thread Gary Willoughby
Another crash (Mac OS 10.8) here but this one doesn't seem to raise a crash dump. Also it seems to work fine on Ubuntu 12.04 import core.sys.posix.sys.stat; import core.sys.posix.unistd; import std.c.stdio; import std.c.stdlib; import std.process; import std.stdio; import std.string; import

Re: Mac OS crash, details inside...

2013-06-14 Thread Gary Willoughby
You do know that you usually don't have a /home/ directory on Mac OS X? On Mac OS X it's called /Users/. Yeah, that was me running the same code on Ubuntu. BTW, running that on Mac OS X 10.6.3 does not cause a crash. Although it doesn't seem to print or write anything. That's the problem i

Re: Mac OS crash, details inside...

2013-06-14 Thread Gary Willoughby
In fact i have the same problem reading files too. It only reads files up to a certain amount of bytes then crashes in the same manner explained above. Again this only happens when the program runs as a daemon.

Can someone give me a little program design advice please?

2013-06-16 Thread Gary Willoughby
I'm writing a little program in D to perform some database operations and have a small question about design. Part of my program watches a log file for changes and this involves code which is wrapped up in a class. So the usage is something like this: auto fileWatcher = new

Example on how to spawn a thread using a class method?

2013-06-17 Thread Gary Willoughby
Anyone got an example on how to spawn a thread using a class method? I want to wrap behaviour in a class and launch one of its methods using a thread. Once the method is running i want to interact with it from the main program by calling other methods which send the thread messages. I'm

Re: Mac OS crash, details inside...

2013-06-17 Thread Gary Willoughby
Run as a daemon how? By running the above code. All the code before opening the file causes the program to run as a daemon.

Re: Example on how to spawn a thread using a class method?

2013-06-18 Thread Gary Willoughby
Ah right, so you use a function as a wrapper around the delegate. Thanks.

Re: Can someone give me a little program design advice please?

2013-06-18 Thread Gary Willoughby
Interesting thanks.

Tips on making regex more performant?

2013-06-18 Thread Gary Willoughby
Below is an example snippet of code to test for performance of regex matches. I need to parse a large log and extract data from it and i've noticed a huge increase in time of the loop when reading and using regex. ... auto alert = regex(r^Alert ([0-9]+)); while ((line

Re: Tips on making regex more performant?

2013-06-18 Thread Gary Willoughby
enum alert = ctRegex!r^Alert ([0-9]+); And then use it the same way. Thanks. Hmmm.. i get 500K (worse performance) using that. :/ Any more tips?

Re: Is there a keyword to access the base class

2013-06-18 Thread Gary Willoughby
I iterated on Ali's solution with more OOP to demonstrate features you may find interesting. import std.stdio; interface IBar { @property int val(); } class Bar : IBar { protected int _val; @property int val() { return this._val; } }

Re: Tips on making regex more performant?

2013-06-20 Thread Gary Willoughby
I'm working with some string-heavy applications so I was curious about this myself. I'm new to D, but I did some heavy data analysis on chat files a while back. Not knowing anything about your data or what other queries you might want to do on it, matching the first part of the string with

Read a file to the end, new data is appended, no more is read?

2013-06-20 Thread Gary Willoughby
I have a simple problem, I want to open a file and read data from it. When the file changes, i will read more data. The trouble is i only want to open the file once. Here's the simplified code: import core.thread; import std.stdio; void main(string[] args) { auto file =

Re: Read a file to the end, new data is appended, no more is read?

2013-06-20 Thread Gary Willoughby
auto file = File(file.txt, r); char[1024] buffer; char[] line; writeln(First Read:); while ((line = file.rawRead(buffer)) !is null) { write(line); } Thread.sleep(dur!(seconds)(5)); writeln(Second Read:);

Re: Read a file to the end, new data is appended, no more is read?

2013-06-20 Thread Gary Willoughby
This must be platform-dependent. Your program works as expected under my Scientific Linux distribution. (Same as Red Hat.) Ali You're right, it seems to be a Mac OS limitation. It works fine here on Ubuntu.

Tips for fast string concatenation?

2013-06-21 Thread Gary Willoughby
Have you any tips for using D when you need fast string concatenation? I regularly use code like this: foreach (i, range) { foo ~= bar; } or: foo = foo ~ bar ~ baz ~ qux; I've used std.string.format(...) in some instances which sped things up which surprised me.

Is it possible to use global variables spanning modules?

2013-06-21 Thread Gary Willoughby
Yes i know it's horrible but is it possible to use global variables spanning modules? I need to capture a small amount of program data and deal with it in termination signal handlers. The data will be captured from various classes spread around different modules. I'm thinking the easiest

Re: Is it possible to use global variables spanning modules?

2013-06-21 Thread Gary Willoughby
On Friday, 21 June 2013 at 16:29:06 UTC, bearophile wrote: Gary Willoughby: is it possible to use global variables spanning modules? Why don't you use a __gshared module-global var, and then import it in all the modules where you need it? Bye, bearophile I've just been looking

Re: Is it possible to use global variables spanning modules?

2013-06-22 Thread Gary Willoughby
That works great thanks all.

How would you solve this 'interview' question in D?

2013-06-26 Thread Gary Willoughby
Just for a bit of fun, I saw this question posted on reddit the other day and wondered how *you* would solve this in D? http://stackoverflow.com/questions/731832/interview-question-ffn-n

Re: How would you solve this 'interview' question in D?

2013-06-26 Thread Gary Willoughby
The text from the question: Design a function f, such that: f(f(n)) == -n Where n is a 32 bit signed integer; you can't use complex numbers arithmetic. If you can't design such a function for the whole range of numbers, design it for the largest range possible.

Re: Passing a instance of a class to a thread via spawn?

2013-06-30 Thread Gary Willoughby
You must pass a shared object: Thanks!

Is this a bug in the concurrency lib or am i using it incorrectly?

2013-07-01 Thread Gary Willoughby
I was hoping the below example would display 'hello world' but it only displays 'hello'. Is this a bug in the concurrency lib or am i using it incorrectly? import std.stdio; import std.concurrency; void writer() { try { while (true) {

Re: Is this a bug in the concurrency lib or am i using it incorrectly?

2013-07-01 Thread Gary Willoughby
If you remove the the try..catch you will notice that OwnerTerminated is thrown, if this is the intended behaviour, I don't know. Probably is, because this would be a pretty obvious bug. Ah right, so i guess the main thread is finishing and throwing the exception to writer before sender has

Re: C standard libraries

2013-07-02 Thread Gary Willoughby
Use core.stdc, and forget of std.c. Bye, bearophile What's the reason for that?

Re: C standard libraries

2013-07-09 Thread Gary Willoughby
On Tuesday, 2 July 2013 at 12:52:49 UTC, bearophile wrote: Adam D. Ruppe: The older std.c is kept around just for compatibility with the old names before the move, at least as far as I know. Maybe they haven't fully deprecated it though because there's other reasons I don't know about, since

Can templated functions be used in interfaces?

2013-07-11 Thread Gary Willoughby
I have an interface like this: interface IAccessor { public ResultSet getCacheData(); public bool persist(T)(ref T[] collection); } Then i'm composing an object constraining via that interface: ... private IAccessor _accessor public void setAccessor(IAccessor accessor) {

Re: Can templated functions be used in interfaces?

2013-07-11 Thread Gary Willoughby
Also i've noticed that the compiler doesn't complain if templated functions are not implemented in the classes that implement the interface, which is wrong!

What is the correct way to test for an empty string?

2013-07-16 Thread Gary Willoughby
What is the correct way to test for an empty string? I've used if (string == ) and if (string is null) and both (O_o) in some places, it's starting to do my head in. What is the correct way?

Re: What is the correct way to test for an empty string?

2013-07-16 Thread Gary Willoughby
On Tuesday, 16 July 2013 at 19:33:13 UTC, bearophile wrote: The right, safe and readable way is to use std.array.empty: if (myString.empty) OMG, of course. Thanks!

Are associative arrays stable in D?

2013-07-16 Thread Gary Willoughby
Are associative arrays stable in D? I have to ask because i'm having a great deal of problems with them for simple operations. For example the following crashes. import std.stdio; void main(string[] args) { int[string] waiting; waiting[gary] = 1; waiting[tess] = 2;

Why does this template not have the desired result?

2013-07-19 Thread Gary Willoughby
Why does this template not have the desired result? I honestly though it would return true. import std.stdio; template inBounds(size_t size, T) { enum result = (size = T.min size = T.max); } void main(string[] args) { writefln(%s, inBounds!(10, int).result); // false! eh? }

Re: Why does this template not have the desired result?

2013-07-19 Thread Gary Willoughby
The way I'd do the inBounds is to just use T size instead of size_t size. template inBounds(T, T size) { snip same stuff } then writefln(%s, inBounds!(int, 10).result); // true as expected The problem with that though is that with size arguments int.max will wrap when being cast

Interesting line in the recent Dr Dobbs article about profiling?

2013-07-25 Thread Gary Willoughby
I've just read the article over at Dr Dobbs by Walter http://www.drdobbs.com/cpp/increasing-compiler-speed-by-over-75/240158941 and this line caught my eye: Even if you know your code well, you're likely wrong about where the performance bottlenecks are. Use a profiler. If you haven't used

Fastest way to compare dates using two unix timestamps?

2013-07-26 Thread Gary Willoughby
I'm writing a program that deals a lot with dates in unix timestamp format. I need to 'normalise' this timestamp to only give me the date and not the time. To do this i thought of using only midnight on that day. Here is the first attempt to normalise these dates: protected uint

What D related (or interesting development based) twitter accounts do you guys follow?

2013-07-28 Thread Gary Willoughby
What D related (or interesting development based) twitter accounts do you guys follow? I'm pretty new to twitter and trying to follow accounts that i find interesting.

Whats the difference between a final and non-final switch statement?

2013-07-30 Thread Gary Willoughby
Whats the difference between a final and non-final switch statement? I know the compiler complains when i don't use a default case in a non-final switch statement but i've no idea why.

Re: Whats the difference between a final and non-final switch statement?

2013-07-30 Thread Gary Willoughby
On Tuesday, 30 July 2013 at 10:29:45 UTC, Namespace wrote: On Tuesday, 30 July 2013 at 10:14:50 UTC, Gary Willoughby wrote: Whats the difference between a final and non-final switch statement? I know the compiler complains when i don't use a default case in a non-final switch statement

What would be the best way to compile a project with GDC?

2013-08-01 Thread Gary Willoughby
I've just finished a project in D and have been using rdmd to compile during testing. While this is nice, i now want to try other compilers to see if i get any speed gains. Because i use rdmd it takes care of passing everything to dmd. Now i want to try GDC and i need to pass the files in the

Re: What would be the best way to compile a project with GDC?

2013-08-02 Thread Gary Willoughby
On Thursday, 1 August 2013 at 19:06:38 UTC, Dicebot wrote: On Thursday, 1 August 2013 at 17:46:07 UTC, Gary Willoughby wrote: There must be a simpler way to pass these files to dmd in the right order? rdmd does it somehow. You do know that you can use GDC with rdmd? `rdmd --compiler=gdmd

Re: What would be the best way to compile a project with GDC?

2013-08-02 Thread Gary Willoughby
On Friday, 2 August 2013 at 14:28:39 UTC, H. S. Teoh wrote: What version of GDC are you using? T ~ gdc -v Using built-in specs. COLLECT_GCC=gdc COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.8/lto-wrapper Target: x86_64-linux-gnu Configured with: ../src/configure -v

Reading a structured binary file?

2013-08-02 Thread Gary Willoughby
What library commands do i use to read from a structured binary file? I want to read the byte stream 1, 2 maybe 4 bytes at a time and cast these to bytes, shorts and ints respectively. I can't seem to find anything like readByte().

Re: Reading a structured binary file?

2013-08-02 Thread Gary Willoughby
How big is the file? If it's not too huge i'd just read it in with std.file.read and then sort out splitting it up from there. Quite large so i'll probably stream it. Thanks guys.

Re: Reading a structured binary file?

2013-08-03 Thread Gary Willoughby
On Friday, 2 August 2013 at 22:13:28 UTC, Jonathan M Davis wrote: I'd probably use std.mmfile and std.bitmanip to do it. MmFile will allow you to efficiently operate on the file as a ubyte[] in memory thanks to mmap, and std.bitmanip's peek and read functions make it easy to convert multiple

Re: Reading a structured binary file?

2013-08-03 Thread Gary Willoughby
On Saturday, 3 August 2013 at 18:14:47 UTC, Gary Willoughby wrote: This sounds a great idea but once the file has been opened as a MmFile how to i convert this to a ubyte[] so the std.bitmanip functions work with it? I'm currently doing this: auto file = new MmFile(file.dat

Is it possible using reflection or similar to extract only public method names from classes?

2013-08-06 Thread Gary Willoughby
Is it possible using reflection or similar to extract only public method names from classes? I'm thinking how i would go about writing a unit test/mocking framework, investigating how i can gather information about such things before i manipulate them.

Re: Is it possible using reflection or similar to extract only public method names from classes?

2013-08-07 Thread Gary Willoughby
On Tuesday, 6 August 2013 at 22:55:49 UTC, Marek Janukowicz wrote: Gary Willoughby wrote: Is it possible using reflection or similar to extract only public method names from classes? I'm thinking how i would go about writing a unit test/mocking framework, investigating how i can gather

What's the D way of allocating memory?

2013-08-07 Thread Gary Willoughby
What's the D way of allocating memory? Do you guys just use malloc() and free()? Or are there functions in phobos that should be used? I just need a buffer of variable length allocating every now and then.

Re: What's the D way of allocating memory?

2013-08-07 Thread Gary Willoughby
On Wednesday, 7 August 2013 at 17:47:38 UTC, monarch_dodra wrote: If you want to do semi-manual memory management, you can use GC.malloc, which works like normal malloc, but is *still* managed by the GC. I'd actually recommend GC.qalloc over GC.malloc: it's the same function, but qalloc

Re: Sql - Any tuto ?

2013-08-08 Thread Gary Willoughby
On Thursday, 8 August 2013 at 11:18:16 UTC, Larry wrote: https://github.com/rejectedsoftware/mysql-native/blob/master/README.md the native D mysql driver. But then, what to do with it ? I've used this quite a bit and works quite nicely. I've found a few bugs while using it and they have

Re: What's the D way of allocating memory?

2013-08-08 Thread Gary Willoughby
On Wednesday, 7 August 2013 at 22:03:16 UTC, Ali Çehreli wrote: qalloc seems better but just like in C and C++, when comparing GC.malloc and GC.calloc, the default choice should always be GC.calloc. As a side note, i was just checking this out in core.memory and i was surprised: /**

Re: Sql - Any tuto ?

2013-08-09 Thread Gary Willoughby
On Friday, 9 August 2013 at 07:31:09 UTC, Larry wrote: So many thanks ! Yes it is not very polished yet. But now I see how I can manage it, I will follow your lead and try things. :) Thanks again, Larry Great! Remember if you have any issues or find any bugs raise an issue on github.

Re: How do you profile your apps under windows?

2013-08-09 Thread Gary Willoughby
On Friday, 9 August 2013 at 16:39:41 UTC, Alexandr Druzhinin wrote: -profile switch doesn't work for me (nothing happens), so I'm curious how to profile? I had the same problem on Linux where -profile didn't seem to produce anything. I had a program which ran an infinite loop running as a

Linker error with one particular function

2013-08-14 Thread Gary Willoughby
I have defined the following module: /** * Module containing unit test helper functions for date time operations. */ module common.test.unit.datetime; /** * Imports. */ import std.conv; import std.datetime; /** * Return a unix timestamp. * * Params: * T = The return type of the

Re: Linker error with one particular function

2013-08-14 Thread Gary Willoughby
On Wednesday, 14 August 2013 at 14:05:07 UTC, Jacob Carlborg wrote: Have you compiled all the files? Show us the command you use to compile your code. Usually this is enough rdmd main.d, where main.d is the file containing the main function. I'm sure all source files are compiled during the

Re: Linker error with one particular function

2013-08-16 Thread Gary Willoughby
On Thursday, 15 August 2013 at 18:54:40 UTC, 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

Tools for building a dynamic derived type? I need a push in the right direction.

2013-08-20 Thread Gary Willoughby
I've been researching ways to accomplish creating a template that creates a special kind of derived type and i think i need a push in the right direction. Take this simple class: class Person { private string _name; private int _age; this(string name, int age)

Re: How compile program with curl support?

2013-08-22 Thread Gary Willoughby
On Thursday, 22 August 2013 at 13:20:44 UTC, evilrat wrote: why do u link phobos when compiler do this for you? For some reason the order of linked libs matters especially with curl.

Using traits how do i get a function's parameters as a string?

2013-09-03 Thread Gary Willoughby
Using traits how do i get a methods's parameters as a string? Say i have the following method: ... public void setAge(int age) { this._age = age; } ... I want a string that is: (int age) or how ever many params there are. The nearest i got was using this code:

Re: Using traits how do i get a function's parameters as a string?

2013-09-07 Thread Gary Willoughby
Thanks all! :)

Re: Tools for building a dynamic derived type? I need a push in the right direction.

2013-09-07 Thread Gary Willoughby
On Wednesday, 21 August 2013 at 03:37:46 UTC, Kapps wrote: On Tuesday, 20 August 2013 at 18:55:44 UTC, Gary Willoughby wrote: I've been researching ways to accomplish creating a template that creates a special kind of derived type and i think i need a push in the right direction. Take

Do constructors in D support the privacy keyword?

2013-09-07 Thread Gary Willoughby
Do constructors in D support a privacy keyword? I'm guessing not because if i declare one like this: class T { private this() { } } i can still instantiate the class like this: auto x = new T(); and there is no error thrown. Am i right in thinking the privacy keyword is ignored?

Re: Do constructors in D support the privacy keyword?

2013-09-07 Thread Gary Willoughby
On Saturday, 7 September 2013 at 18:49:43 UTC, H. S. Teoh wrote: On Sat, Sep 07, 2013 at 08:37:05PM +0200, Gary Willoughby wrote: Do constructors in D support a privacy keyword? I'm guessing not because if i declare one like this: class T { private this() { } } i can still

Using traits get a list of methods and filter out the member vars.

2013-09-08 Thread Gary Willoughby
When iterating through class members using traits how do you filter out the member vars to only get a list of methods. I think i've solved it in the code below but it feels like i am abusing MemberFunctionsTuple. Is this the correct way to do this? private template Methods(T, int index = 0) {

Re: Using traits get a list of methods and filter out the member vars.

2013-09-08 Thread Gary Willoughby
On Sunday, 8 September 2013 at 13:46:26 UTC, Dicebot wrote: http://dpaste.dzfl.pl/c250e798 import std.traits, std.range; private template Methods(T) if (is(T == class)) { private string[] getMethods() { string result[];

Re: Using traits get a list of methods and filter out the member vars.

2013-09-08 Thread Gary Willoughby
On Sunday, 8 September 2013 at 17:07:57 UTC, Dicebot wrote: On Sunday, 8 September 2013 at 16:43:16 UTC, Gary Willoughby wrote: This looks like a nice solution but i get errors when used across modules. The problem is that allmembers emits private members so across modules

Any idea for a solution to handle overloads when dynamically implementing methods?

2013-09-09 Thread Gary Willoughby
Just wondered if i could pick you brains for a nice solution to dynamically add methods to a class, paying particular attention to overloads. I'm currently writing a mocking framework and everything's coming along nicely and i'm wondering how to handle replacing overloads of the mocked class.

Re: named import are always public

2013-09-10 Thread Gary Willoughby
On Tuesday, 10 September 2013 at 08:22:18 UTC, Namespace wrote: I have already found an old bug report for this, but I do not understand why it has still not been solved. Can someone explain that to me? Example: a.d: module a; private import std.stdio : writeln; b.d: import

Re: Linker error with one particular function

2013-09-10 Thread Gary Willoughby
On Friday, 16 August 2013 at 09:52:53 UTC, Gary Willoughby wrote: You might be onto something here as i only import this module into unit tests. When i get time i'll investigate a little further. If i take the import out of the unit test and place it at the top of my source file everything

Re: Linker error with one particular function

2013-09-10 Thread Gary Willoughby
On Tuesday, 10 September 2013 at 10:42:44 UTC, Gary Willoughby wrote: On Friday, 16 August 2013 at 09:52:53 UTC, Gary Willoughby wrote: You might be onto something here as i only import this module into unit tests. When i get time i'll investigate a little further. If i take the import out

  1   2   3   4   5   6   >