Re: conv.to for radixes

2011-11-22 Thread Andrej Mitrovic
Oki, http://d.puremagic.com/issues/show_bug.cgi?id=6992 .

Re: conv.to for radixes

2011-11-22 Thread Jonathan M Davis
On Wednesday, November 23, 2011 04:39:37 Andrej Mitrovic wrote: > Is there any special reason why conv.to doesn't work with radixes, and > we have to use parse instead? > > import std.conv; > import std.stdio; > > void main() > { > writeln(parse!int("ff", 16)); // ok > writeln(to!int("ff

Re: conv.to for radixes

2011-11-22 Thread Andrej Mitrovic
Let me demonstrate why this is a problem: string get() { return "ff"; } void main() { writeln(parse!int(get(), 16)); } Error: get() is not an lvalue

conv.to for radixes

2011-11-22 Thread Andrej Mitrovic
Is there any special reason why conv.to doesn't work with radixes, and we have to use parse instead? import std.conv; import std.stdio; void main() { writeln(parse!int("ff", 16)); // ok writeln(to!int("ff", 16)); // NG }

Re: Convert SysTime to TickDuration?

2011-11-22 Thread Jonathan M Davis
On Wednesday, November 23, 2011 03:12:25 Andrej Mitrovic wrote: > Interesting, it might just be stdTime like you've said. I do get a > slightly different reading though: > > D2 Phobos: > import std.stdio; > import std.file; > void main() > { > auto x = timeLastModified(`c:\test.d`).stdTime; >

Re: Convert SysTime to TickDuration?

2011-11-22 Thread Andrej Mitrovic
Interesting, it might just be stdTime like you've said. I do get a slightly different reading though: D2 Phobos: import std.stdio; import std.file; void main() { auto x = timeLastModified(`c:\test.d`).stdTime; writeln(x); } D1 Tango: import Path = tango.io.Path; import tango.io.Stdout; vo

Re: Convert SysTime to TickDuration?

2011-11-22 Thread Andrej Mitrovic
Yeah, Tango doesn't really say much except "Get the number of ticks that this timespan represents.": http://www.dsource.org/projects/tango/docs/stable/tango.time.Time.html#TimeSpan.ticks I'll have to install Tango to test the code. Anyway thanks for your help!

Re: Convert SysTime to TickDuration?

2011-11-22 Thread Jonathan M Davis
On Wednesday, November 23, 2011 01:01:54 Andrej Mitrovic wrote: > I'm trying to port some Tango D1 code to D2, I don't know why ticks > are used, but this was the code: > > timeModified = Path.modified(path).ticks; > > It fetches the modification date of a file and apparently converts > that to t

Re: Convert SysTime to TickDuration?

2011-11-22 Thread Andrej Mitrovic
I'm trying to port some Tango D1 code to D2, I don't know why ticks are used, but this was the code: timeModified = Path.modified(path).ticks; It fetches the modification date of a file and apparently converts that to ticks. I've tried using Phobos' std.file.timeLastModified which returns a SysTi

Re: Convert SysTime to TickDuration?

2011-11-22 Thread Jonathan M Davis
On Wednesday, November 23, 2011 00:24:13 Andrej Mitrovic wrote: > I need the number of ticks for a file's modification date. > > module test; > import std.datetime; > import std.file; > import std.stdio; > > void main() > { > auto res1 = TickDuration(timeLastModified("test.d")); // NG > auto res2

Re: How come a thread can access another thread's stack variable?

