Re: non-constant error for module AAs

2011-01-25 Thread Lars T. Kyllingstad
On Mon, 24 Jan 2011 10:45:03 -0500, Andrej Mitrovic wrote: Is this a bug? import std.stdio; string[string] values = [abc:abc, def:def]; void main() { string[string] values2 = [abc:abc, def:def]; } test.d(3): Error: non-constant expression [abc:abc,def:def] What's

How to Mixin a Type List?

2011-01-25 Thread Nick
Instead of mixing in type by type, is there a way to mixin a Type Tuple? Some foreach Type mixin; Otherwise, I guess recursive templated inheritance with a single mixin at each level should to the trick? Thanks, Nick

Re: non-constant error for module AAs

2011-01-25 Thread spir
On 01/25/2011 08:54 AM, bearophile wrote: Andrej Mitrovic: It's interesting that enum works but immutable doesn't. enum will do, Thanks. But there are some problems with enum AAs. Take a look at this little program: enum int[int] aa = [1:2, 3:4]; int foo(int x) { return aa[x]; } void

Re: non-constant error for module AAs

2011-01-25 Thread spir
On 01/25/2011 09:13 AM, Lars T. Kyllingstad wrote: On Mon, 24 Jan 2011 10:45:03 -0500, Andrej Mitrovic wrote: Is this a bug? import std.stdio; string[string] values = [abc:abc, def:def]; void main() { string[string] values2 = [abc:abc, def:def]; } test.d(3): Error: non-constant

Re: concatenation

2011-01-25 Thread Steven Schveighoffer
On Mon, 24 Jan 2011 18:39:39 -0500, Simen kjaeraas simen.kja...@gmail.com wrote: Ellery Newcomer ellery-newco...@utulsa.edu wrote: in the following: void main(){ char[] x; string s; string y; y = s ~ x; } tok.d(5): Error: cannot implicitly convert expression

template magic

2011-01-25 Thread spir
Hello, This post is about the various roles D templates can play. I had to write a higher-order function (hof) that takes as parameter a func which itself returns any kind of type. Thus, the hof is also templated. (Below the simplest case I could find as example.) Unlike in functional

template this parameters

