Compile-Time module info

2012-07-22 Thread Chris NS
Is there any means to get meaningful moduleinfo at compile time, specifically a list of the local classes of a given module? __traits(allMembers, mod) doesn't work: inverse.d(109): Error: import data has no members. I was hoping that something along these lines would be possible in CTFE:

Re: ~= call copy ctor?

2012-07-22 Thread Jonathan M Davis
On Sunday, July 22, 2012 09:48:39 Namespace wrote: The strange constructs in std.algorithm aren't something i like to use in real projects. Is there some other solution? And what's so strange about them? That they use ranges? If you start avoiding ranges, you're going to be missing out on a

Re: ~= call copy ctor?

2012-07-22 Thread monarch_dodra
On Saturday, 21 July 2012 at 21:12:55 UTC, Namespace wrote: I'm not sure if it's a bug or my code is nonsense. ;) While there are some bugs D, you have to realize that D is a garbage collected language, which means you should not rely on objects being destructed in a timely fashion (or at

Re: ~= call copy ctor?

2012-07-22 Thread Namespace
Yes, C++ was my previous language. And no, nobody say anything about Ranges. But i doesn't like stuff who is deprecated as language feature and is rebuild as std.algorithm construct. It is that simple. :)

Re: ~= call copy ctor?

2012-07-22 Thread Jonathan M Davis
On Sunday, July 22, 2012 10:16:25 Namespace wrote: Yes, C++ was my previous language. And no, nobody say anything about Ranges. But i doesn't like stuff who is deprecated as language feature and is rebuild as std.algorithm construct. It is that simple. :) std.algorithm doesn't have anything

Re: ~= call copy ctor?

2012-07-22 Thread Namespace
Oh yes, i mean std.typecons, not std.algorithm, my bad. If delete will be deprecated, how can i delete/call dtor of one of my objects manually?

Re: ~= call copy ctor?

2012-07-22 Thread Jonathan M Davis
On Sunday, July 22, 2012 10:46:51 Namespace wrote: Oh yes, i mean std.typecons, not std.algorithm, my bad. If delete will be deprecated, how can i delete/call dtor of one of my objects manually? You're _really_ not supposed to be doing that. If you're dealing with GC allocated memory, then

getting to know dmd and druntime

2012-07-22 Thread maarten van damme
Right now I'm a bit confused. I assume that the garbage collector and some other parts from druntime need startup code. But what gets run first is my main method in the d file I compile. Does this mean that the first call to something in druntime calls that startup code? If not, what does get ran

Re: getting to know dmd and druntime

2012-07-22 Thread Nick Sabalausky
On Sun, 22 Jul 2012 11:30:14 +0200 maarten van damme maartenvd1...@gmail.com wrote: Right now I'm a bit confused. I assume that the garbage collector and some other parts from druntime need startup code. But what gets run first is my main method in the d file I compile. Actually, that's just

Re: getting to know dmd and druntime

2012-07-22 Thread maarten van damme
2012/7/22 Nick Sabalausky seewebsitetocontac...@semitwist.com: Actually, that's just a clever illusion. Your main() method isn't really the first thing called, the first thing called is a function in druntime called dmain (or Dmain or _dmain or something like that, I forget offhand). This

Re: ~= call copy ctor?

2012-07-22 Thread Namespace
The reason for my experiements is just to find a good solution for Not Null types. :) As long as they are not implement in std.typecons. Maybe you take my solution, if i have some. ;)

Re: getting to know dmd and druntime

2012-07-22 Thread David Nadlinger
On Sunday, 22 July 2012 at 10:42:58 UTC, Nick Sabalausky wrote: Actually, that's just a clever illusion. Your main() method isn't really the first thing called, the first thing called is a function in druntime called dmain (or Dmain or _dmain or something like that, I forget offhand). This

Re: Compile-Time module info

