Re: How about macro == symbol for mixin statement? [was Re: Member functions C to D]

2009-10-10 Thread Christopher Wright
Yigal Chripun wrote: On 10/10/2009 00:36, Christopher Wright wrote: Yigal Chripun wrote: On 09/10/2009 00:38, Christopher Wright wrote: It makes macros highly compiler-specific, or requires the compiler's AST to be part of the language. Nemerle took the nuclear option, and its macros

Re: How about macro == symbol for mixin statement? [was Re: Member functions C to D]

2009-10-09 Thread Christopher Wright
Yigal Chripun wrote: On 09/10/2009 00:38, Christopher Wright wrote: It makes macros highly compiler-specific, or requires the compiler's AST to be part of the language. Nemerle took the nuclear option, and its macros are all-powerful. That's a reasonable way of doing things. I'd be happy

Re: How about macro == symbol for mixin statement? [was Re: Member functions C to D]

2009-10-08 Thread Christopher Wright
Bill Baxter wrote: It seems macros are implemented as compiler extensions. You compile your macros into DLLs first, that then get loaded into the compiler as plugins. On the plus side, doing things that way you really do have access to any API you need at compile-time, using the same syntax as

Re: Getting constructor's metadata

2009-10-08 Thread Christopher Wright
Max Samukha wrote: Is it possible to get types or aliases of all constructors of a class in D2? No. __traits has some random functionality in this regard. It has a command getVirtualFunctions which only returns virtual overloads. By virtual, we mean appears in vtbl. So any non-private,

Re: How initialize a static rectangular array (2-d matrix)

2009-10-08 Thread Christopher Wright
Justin Johansson wrote: Jarrett Billingsley Wrote: On Thu, Oct 8, 2009 at 8:10 PM, Justin Johansson n...@spam.com wrote: I almost have to apologize for this question but .. How does one initialize a static rectangular array (2-d matrix) in D1? None of the following or other variations that

Re: Get template and its instantiation parameters

2009-10-07 Thread Christopher Wright
BCS wrote: Hello Michal, If one has a template instance, is it possible to get template name and parameter type that was used for instantiating, at compile time? consider: class List (T) {} List!(int) lst; Foo (lst); I want to create such template Foo which prints: List!(int) List int You

Re: Should be easy

2009-06-13 Thread Christopher Wright
Saaa wrote: I did get it to compile at one time, but didn't know how to use it, like your code.. index( array, index2); //compiles and all, but how do I set the value? index( array, index2) = -1; // doesn't work If you're using d2, add 'ref' to the return type. Otherwise, you need

Re: Encoding problems...