2011-01-25 Thread Trass3r
Why do they exist and why does typeof(this) strip constness? import std.stdio; struct S { const void foo(this T)(int i) { writeln(typeid(T)); } const void bar() { writeln(typeid(typeof(this))); } } void main() { const(S) s; (s).foo(1); S s2;

Re: template magic

2011-01-25 Thread Steven Schveighoffer
On Tue, 25 Jan 2011 10:21:29 -0500, spir denis.s...@gmail.com wrote: Hello, This post is about the various roles D templates can play. I had to write a higher-order function (hof) that takes as parameter a func which itself returns any kind of type. Thus, the hof is also templated. (Below

Re: template magic

2011-01-25 Thread Trass3r
2. What is the reason for Phobos defining param funcs as template params? Correct me if I'm wrong but there's no way to pass an arbitrary function to a function in a type-safe way. If you use pointers and casts you can't check if the passed function meets certain requirements (parameters, return

Re: template this parameters

2011-01-25 Thread Simen kjaeraas
Trass3r u...@known.com wrote: Why do they exist and why does typeof(this) strip constness? Template this parameters allow for covariant return types, that's about all the use cases I've found for it. It seems like such a great thing, almost doing automatic overriding of methods in subclasses,

Re: template this parameters

2011-01-25 Thread Steven Schveighoffer
On Tue, 25 Jan 2011 10:44:23 -0500, Trass3r u...@known.com wrote: Why do they exist It tells you the exact type of this at the call site. For const struct functions, this will tell you what the actual constness of the variable is. For classes, this may give you the derived or base class

Re: template this parameters

2011-01-25 Thread Steven Schveighoffer
On Tue, 25 Jan 2011 10:58:18 -0500, Steven Schveighoffer schvei...@yahoo.com wrote: That seems like a bug, but actually, I'd not trust typeid. typeid is actually a runtime-defined TypeInfo class, which you are calling toString on, which is not telling you exactly what the compiler thinks

Re: template magic

2011-01-25 Thread Jesse Phillips
Trass3r Wrote: 2. What is the reason for Phobos defining param funcs as template params? Correct me if I'm wrong but there's no way to pass an arbitrary function to a function in a type-safe way. If you use pointers and casts you can't check if the passed function meets certain

Re: template magic

2011-01-25 Thread Simen kjaeraas
Trass3r u...@known.com wrote: 2. What is the reason for Phobos defining param funcs as template params? Correct me if I'm wrong but there's no way to pass an arbitrary function to a function in a type-safe way. If you use pointers and casts you can't check if the passed function meets certain

Re: template magic

2011-01-25 Thread spir
On 01/25/2011 06:03 PM, Simen kjaeraas wrote: Of course, given a non-template function, it is impossible to safely pass a function to it. Dont you count this as typesafe function passing? void writeRounding (int function (float) roundingScheme) {...} Denis -- _ vita

Re: template magic

2011-01-25 Thread Trass3r
How do you not pass them in a safe manner? If you are casting things, of course you don't get type safety. Yep, I was talking about non-template functions. Only way to pass an arbitrary function is via void*

shared library loader (wrapper for GetProcAddress Co)

2011-01-25 Thread Trass3r
I can't seem to find something like that in phobos. Is it missing or am I overlooking it?

Re: shared library loader (wrapper for GetProcAddress Co)

2011-01-25 Thread Andrej Mitrovic
I don't think there are any, searching for GetProcAddress only returns loader.d which seems to be an old module for loading executables but probably unrelated to DLLs (?). There's dll_helper.d in druntime\src\core\ but it only has some TLS workaround features. I've found some good solutions for

Re: C# code sample

2011-01-25 Thread Mandeep Singh Brar
On Mon, 24 Jan 2011 14:39:33 -0500, Simen kjaeraas simen.kja...@gmail.com wrote: pragma the_ignora...@hotmail.com wrote: Hi i come from a c# background I would like to write the following code in the according D style but i'm not sure howto do it c# code: void foo(IEnumerabledouble[]

Interface problems

2011-01-25 Thread Mandeep Singh Brar
Hi, Not a question but just raising a concern i am facing again and again. The current implementation of interfaces seem to be creating a number of problems. I am not able to: - find indexOf interface in an interface range using std.algorithm. - compare interface objects - assign interface to

Re: C# code sample

2011-01-25 Thread Jesse Phillips
Mandeep Singh Brar Wrote: How about simply saying: void foo(double[] data) { foreach (d; data) { do_some_stuff(d); } } all ranges are already foreachable. Regards Mandeep He is iterating over a range/iterable of double[], Simen got the type check wrong, which I

Re: template magic

2011-01-25 Thread Jesse Phillips
spir Wrote: On 01/25/2011 06:03 PM, Simen kjaeraas wrote: Of course, given a non-template function, it is impossible to safely pass a function to it. Dont you count this as typesafe function passing? void writeRounding (int function (float) roundingScheme) {...} He means

override '.' member access

2011-01-25 Thread spir
Hello, Cannot find corresponding opSomething method, if any. (opDispatch seems to specialise for method call.) Else, how to catch obj.member? Denis -- _ vita es estrany spir.wikidot.com

Re: Interface problems

2011-01-25 Thread bearophile
Mandeep Singh Brar: I am not able to: - find indexOf interface in an interface range using std.algorithm. I don't understand. Please explain better. - compare interface objects What kind of comparisons do you need to perform and why? - assign interface to generic objects. Why do you

Re: override '.' member access

2011-01-25 Thread Jonathan M Davis
On Tuesday, January 25, 2011 11:33:24 spir wrote: Hello, Cannot find corresponding opSomething method, if any. (opDispatch seems to specialise for method call.) Else, how to catch obj.member? You're trying to override a member variable? Or are you trying to override the dot operator? You

Re: How to Mixin a Type List?

2011-01-25 Thread Philippe Sigaud
On Tue, Jan 25, 2011 at 12:33, Nick n...@example.com wrote: Instead of mixing in type by type, is there a way to mixin a Type Tuple? Some foreach Type mixin; Otherwise, I guess recursive templated inheritance with a single mixin at each level should to the trick? Could you give an example of

Re: override '.' member access

2011-01-25 Thread Simen kjaeraas
spir denis.s...@gmail.com wrote: Hello, Cannot find corresponding opSomething method, if any. (opDispatch seems to specialise for method call.) Else, how to catch obj.member? opDispatch is likely what you want. with the @property annotation, it will readily support obj.member; and

Re: D2 and gdb

2011-01-25 Thread Steven Schveighoffer
On Tue, 25 Jan 2011 15:44:59 -0500, vnm gre...@tut.by wrote: Why gdb can't show line information and why it shows symbols in mangled form ? Is this software issues or I'm doing something wrong ? AFAIK, gdb 7.2 integrated some patch for D support (including symbols demangling feature). This

Re: override '.' member access

2011-01-25 Thread Simen kjaeraas
spir denis.s...@gmail.com wrote: On 01/25/2011 10:29 PM, Simen kjaeraas wrote: spir denis.s...@gmail.com wrote: Hello, Cannot find corresponding opSomething method, if any. (opDispatch seems to specialise for method call.) Else, how to catch obj.member? opDispatch is likely what you

Re: Interface problems

2011-01-25 Thread Mandeep Singh Brar
Mandeep Singh Brar: I am not able to: - find indexOf interface in an interface range using std.algorithm. I don't understand. Please explain better. In the following snippet: Interface interfaceA{} class C:interfaceA{} class D:interfaceA{} interfaceA[] registry;