Re: static functions?

2012-05-20 Thread Mike Parker
On 5/21/2012 6:32 AM, jerro wrote: On Sunday, 20 May 2012 at 21:19:14 UTC, p0xel wrote: This seems to work when the class is in the same file as main(), but if I move it to it's own file and use "import foo" it errors. What am I missing? When you write "import foo;" and then foo.bar, the compi

Re: How to test for equality of types?

2012-05-20 Thread Kenji Hara
On Sunday, 20 May 2012 at 06:57:20 UTC, Kenji Hara wrote: On Saturday, 19 May 2012 at 18:17:16 UTC, Matthias Walter wrote: On 2012-05-19 15:28, Philippe Sigaud wrote: On Sat, May 19, 2012 at 12:23 PM, Matthias Walter wrote: I would open a bug report with the following code which is a bit sma

Re: ProjectEuler problem 35

2012-05-20 Thread Jay Norwood
On Sunday, 20 May 2012 at 15:48:31 UTC, Stewart Gordon wrote: On 19/05/2012 16:13, maarten van damme wrote: Yes, that's a common optimisation. Faster still would be to test 6k-1 and 6k+1 for each positive integer k. Indeed, I've done more than this in my time: hard-coded all the primes up to

Re: druntime investigation troubles

2012-05-20 Thread Alex Rønne Petersen
On 20-05-2012 22:13, Jacob Carlborg wrote: On 2012-05-20 18:25, Alex Rønne Petersen wrote: Seems like I misunderstood what you were saying. Right, the C runtime on *Windows* is closed source. But, I don't know why you think that function is called by the C runtime; see src/rt/dmain2.d. Have a

Re: std.concurrency.send

2012-05-20 Thread Nathan M. Swan
On Sunday, 20 May 2012 at 04:09:50 UTC, japplegame wrote: public: void startLogger(LogConstructorArgs args) { loggerTid = spawn(&loggerThread, args); } void log(string msg, OtherOptions oo) { loggerTid.send(LogMsg(msg, oo)); } void stopLogger() { loggerTid.send(QuitMsg()); } private:

Re: static functions?

2012-05-20 Thread jerro
On Sunday, 20 May 2012 at 21:19:14 UTC, p0xel wrote: This seems to work when the class is in the same file as main(), but if I move it to it's own file and use "import foo" it errors. What am I missing? When you write "import foo;" and then foo.bar, the compiler thinks that you a referring to

Re: static functions?

2012-05-20 Thread p0xel
This seems to work when the class is in the same file as main(), but if I move it to it's own file and use "import foo" it errors. What am I missing?

static functions?

2012-05-20 Thread p0xel
I pretty sure I'm an idiot. [code] class foo { public static int bar() { return 0; } } [/code] How do I call bar() without creating an instance of foo? foo.bar() results in "Error: undefined identifier 'bar'" I'm having a really hard time finding anything relat

Re: druntime investigation troubles

2012-05-20 Thread Jacob Carlborg
On 2012-05-20 18:25, Alex Rønne Petersen wrote: Seems like I misunderstood what you were saying. Right, the C runtime on *Windows* is closed source. But, I don't know why you think that function is called by the C runtime; see src/rt/dmain2.d. Have a look again. It's only called on Posix: htt

Re: druntime investigation troubles

2012-05-20 Thread Alex Rønne Petersen
On 20-05-2012 18:20, Alex Rønne Petersen wrote: On 20-05-2012 10:41, Denis Shelomovskij wrote: Looks like `_STI_monitor_staticctor` is called by C runtime on Windows. And C runtime isn't open-source. It creates troubles for investigation druntime (for me at least). Why is it so? Why not to call

Re: druntime investigation troubles

2012-05-20 Thread Alex Rønne Petersen
On 20-05-2012 10:41, Denis Shelomovskij wrote: Looks like `_STI_monitor_staticctor` is called by C runtime on Windows. And C runtime isn't open-source. It creates troubles for investigation druntime (for me at least). Why is it so? Why not to call everything in C `main`, what's the reason? If t

Re: ProjectEuler problem 35

2012-05-20 Thread Stewart Gordon
On 19/05/2012 16:13, maarten van damme wrote: A huge optimization could be made by storing and int array of already found primes and test all primes smaller then half the to-test number. this will speed up a lot. Do you mean build an array of already-found primes and use them to test new primes

Re: unsynchronized access to primitive variables

2012-05-20 Thread David Nadlinger
On Sunday, 20 May 2012 at 13:51:45 UTC, Dejan Lekic wrote: This proggy will always print "1" because writeln() prints the value from the main thread. Spawned thread will have own value. Remember TLS is the default storage. This is wrong. _Global_ (or static) variables are in TLS by default, b

Re: detecting POD types

2012-05-20 Thread Andrej Mitrovic
I don't think there is, but maybe you could use some template constraints from std.traits, like isPointer: if (!isPointer!T && !is(T == class)) There's probably other cases to consider, I'll leave others to fill in. On 5/20/12, japplegame wrote: > I write function template that should works only

Re: unsynchronized access to primitive variables

2012-05-20 Thread Dejan Lekic
On Saturday, 19 May 2012 at 08:16:39 UTC, luka8088 wrote: Hello to all, I would like to know if D guarantees that access to primitive variable is atomic ? I was looking for any source of information that says anything about unsynchronized access to primitive variables. What I want to know i

detecting POD types

2012-05-20 Thread japplegame
I write function template that should works only with POD types (i.e. base types, structures, enums etc.). Is there something like C++11 std::is_pod (http://en.cppreference.com/w/cpp/types/is_pod) template?

druntime investigation troubles

2012-05-20 Thread Denis Shelomovskij
Looks like `_STI_monitor_staticctor` is called by C runtime on Windows. And C runtime isn't open-source. It creates troubles for investigation druntime (for me at least). Why is it so? Why not to call everything in C `main`, what's the reason? If there is no list of stuff done before C `main`

Re: How to test for equality of types?

2012-05-20 Thread Philippe Sigaud
--> 09:33, "Kenji Hara" --> 08:57, Kenji Hara wrote: >> It seems to me that is a regression by fixing bug 6475. >> Now I'm trying to fix them. > > > I've filed the bug in bugzilla: > http://d.puremagic.com/issues/show_bug.cgi?id=8123 > > And posted a pull request to fix it: > https://github.com/

Re: How to test for equality of types?

2012-05-20 Thread Kenji Hara
On Sunday, 20 May 2012 at 06:57:20 UTC, Kenji Hara wrote: On Saturday, 19 May 2012 at 18:17:16 UTC, Matthias Walter wrote: Using the current git version of dmd I realized that C works! Hence, as a workaround it can be used by creating a local alias A and subsequently using A.Alias in the is-ex