Calling ShellExecute to open a URL in the default browser

2010-08-04 Thread Daniel Worthington
I am trying to compile the following code using: dmd test.d or dmd test.d shell32.lib import std.c.windows.windows; int main(string[] args) { extern (Windows) HINSTANCE ShellExecuteW(HWND, LPCWSTR, LPCWSTR, LPCWSTR, LPCWSTR, INT); HINSTANCE i = ShellExecuteW(null, "open", "http://www

Re: Calling ShellExecute to open a URL in the default browser

2010-08-04 Thread Simen kjaeraas
Daniel Worthington wrote: import std.c.windows.windows; int main(string[] args) { extern (Windows) HINSTANCE ShellExecuteW(HWND, LPCWSTR, LPCWSTR, LPCWSTR, LPCWSTR, INT); HINSTANCE i = ShellExecuteW(null, "open", "http://www.example.com";, null, null, SW_SHOW); return 0; } Err

std.algorithm.sort fails?

2010-08-04 Thread Johannes Pfau
Hi, I'm trying to sort an array of strings exactly the way it's done in the docs, but I don't get the expected results: import std.algorithm; import std.stdio; import std.contracts; void main() { string[] arr = ["unions", "vars", "d_enum", "constructors",

Re: std.algorithm.sort fails?

2010-08-04 Thread Jonathan M Davis
On Wednesday 04 August 2010 02:17:31 Johannes Pfau wrote: > Hi, I'm trying to sort an array of strings exactly the way it's done in > the docs, but I don't get the expected results: > > > import std.algorithm; > import std.stdio; > import std.contracts; > > void main(

hijacking a class's members

2010-08-04 Thread Rory Mcguire
Hi, The code below is my beginning to attempt a class which implements any class and throws an exception if one tries to access any member of that class. Problem is that if I use: auto a1 = noinit!(A)(); it works and accesses the int x() {...} member of the generated class, but if I use: A a1 =

Re: hijacking a class's members

2010-08-04 Thread Mafi
Am 04.08.2010 12:11, schrieb Rory Mcguire: Hi, The code below is my beginning to attempt a class which implements any class and throws an exception if one tries to access any member of that class. Problem is that if I use: auto a1 = noinit!(A)(); it works and accesses the int x() {...} member

Re: cannot evalute mixin(uuid("bla")) at compile time

2010-08-04 Thread Steven Schveighoffer
On Tue, 03 Aug 2010 21:04:26 -0400, Sam Hu wrote: Richard Webb Wrote: The Juno library has a 'uuid' that works like that, and the posted example seems to build ok here using DMD 1.062. Theres also a Tango version of the same code in the dwin library, but i haven't tried that for ages. T

Re: cannot evalute mixin(uuid("bla")) at compile time

2010-08-04 Thread Richard Webb
Dwin uses Tango and so only works in D1 anyway, so i don't know if thats the problem (Juno uses string already, and i've used that ok in D1 and D2). I've managed to get Juno working with a recent D2 before, but with the latest SVN version i get: /// ph

Re: cannot evalute mixin(uuid("bla")) at compile time

2010-08-04 Thread Steven Schveighoffer
On Wed, 04 Aug 2010 08:35:18 -0400, Richard Webb wrote: Dwin uses Tango and so only works in D1 anyway, so i don't know if thats the problem (Juno uses string already, and i've used that ok in D1 and D2). All I'm saying is that is what the error message is saying "you're trying to mixin

DMD D2: Unittest in static lib

2010-08-04 Thread Ettienne Gilbert
Hi, I am experienced in C++ but still a relative D newbie... I am building a static lib containing a bunch of functions that I often re-use. I will use these in other exe/dll projects by linking to the lib [and specifying the necessary Import paths..]. Everything is working ok when I test the co

Re: DMD D2: Unittest in static lib

2010-08-04 Thread Jesse Phillips
On Wed, 04 Aug 2010 12:50:45 +, Ettienne Gilbert wrote: > I have even - in desperation [did not really think it would work] - > tried to pass "--main" as an argument to the compiler [described by > Andrei in "The D Programming Language" in $5.1 on p133], in the hope > that I can fool the comp

Re: DMD D2: Unittest in static lib

2010-08-04 Thread Don
Ettienne Gilbert wrote: Hi, I am experienced in C++ but still a relative D newbie... I am building a static lib containing a bunch of functions that I often re-use. I will use these in other exe/dll projects by linking to the lib [and specifying the necessary Import paths..]. Everything is wor

Re: hijacking a class's members

2010-08-04 Thread Rory Mcguire
Mafi wrote: > Am 04.08.2010 12:11, schrieb Rory Mcguire: >> Hi, >> >> The code below is my beginning to attempt a class which implements any >> class and throws an exception if one tries to access any member of that >> class. >> >> Problem is that if I use: >> auto a1 = noinit!(A)(); >> >> it work

Re: hijacking a class's members

2010-08-04 Thread Mafi
Thats what feels weird to me. a.x can result in different things happening even though x exists in both A and the generated class. However the generated class has two "fields" called x one you can't access anymore and the @property one. When I create an instance of the generated class I would expe

Re: hijacking a class's members

2010-08-04 Thread Stanislav Blinov
04.08.2010 14:11, Rory Mcguire wrote: Hi, The code below is my beginning to attempt a class which implements any class and throws an exception if one tries to access any member of that class. Problem is that if I use: auto a1 = noinit!(A)(); it works and accesses the int x() {...} member of t

Re: hijacking a class's members

2010-08-04 Thread Rory Mcguire
Mafi wrote: >> Thats what feels weird to me. a.x can result in different things >> happening even though x exists in both A and the generated class. However >> the generated class has two "fields" called x one you can't access >> anymore and the @property one. >> When I create an instance of the g