2011-11-22 Thread Simen Kjærås
On Tue, 22 Nov 2011 23:00:17 +0100, Andrej Mitrovic wrote: import core.thread; import std.stdio; struct Foo { int field; void test() { writeln("field: ", &field); } } void main() { Foo foo; auto thread = new Thread(&foo.test); thread.start(); thread.j

Convert SysTime to TickDuration?

2011-11-22 Thread Andrej Mitrovic
I need the number of ticks for a file's modification date. module test; import std.datetime; import std.file; import std.stdio; void main() { auto res1 = TickDuration(timeLastModified("test.d")); // NG auto res2 = TickDuration.from!"hnsecs"(timeLastModified("test.d").stdTime); writel

How come a thread can access another thread's stack variable?

2011-11-22 Thread Andrej Mitrovic
import core.thread; import std.stdio; struct Foo { int field; void test() { writeln("field: ", &field); } } void main() { Foo foo; auto thread = new Thread(&foo.test); thread.start(); thread.join(); foo.test(); } This prints the same addresses. std.con

Re: mixin on identifier

2011-11-22 Thread Philippe Sigaud
Hi there, template recursion can get difficult to write sometimes. For the mixin part, since what you're doing is looping on States, another solution is to use string mixins: string stateCode(States...)() { string code; foreach(state; States) code ~= "mixin " ~ __traits(identifier

Re: DFastCGI

2011-11-22 Thread Kai Meyer
On 11/22/2011 07:26 AM, bioinfornatics wrote: dear, i started to interface fastcgi to D https://github.com/bioinfornatics/DFastCGI They are a Readme and some example for quick start at this time take example from examples/test3_fcgiapp.d Any help are welcome Thanks I don't see a test3_fcg

Optimization in std.algorithm.max?

2011-11-22 Thread Jesse Phillips
There is a good possibility that I don't know anything, but is there something about doing two checks that goes faster? static if (isIntegral!(T1) && isIntegral!(T2) && (mostNegative!(T1) < 0) != (mostNegative!(T2) < 0)) static if (mostNegative!(T1) < 0)

Re: Internal error: ..\ztc\cgcs.c 352

2011-11-22 Thread Trass3r
Please check if your case is equal to http://d.puremagic.com/issues/show_bug.cgi?id=4414

Internal error: ..\ztc\cgcs.c 352

2011-11-22 Thread Nrgyzer
Hi guys, I get an internal error in \ztc\cgcs.c 352 when I try to do the following: HashMap!(uint, float[2]) example; void main() { example = new HashMap!(uint, float[2])(); example.set(0, [10.f, 20.f]); example.set(10, [100.f, 200.f]); foreach (ref c; example.keys) std.stdio.writel

Re: Fields size property

2011-11-22 Thread Andrej Mitrovic
:) On 11/22/11, Dejan Lekic wrote: > > This one is not good either because it does not include TypeInfo, etc... > > __traits(classInstanceSize, T)) is better choice, as Ali said... :) >

Re: Queue thread

2011-11-22 Thread Kai Meyer
On 11/21/2011 11:27 AM, Andrej Mitrovic wrote: How come you don't have any threads per CPU? I guess this is a difference between multi-processor and multi-core machines maybe? I don't know, I'm not much of a hardware guy. Here's the 8th CPU's entry from /proc/cpuinfo. This is a Dell Optiplex 9

Re: Make a variable single-assignment?

2011-11-22 Thread Ary Manzana
On 11/21/11 1:17 PM, Kapps wrote: For one reason, public fields that lack a set without having to create a backing field, followed by a bulky property. It does sound lazy, but when it's something you have to repeat many times, it gets annoying. On 21/11/2011 9:43 AM, Ary Manzana wrote: On 11/21

Re: Fields size property

2011-11-22 Thread Dejan Lekic
This one is not good either because it does not include TypeInfo, etc... __traits(classInstanceSize, T)) is better choice, as Ali said... :)

Re: DFastCGI

2011-11-22 Thread Dejan Lekic
Good news! This should be a part of the Deimos organisation. :) Also, the post should be in the D.announce newsgroup. :) Well-done!

DFastCGI

2011-11-22 Thread bioinfornatics
dear, i started to interface fastcgi to D https://github.com/bioinfornatics/DFastCGI They are a Readme and some example for quick start at this time take example from examples/test3_fcgiapp.d Any help are welcome Thanks

Re: mixin on identifier

2011-11-22 Thread Johannes Totz
On 22/11/2011 04:57, David Nadlinger wrote: Turns out to be surprisingly tricky… A possible solution is: mixin template StateOne() { int value; } mixin template StateTwo() { float data; } mixin template MixinAll(T...) { static if (T.length > 0) { alias T[0] A; mixin A; mixin MixinAll!(T[1 .. $

Re: Is __VERSION__ cross-compiler compatible?

2011-11-22 Thread Andrew Wiley
On Mon, Nov 21, 2011 at 8:16 PM, Andrej Mitrovic wrote: > GDC does seem to use this, now that I've tested it: > > D:\dev\code\d_code>gdc test.d > 1067L > > D:\dev\code\d_code>gdc -v2 test.d > 2052L > > I've found the docs, it states this is a compiler token: > http://d-programming-language.org/lex