2009-05-28 Thread Christopher Wright
Robert Fraser wrote: Hi all, Quick question: I want to use some unicode identifiers, but I get unsupported char 0xe2, both with using and not using a BOM. The characters in question are the superset/subset-equals operators: ⊇ and ⊆... Perhaps these are just unsupported by DMD (in which case,

Re: Why do I get stack overflow?

2009-05-24 Thread Christopher Wright
Ary Borenszweig wrote: When I compile this code I get stack overflow printed in the console. Anyone know why? --- int fact(int X)() { if(X == 0) { return 1; } else { int temp = fact!(X - 1)(); return X * temp; } } const someVar = fact!(0)(); --- Like

Re: any html parser with d binding

2009-05-21 Thread Christopher Wright
BCS wrote: Hello reimi, i have 2 question here: 1) can anyone suggest good html parser with d binding? IIRC ANTLR can generate D The last supported version was 2.7.something. It depends on phobos, possibly a rather old version of it (I don't know).

Re: Determine if template argument is an array

2009-05-21 Thread Christopher Wright
Fractal wrote: Hello Any body can explan me how to determine if a template argument is an array? Thanks Have a look at std.traits or tango.core.Traits. The appropriate way to check is via the templates they define, since it's clearer. Looking at the source will tell you how to replicate

Re: struct opCmp?

2009-05-15 Thread Christopher Wright
Frits van Bommel wrote: Nick Sabalausky wrote: Can anyone think of a reasonable case where it would actually make sense to override opCmp, but not opEquals? (that is, without bastardizing them like in a C++ streams kind of way) How about a struct you want to be opCmp()-comparable (which,

Re: [static] [shared] [const|immutable]

2009-05-14 Thread Christopher Wright
Lionello Lunesu wrote: I like shared/const/immutable as much as the next guy, but there are now 2x2x3=12 ways to decorate a variable. Furthermore, by either declaring the variable globally or locally (stack), we end up with 24 possible declaration. See the code at the end of this post. The

Re: [static] [shared] [const|immutable]

2009-05-14 Thread Christopher Wright
Lionello Lunesu wrote: Christopher Wright dhase...@gmail.com wrote in message news:gugs7b$70...@digitalmars.com... Lionello Lunesu wrote: I like shared/const/immutable as much as the next guy, but there are now 2x2x3=12 ways to decorate a variable. Furthermore, by either declaring

Re: 3 variant questions

2009-05-11 Thread Christopher Wright
Saaa wrote: Christopher Wright dhase...@gmail.com wrote in message news:gu8v1b$1ut...@digitalmars.com... Saaa wrote: How do I return a variant type in D1? After assessing that a variadic argument is an array, how do I check its depth? How do I set the variable given to me through

Re: std.random:uniform - uncompilable example from docs

2009-05-10 Thread Christopher Wright
Tyro[a.c.edwards] wrote: http://www.digitalmars.com/d/2.0/phobos/std_random.html#uniform Above documentation provides the following example: Random gen(unpredictableSeed); // Generate an integer in [0, 1023] auto a = uniform(0, 1024, gen); // Generate a float in [0, 1)

Re: D styled data format, Json failed

2009-05-06 Thread Christopher Wright
Saaa wrote: My first stab at the get function. As you might see, I need help :D Thanks! How do I make the function take a variadic argument and get its type? void get(in char[][] file, in char[] identifier, ...) { TypeInfo type = _arguments[0]; void* var = _argptr; //

Re: line drawing package?

2009-05-03 Thread Christopher Wright
BCS wrote: I find my self in need of a line drawing package. I need to pop a window and draw lines and points. Text would be nice but I can live without it. Most importantly, I need something that is dirt simple to get running. I don't have time to dink around with libs (if I did have time I'd

Re: D-styled data file

2009-04-29 Thread Christopher Wright
Saaa wrote: If the JSON writer won't write every item (which will be thousands of items) on a new line and reading in multi arrays, then I think I need to witch to Tango :D Tango's JSON printer has options for pretty-printing and condensed printing. The default is condensed; everything will

Re: D-styled data file

2009-04-29 Thread Christopher Wright
Saaa wrote: Christopher Wright dhase...@gmail.com wrote in message news:gtb02h$e4...@digitalmars.com... Saaa wrote: If the JSON writer won't write every item (which will be thousands of items) on a new line and reading in multi arrays, then I think I need to witch to Tango :D Tango's JSON

Re: What does this linker messages try to tell me?

2009-04-19 Thread Christopher Wright
Frank Benoit wrote: OPTLINK (R) for Win32 Release 8.00.1 Copyright (C) Digital Mars 1989-2004 All rights reserved. C:\Project\dwtinst\dwt-rcp\lib\org.eclipse.core.databinding.lib(AbstractObservableList) Offset F0567H Record Type 00C3 Error 1: Previous Definition Different :

Re: any framework or tips for multi-tier applications

2009-03-28 Thread Christopher Wright
Qian Xu wrote: Hi All, We are redesigning a system (previously was written in C) using D. We use Boundary-Controll-Entity-Pattern. To wrap db table to entities is a very time consuming work. Is there any framework or tips for multi-tier applications in D? --Qian At times like this, I think

Re: How to reduce compile times?

2009-03-21 Thread Christopher Wright
grauzone wrote: PS: another thing that possibly would bring a speed gain would be to make dsss compile the whole project in one run, instead of invoking a new dmd process for each source file. How do I need to change the rebuild configuration to achieve this? oneatatime = [yes|no] You want

Re: Displaying type of something

2009-03-09 Thread Christopher Wright
Georg Wrede wrote: When creating templates, it is sometimes handy to print the type of something. Is there a trivial way to print it? writeln(Typeof T is: , typeof(t)); This doesn't work, but you get the idea. For a class or interface: writeln(Typeof T is: , t.classinfo.name);

Re: Template in interface ?

2009-03-01 Thread Christopher Wright
TSalm wrote: Le Sun, 01 Mar 2009 03:07:16 +0100, Christopher Wright dhase...@gmail.com a écrit: TSalm wrote: Does something have an idea on how to do something like this ? You don't. Templates cannot participate in polymorphism. I've dealt with this in the past and ended up making another

Re: Access Vialotation

2009-02-28 Thread Christopher Wright
downs wrote: BCS wrote: Reply to Jarrett, On Fri, Feb 27, 2009 at 9:01 AM, Qian Xu quian...@stud.tu-ilmenau.de wrote: Hi All, Is there any way to keep program alive, when an AV takes place? It's possible on Windows in D, but that's because Windows reports segfaults with the same

Re: function to slive a quadratic equation

2009-02-01 Thread Christopher Wright
zvia wrote: Is it true thr input way? what is din type (I didn't put its a declaration)?? Thrinput's Way was discredited in the late 1700's by a German theologian named Albrecht Kirsch. It was already in decline due to its requirements of extreme asceticism; many scholars, most notably Dr.

Re: Template Mixin issue

2009-01-30 Thread Christopher Wright
Mike L. wrote: If the compiler can tell that B!(int) is a type, why can't it tell that it is a child class of A!(int) ? This is a bug. In template specializations, : means equality. In static if, : means convertibility. So, you can use: template ADefaults(Type, AType) { static

Re: Template Mixin issue

2009-01-30 Thread Christopher Wright
Christopher Wright wrote: Mike L. wrote: If the compiler can tell that B!(int) is a type, why can't it tell that it is a child class of A!(int) ? This is a bug. In template specializations, : means equality. In static if, : means convertibility. This is only with template specializations

Re: Class and Interface Fun

2009-01-25 Thread Christopher Wright
Denis Koroskin wrote: On Sun, 25 Jan 2009 08:38:18 +0300, Tim M a...@b.com wrote: class B : A,I { void foo() { A.foo(); } } void main() { } It is too verbose and makes twice an overhead. I'd like to avoid this solution. Any reasonable compiler would inline the call to A.foo. In

.tupleof.stringof

2009-01-21 Thread Christopher Wright
Check this out! class Foo { int someField; } pragma (msg, Foo.tupleof[0].stringof); // int pragma (msg, Foo.tupleof[0].mangleof); // someField Why is this? It's counterintuitive.

Re: .tupleof.stringof

2009-01-21 Thread Christopher Wright
Christopher Wright wrote: Christopher Wright wrote: Check this out! class Foo { int someField; } pragma (msg, Foo.tupleof[0].stringof); // int pragma (msg, Foo.tupleof[0].mangleof); // someField Why is this? It's counterintuitive. Oops, no. mangleof does report the mangled name of the input

Re: .tupleof.stringof

2009-01-21 Thread Christopher Wright
Christopher Wright wrote: Check this out! class Foo { int someField; } pragma (msg, Foo.tupleof[0].stringof); // int pragma (msg, Foo.tupleof[0].mangleof); // someField Why is this? It's counterintuitive. Okay, no, this example is a shorter version of something else that exemplified

Re: compile time output

2009-01-20 Thread Christopher Wright
Sergey Gromov wrote: Comment out the traits and it compiles. Traits are supposed to be compile-time. How's that possible for them to prevent compile-time evaluation? It's the amazing powers of the DMD CTFE engine! And it's why I don't use d2 these days. I think I'll dust off some old code

Re: loop through specific class members

2009-01-20 Thread Christopher Wright
Jarrett Billingsley wrote: On Tue, Jan 20, 2009 at 10:29 AM, Trass3r mrmoc...@gmx.de wrote: It seems like there is no way to automatically get the class methods in D1 currently?! __traits isn't supported, std.traits doesn't give anything usable, .tupleof only gets the fields (plus only giving

Re: Delegate contravariance

2009-01-19 Thread Christopher Wright
Jason House wrote: Silvio Ricardo Cordeiro wrote: Is there any good reason why the following code doesn't work? The function foo requires as its argument a delegate that receives a B. This means that, because of the type soundness of the D language, the delegate will only be called with

Re: confused with some_var.dup

2009-01-17 Thread Christopher Wright
Rainer Deyke wrote: Christopher Wright wrote: You can create a COW array struct pretty easily. However, this will be pretty slow in a lot of cases. A built-in COW type does not need to be slow! The compiler can use static analysis to eliminate unnecessary copies, and reference counting can

Re: using a typedefed variable with library classes

2009-01-15 Thread Christopher Wright
Charles Hixson wrote: A) Yes, it works the way that you say. This damages it's utility. B) I'm replying to a question as to how typedef could reasonably be extended. The point of a typedef is to provide additional type safety. This would not exist if you could implicitly cast back and

Re: confusing (buggy?) closure behaviour

2008-12-13 Thread Christopher Wright
Zoran Isailovski wrote: Oh... I've got the wrong impression from the papers about D. (But then, why would someone design an *unsafe* language *by intention*??? For that, we've got C and C++, don't we?) Anyway, I've been looking for a modern and *safe* language, but without the overkill of a

Re: CTFE - filling an array

2008-12-09 Thread Christopher Wright
The Anh Tran wrote: static double[N] dd = void; dd is not a compile-time constant. static auto tmp = f!(N).fn(dd); The initializer of tmp must be a compile-time constant, but since dd is not a compile-time constant, you can't use CTFE on fn.

Re: Freeing of memory (garbage collection)

2008-12-09 Thread Christopher Wright
Daniel White wrote: That would be a bad idea. Then how would you do manual memory management in the few cases that absolutely require it? Two ways. Either: a: being able to lock the variable so that the garbage collector can't touch it until you unlock it. If you have a reference to the

Re: which version of D for beginers?

2008-11-23 Thread Christopher Wright
Kagamin wrote: Hoenir Wrote: Lutger schrieb: There are a few changes that need to be done when porting code from D1 to D2. It may be helpful to find out what those are at an early stage and program your applications with these in mind. That will help when D2 is more stabilized and you want to

Getting environment variables?

2008-11-22 Thread Christopher Wright
Hey all, How do I get environment variables in a D program? I specifically want the path to a user's home folder. Ta muchly.

Re: access subclass functions

2008-11-20 Thread Christopher Wright
Saaa wrote: from the list (private, protected, public) pick public. Note the difference between peel and peal. :) public YellowBanana: Banana { void doStuff() { bool e = peel(); //visible from derived //class when defined protected or public. } } Banana a =

Re: including a file

2008-11-10 Thread Christopher Wright
Jarrett Billingsley wrote: On Sun, Nov 9, 2008 at 10:18 PM, James [EMAIL PROTECTED] wrote: i created to include file, 1 with 'module xxx' declaration and the other without it. but i still can import both files. what is the diff here? Not a lot. The module declaration doesn't serve much