Re: cannot evalute mixin(uuid("bla")) at compile time

2010-08-04 Thread Philippe Sigaud
On Wed, Aug 4, 2010 at 14:48, Steven Schveighoffer wrote: > On Wed, 04 Aug 2010 08:35:18 -0400, Richard Webb > wrote: > > I haven't worked out whats causing the problem yet, though looking at > the Phobos > >> code i'm not sure what the >> >> is(char[1 + Range.empty])) >> > > Not sure

Recursive templated structs disallowed?

2010-08-04 Thread Simen kjaeraas
struct bar( T ) { auto baz( U )( U arg ) { bar!( typeof( this ) ) tmp; return tmp; } } void main( ) { bar!int n; n.baz( 3 ); } This code fails with Error: recursive template expansion for template argument bar!(int) Now, I agree it is recursive, but it is not infi

Re: cannot evalute mixin(uuid("bla")) at compile time

2010-08-04 Thread Steven Schveighoffer
On Wed, 04 Aug 2010 14:52:14 -0400, Philippe Sigaud wrote: On Wed, Aug 4, 2010 at 14:48, Steven Schveighoffer wrote: On Wed, 04 Aug 2010 08:35:18 -0400, Richard Webb wrote: I haven't worked out whats causing the problem yet, though looking at the Phobos code i'm not sure w

Re: Recursive templated structs disallowed?

2010-08-04 Thread Steven Schveighoffer
On Wed, 04 Aug 2010 15:37:32 -0400, Simen kjaeraas wrote: struct bar( T ) { auto baz( U )( U arg ) { bar!( typeof( this ) ) tmp; return tmp; } } void main( ) { bar!int n; n.baz( 3 ); } This code fails with Error: recursive template expansion for templat

Re: cannot evalute mixin(uuid("bla")) at compile time

2010-08-04 Thread Richard Webb
I don't have a minimal example, but i have found that the error only occurs with the most recent version of std.algorithm -> the current SVN version of phobos with the previous revision of algorithm compiles ok.

Re: Recursive templated structs disallowed?

2010-08-04 Thread Simen kjaeraas
Steven Schveighoffer wrote: On Wed, 04 Aug 2010 15:37:32 -0400, Simen kjaeraas wrote: struct bar( T ) { auto baz( U )( U arg ) { bar!( typeof( this ) ) tmp; return tmp; } } void main( ) { bar!int n; n.baz( 3 ); } This code fails with Error: recursive

Re: Recursive templated structs disallowed?

2010-08-04 Thread Philippe Sigaud
On Wed, Aug 4, 2010 at 22:06, Steven Schveighoffer wrote: > On Wed, 04 Aug 2010 15:37:32 -0400, Simen kjaeraas > wrote: > > struct bar( T ) { >> auto baz( U )( U arg ) { >> bar!( typeof( this ) ) tmp; >> return tmp; >> } >> } >> >> void main( ) { >> bar!int n; >>

Re: cannot evalute mixin(uuid("bla")) at compile time

2010-08-04 Thread Philippe Sigaud
On Wed, Aug 4, 2010 at 22:00, Steven Schveighoffer wrote: > code i'm not sure what the is(char[1 + Range.empty])) >>> >>> Hm..., then shouldn't that be is(typeof(...))? > > But char[1 + ...] is already a type, no? I thought typeof() was to extract type from an express

Re: cannot evalute mixin(uuid("bla")) at compile time

2010-08-04 Thread Steven Schveighoffer
On Wed, 04 Aug 2010 17:31:30 -0400, Philippe Sigaud wrote: On Wed, Aug 4, 2010 at 22:00, Steven Schveighoffer wrote: code i'm not sure what the is(char[1 + Range.empty])) Hm..., then shouldn't that be is(typeof(...))? But char[1 + ...] is already a type, no? I thought typeo

One question about templates

2010-08-04 Thread bearophile
How can I tell that S1 and S2 are different instantiations of the same struct template, while Bar is an instantiation of a different struct template? struct Foo(T...) {} struct Bar(T...) {} template SameStructTemplate(S1, S2) { // enum bool SameStructTemplate = ? } void main() { alias

Re: One question about templates

2010-08-04 Thread bearophile
Something simpler is enough for my purposes, to tell that a type is one instantiation of Foo or not: struct Foo(T...) {} struct Bar(T...) {} template IsFoo(S) { // ? } void main() { alias Foo!(int,int,int) S1; alias Foo!(float,int,int,int) S2; alias Bar!(float,int,int,int) S3;

Re: One question about templates

2010-08-04 Thread bearophile
I have found one bad looking solution :-) template IsFoo(alias S) { enum bool IsFoo = __traits(compiles, { void isf(T...)(Foo!T){} isf(S.init); }); } Bye, bearophile

Reporting unsupported template instantiation

2010-08-04 Thread Kagamin
http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D&article_id=114518 Is there a way to report a custom error message for unsupported template instantiations?

Re: Reporting unsupported template instantiation

2010-08-04 Thread BCS
Hello Kagamin, http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmar s.D&article_id=114518 Is there a way to report a custom error message for unsupported template instantiations? template Foo(T) { static assert(Chcek!(T), "message"); ... } template Bar(T) if (is( T ==

Re: One question about templates

2010-08-04 Thread Philippe Sigaud
On Thu, Aug 5, 2010 at 04:26, bearophile wrote: > I have found one bad looking solution :-) > > template IsFoo(alias S) { >enum bool IsFoo = __traits(compiles, { void isf(T...)(Foo!T){} > isf(S.init); }); > } > I used to be confronted to this pb too. Here is what I did: /** Alias itself to