2012-07-22 Thread Philippe Sigaud
On Sun, Jul 22, 2012 at 9:31 AM, Chris NS ibisbase...@gmail.com wrote: Is there any means to get meaningful moduleinfo at compile time, specifically a list of the local classes of a given module? __traits(allMembers, mod) doesn't work: inverse.d(109): Error: import data has no members. I was

Re: ~= call copy ctor?

2012-07-22 Thread Ali Çehreli
On 07/22/2012 01:46 AM, Namespace wrote: Oh yes, i mean std.typecons, not std.algorithm, my bad. If delete will be deprecated, how can i delete/call dtor of one of my objects manually? In C++, deleting involves two steps: call the destructor and release the memory. It is different in D:

Re: Problem: handling a function dependent on release mode.

2012-07-22 Thread Jacob Carlborg
On 2012-07-21 19:11, Namespace wrote: Equally when they are passed as normal parameters. Really? I didn't know that. -- /Jacob Carlborg

Re: ~= call copy ctor?

2012-07-22 Thread Mafi
On the other hand, calling the destructor is still acceptable in D because it may be important for the programmer to run the contents earlier than GC would. clear() does that: auto t = new Test(f3); // ... clear(t);// -- Run the destructor Unfortunately it has a bad name,

Re: ~= call copy ctor?

2012-07-22 Thread Namespace
Nice to know. A name like destroy or delete would be better i think. But isn't a solution for the not null problem.

Re: ~= call copy ctor?

2012-07-22 Thread Namespace
A other question: How can i check if t is valid, after i call clear? [code] import std.stdio; class Test { public: this() { writeln(CTor); } ~this() { writeln(DTor); } } void main() { Test t = new Test();

Re: ~= call copy ctor?

2012-07-22 Thread Namespace
A other question: How can i check if t is valid, after i call clear? [code] import std.stdio; class Test { public: this() { writeln(CTor); } ~this() { writeln(DTor); } } void main() { Test t = new Test();

Re: ~= call copy ctor?

2012-07-22 Thread Ali Çehreli
On 07/22/2012 09:27 AM, Mafi wrote: Unfortunately it has a bad name, which is going to be changed. Really? I thought we have to stay with this name now. In my opinion this name is quite bad, especially in the presence of UFCS. What is going to be changed to? destroy()? Yep! :) It should be

Re: ~= call copy ctor?

2012-07-22 Thread Namespace
On Sunday, 22 July 2012 at 17:41:33 UTC, Ali Çehreli wrote: On 07/22/2012 09:27 AM, Mafi wrote: Unfortunately it has a bad name, which is going to be changed. Really? I thought we have to stay with this name now. In my opinion this name is quite bad, especially in the presence of UFCS.

Re: ~= call copy ctor?

2012-07-22 Thread Ali Çehreli
On 07/22/2012 09:35 AM, Namespace wrote: A other question: How can i check if t is valid, after i call clear? After the destructor is run, the object itself is put into a strange state. I amnot really sure about the actual details but I think the virtual function table is cleared (or perhaps

Re: ~= call copy ctor?

2012-07-22 Thread Jonathan M Davis
On Sunday, July 22, 2012 20:14:20 Namespace wrote: On Sunday, 22 July 2012 at 17:41:33 UTC, Ali Çehreli wrote: On 07/22/2012 09:27 AM, Mafi wrote: Unfortunately it has a bad name, which is going to be changed. Really? I thought we have to stay with this name now. In my opinion

Re: ~= call copy ctor?

2012-07-22 Thread monarch_dodra
On Sunday, 22 July 2012 at 18:14:21 UTC, Namespace wrote: On Sunday, 22 July 2012 at 17:41:33 UTC, Ali Çehreli wrote: On 07/22/2012 09:27 AM, Mafi wrote: Unfortunately it has a bad name, which is going to be changed. Really? I thought we have to stay with this name now. In my opinion this

Re: ~= call copy ctor?

2012-07-22 Thread Namespace
Works fine. :) Now my little test case work as expected: [code] import std.stdio; class Test { public: this() { writeln(CTor); } ~this() { writeln(DTor); } void echo() const { writeln(Here is Test);

Re: ~= call copy ctor?

2012-07-22 Thread Jonathan M Davis
On Sunday, July 22, 2012 20:45:05 monarch_dodra wrote: AFAIK, there are no invalid objects in D*. structs don't have default constructors, because they all have a compile time init value which they are filled with when emptied/moved/cleared. Ergo, even after being destroyed, they are still

datetime/time quickie

2012-07-22 Thread vurentjie
hi, i can't seem to find how to do this in the docs ... simple example i have 2 times 9:00,12:00 for which i need to get the interval between them in minutes, ie 180 i though I could use Interval!TimeOfDay(9:00:00,12:00:00) and convert this to minutes from here but this does not seem to be

Re: datetime/time quickie

2012-07-22 Thread vurentjie
On Sunday, 22 July 2012 at 20:50:15 UTC, vurentjie wrote: hi, i can't seem to find how to do this in the docs ... simple example i have 2 times 9:00,12:00 for which i need to get the interval between them in minutes, ie 180 i though I could use Interval!TimeOfDay(9:00:00,12:00:00) and

Re: datetime/time quickie

2012-07-22 Thread Jonathan M Davis
On Sunday, July 22, 2012 22:50:14 vurentjie wrote: hi, i can't seem to find how to do this in the docs ... simple example i have 2 times 9:00,12:00 for which i need to get the interval between them in minutes, ie 180 i though I could use Interval!TimeOfDay(9:00:00,12:00:00) and convert

Re: Problem: handling a function dependent on release mode.

2012-07-22 Thread Andrej Mitrovic
On 7/22/12, Jonathan M Davis jmdavisp...@gmx.com wrote: Yeah. Don't have them be template parameters unless you need to, otherwise you get a different template instantiation _every_ time that you call the function. I've just noticed something: @property front(T)(T arr, string file =

Re: Problem: handling a function dependent on release mode.

2012-07-22 Thread Jonathan M Davis
On Sunday, July 22, 2012 23:40:16 Andrej Mitrovic wrote: On 7/22/12, Jonathan M Davis jmdavisp...@gmx.com wrote: Yeah. Don't have them be template parameters unless you need to, otherwise you get a different template instantiation _every_ time that you call the function. I've just

Re: datetime/time quickie

2012-07-22 Thread vurentjie
On Sunday, 22 July 2012 at 21:16:22 UTC, Jonathan M Davis wrote: On Sunday, July 22, 2012 22:50:14 vurentjie wrote: hi, i can't seem to find how to do this in the docs ... simple example i have 2 times 9:00,12:00 for which i need to get the interval between them in minutes, ie 180 i though

Non-global template cannot use local lambda

2012-07-22 Thread Ali Çehreli
I can't see why the following limitation: class C { void foo(alias Func)() {} } void main() { auto c = new C(); c.foo!(x = x)(); // -- Compilation error } Error: template instance foo!(__lambda2) cannot use local '__lambda2(__T1)' as parameter to non-global template foo(alias

Re: Non-global template cannot use local lambda

2012-07-22 Thread Jonathan M Davis
On Sunday, July 22, 2012 17:40:36 Ali Çehreli wrote: I can't see why the following limitation: class C { void foo(alias Func)() {} } void main() { auto c = new C(); c.foo!(x = x)(); // -- Compilation error } Error: template instance foo!(__lambda2) cannot use

Re: Non-global template cannot use local lambda

2012-07-22 Thread Ali Çehreli
On 07/22/2012 06:08 PM, Jonathan M Davis wrote: On Sunday, July 22, 2012 17:40:36 Ali Çehreli wrote: I can't see why the following limitation: class C { void foo(alias Func)() {} } void main() { auto c = new C(); c.foo!(x = x)(); //-- Compilation error }