Re: Limit number of compiler error messages

2012-05-22 Thread Robert Clipsham
On 19/05/2012 23:38, cal wrote: Is there a way to limit the dmd compiler to outputting just the first few errors it comes across? As Don said, if there are any useless error messages it is a bug, and needs to be reported at: http://d.puremagic.com/issues/ This said, if you're on a non-Windo

Forcing static foreach

2012-04-24 Thread Robert Clipsham
Is there anyway to force a static foreach to occur? template TT(T...) { alias T TT; } void main() { // This works foreach(s; TT!("a", "b", "c")) { mixin(`int ` ~ s ~ `;`); } enum foo = TT!("a", "b", "c"); // This fails foreach(s; foo) { mix

Re: GUI or more human readable -profile data?

2012-02-29 Thread Robert Clipsham
On 29/02/2012 21:30, simendsjo wrote: On Wed, 29 Feb 2012 22:28:29 +0100, Robert Clipsham wrote: On 29/02/2012 19:41, simendsjo wrote: http://www.digitalmars.com/ctg/trace.html Has someone made some GUI/pretty printing/dump to database or other tools to make the profile data a bit simpler

Re: GUI or more human readable -profile data?

2012-02-29 Thread Robert Clipsham
On 29/02/2012 19:41, simendsjo wrote: http://www.digitalmars.com/ctg/trace.html Has someone made some GUI/pretty printing/dump to database or other tools to make the profile data a bit simpler to digest? If you're on Windows you could try: http://h3.gd/code/xfProf/ Although I don't believe i

Re: post/pre-increment/decrement and property

2012-02-07 Thread Robert Clipsham
On 07/02/2012 23:04, Timon Gehr wrote: Try this: int _foo; @property ref foo() { return _foo; } @property ref foo(int foo) { return _foo = foo; } void main() { ++foo; } Using 'ref' instead of auto returns a reference to _foo, allowing it to be modified. Yes, but then he cannot verif

Re: post/pre-increment/decrement and property

2012-02-07 Thread Robert Clipsham
On 07/02/2012 22:37, Vidar Wahlberg wrote: Take the following code: int _foo; @property auto foo() { return _foo; } @property auto foo(int foo) { return _foo = foo; } void main() { ++foo; } This won't compile, and it sort of makes sense (at least to me), but is it (or will it in the future be)

Re: OOP Windows

2012-01-16 Thread Robert Clipsham
On 16/01/2012 00:34, DNewbie wrote: Is there a D version of this type of tutorial? https://www.relisoft.com/win32/index.htm This might be related to what you want: https://github.com/AndrejMitrovic/DWinProgramming -- Robert http://octarineparrot.com/

Exceptions in safe D

2012-01-09 Thread Robert Clipsham
Are exceptions in safe D possible? I started trying to make my code @safe (there's no reason why it can't be as far as I'm aware), but I hit the following issue: @safe class MyException : Exception { this() { super(""); } } void main() { throw new MyException("");

Re: Compile-time evaluation of real expressions?

2012-01-06 Thread Robert Clipsham
On 07/01/2012 02:28, H. S. Teoh wrote: On Sat, Jan 07, 2012 at 02:15:39AM +, Robert Clipsham wrote: On 07/01/2012 00:31, H. S. Teoh wrote: I admit I've no idea how the D compiler implements compile-time evaluation, but is it possible for the compiler to actually emit code for compile

Re: Compile-time evaluation of real expressions?

2012-01-06 Thread Robert Clipsham
On 07/01/2012 00:31, H. S. Teoh wrote: I admit I've no idea how the D compiler implements compile-time evaluation, but is it possible for the compiler to actually emit code for compile-time functions containing asm blocks and, say, execute it in a sandbox, and read the values out from the machine

Re: Read text file, line by line?

2011-12-13 Thread Robert Clipsham
On 13/12/2011 13:58, Iain S wrote: How would one achieve this in D2? I have tried for a couple of hours now and have achieved nothing but stress. import std.stdio; void main() { foreach(line; File("myTextFile.txt").byLine()) { writefln(line); } } -- Robert http://octarineparr

Re: Make a variable single-assignment?

2011-11-21 Thread Robert Clipsham
On 21/11/2011 14:04, Alex Rønne Petersen wrote: Hi, Is there any way to make a variable single-assignment, regardless of its type? I.e.: void foo() { int i = 0; i = 2; // Error: i cannot be reassigned } I realize const and immutable will do this, but they are transitive and infect the type, w

Re: Is this a bug in __traits(hasMember..)?

2011-11-08 Thread Robert Clipsham
On 08/11/2011 20:09, Tobias Pankrath wrote: which is very confusing to me. Guess this is a bug? Tobias Looks like a bug to me. This works: struct Bag(S...) { alias S Types; } template Test(/*alias i,*/ B) { void fn() { foreach(t; B.Types) { pragma(msg,

Re: How convice people that D it's wonderfull in a hour ?

2011-10-09 Thread Robert Clipsham
On 09/10/2011 11:00, Zardoz wrote: Recently I've been asked if I could give a speech about D in my university. It will be of one hour of long. I not respond yet, but I think that I will do it. Actually I have the problem that I don't know well how explain well too many features and things of D th

Re: Debug on OSX?

2011-09-06 Thread Robert Clipsham
On 06/09/2011 07:25, Jacob Carlborg wrote: On 2011-09-06 05:22, Dan Olson wrote: I tried dmd -gc like on linux but gdb on OSX doesn't seem happy. Is there a way to get the debuger to work with dmd on OSX? Thanks, Dan There are things that won't work with gdb and dmd on Mac OS X due to a bug i

Re: Insert array into an AA

2011-08-16 Thread Robert Clipsham
On 16/08/2011 20:17, nrgyzer wrote: Hi everyone, I've the following: private static ubyte[][2][hash_t] classInstances; this() { classInstances[toHash()] = new ubyte[2]; // does not work } I want insert every class instance into the hashmap. Every class instance should be contained in th

Re: Need OMF MySQL lib that actually f^*&^ works...

2011-07-22 Thread Robert Clipsham
On 22/07/2011 07:20, Nick Sabalausky wrote: Anyone have a known-working Windows OMF library for MySQL? Static or dynamic, I don't care. I've tried fucking everything and I can't get the dang thing to work. Static was a total no-go. With dynamic, using implib I got it to link, but calling any of i

Re: compile time introspection and code generation - automatically serialize to json

2011-07-21 Thread Robert Clipsham
On 21/07/2011 08:57, Tobias Pankrath wrote: Hi everyone, I'm taking a look at D again and asked myself, if it is possible to write a template mixin or something similiar that automatically serializes an object to json. For example: class MyClass { string memberA; int memberB; My

Re: compile time introspection and code generation - automatically serialize to json

2011-07-21 Thread Robert Clipsham
On 21/07/2011 08:57, Tobias Pankrath wrote: Hi everyone, I'm taking a look at D again and asked myself, if it is possible to write a template mixin or something similiar that automatically serializes an object to json. For example: class MyClass { string memberA; int memberB; My

Re: how to reduce a debug symbol error?

2011-06-28 Thread Robert Clipsham
On 28/06/2011 22:47, Trass3r wrote: Starting my cl4d executable with 'gdb main -readnow' results in Reading symbols from main...expanding to full symbols...Die: DW_TAG_type_unit (abbrev 4, offset 0x6a) parent at offset: 0xb has children: FALSE attributes: DW_AT_byte_size (DW_FORM_data1) constant

Re: Interfacing to C. extern (C) variables

2011-06-26 Thread Robert Clipsham
On 26/06/2011 20:54, Alex_Dovhal wrote: I'd like to call C functions and use C variables in D module. D calls C functions just fine, but how can I use C variables? extern(C) extern int myCVar; -- Robert http://octarineparrot.com/

Re: delegate type from function signature

2011-06-26 Thread Robert Clipsham
On 26/06/2011 08:08, Nub Public wrote: Is it possible to get the signature of a function and make a delegate type from it? Something like this: bool fun(int i) {} alias (signature of fun) DelegateType; DelegateType _delegate = delegate(int i) { return i == 0; }; alias typeof(&fun) Fun

Re: WTF! Parallel foreach more slower that normal foreach in multicore CPU ?

2011-06-23 Thread Robert Clipsham
On 23/06/2011 11:05, Zardoz wrote: I'm trying std.parallelism, and I made this code (based over foreach parallel example) : import std.stdio; import std.parallelism; import std.math; import std.c.time; void main () { auto logs = new double[20_000_000]; const num = 10;

Re: dmdscript osx.mak

2011-06-18 Thread Robert Clipsham
On 18/06/2011 21:50, Robert Clipsham wrote: On 18/06/2011 07:35, Joshua Niehus wrote: Hello, I apologize if this is the wrong forum to post this question, but I couldn't find a corresponding learn mailing list for DMDScript. I wanted to play around with DMDScript but cant seem to get st

Re: dmdscript osx.mak

2011-06-18 Thread Robert Clipsham
On 18/06/2011 07:35, Joshua Niehus wrote: Hello, I apologize if this is the wrong forum to post this question, but I couldn't find a corresponding learn mailing list for DMDScript. I wanted to play around with DMDScript but cant seem to get started. I downloaded the source and attempted to mak

Re: It's dsss live ?

2011-06-14 Thread Robert Clipsham
On 14/06/2011 18:30, Zardoz wrote: I'm learning D2, and puxxled when I see that something usefull like dsss, looks that not have any updte for too long time. In his SVN, show that not have any update in years!!! (or I'm blind). It's dsss dead ?? dsss hasn't been updated in years, you are c

Re: introspection woes (2)

2011-06-13 Thread Robert Clipsham
On 13/06/2011 13:56, Lloyd Dupont wrote: Thanks Robert! Mm.. can you (per chance!) share some code? I'm a newbie and compile time reflection is something which eludes me (so far...)! See: http://www.digitalmars.com/d/2.0/traits.html class MyClass { void method1(){} void method2(){

Re: introspection woes (2)

2011-06-13 Thread Robert Clipsham
On 13/06/2011 13:11, Lloyd Dupont wrote: Interesting... I think I understand... Thanks! :) However an other problem arise with getMembers() it always returns null! Looking at the code it seems (from my beginner's perspective) that getMembers() rely on the member field (function) xgetMembers whic

Re: Serialization libs?

2011-06-10 Thread Robert Clipsham
On 10/06/2011 08:30, Nick Sabalausky wrote: Are there any good D2 serialization libs out there that utilize introspecition (ie, don't have to manually specify all the member of each type), handle cyclic graphs and have flexible output? I've never used it, and I don't know if it's any good or ev

Re: How to avoid running out of OS thread handles when spawning lots of short-lived threads?

2011-06-09 Thread Robert Clipsham
On 10/06/2011 00:17, David Nadlinger wrote: The title says it all – how can I avoid running out of OS thread handles when spawning lots of short-lived threads? In reality, I encountered the issue while writing tests a piece of code which spawns a thread, but this is the basic issue: --- import

Re: Is it reasonable to learn D

2011-06-07 Thread Robert Clipsham
On 07/06/2011 20:47, Fabian wrote: Dear D Community, is it reasonable to learn D? I've found a lot of good points for D but I've found a lot of negative points too. I believe that I needn't to list all the point for D but I want to give a few examples against learning D I've read in some German a

Re: Compile time static array issues.

2011-05-28 Thread Robert Clipsham
On 28/05/2011 23:57, Era Scarecrow wrote: I don't seem to have a good explanation why this isn't working. All i end up getting is 'Error: cannot implicitly convert expression of type string[][] to joined[]'. I also get 'incompatible types for (("AADT") ? (16)): 'string' and 'int''. I've tr

Re: web development in D

2011-05-22 Thread Robert Clipsham
On 22/05/2011 22:40, Adam D. Ruppe wrote: Vladimir Panteleev wrote: But if your website is getting enough hits to generate more requests than the server can process, technology choice matters a lot. Yeah. I've never had that happen, so I don't really know. If it happens, it's easy enough to ch

Re: web development in D

2011-05-22 Thread Robert Clipsham
On 22/05/2011 19:11, Adam D. Ruppe wrote: I've never done any CGI stuff before, but can't you employ some kind of messaging mechanism with an already running process? Yes. I find it's quite useful when you want instant notifications on something, like a web chat application, but it could do som

Re: web development in D

2011-05-22 Thread Robert Clipsham
On 22/05/2011 13:09, Lutger Blijdestijn wrote: joe wrote: I currently do most of my web development in PHP, with some work in Ruby with RoR. Right now I'm starting to think about building my own stack for web dev (I already use my own MVC framework and libs in PHP), but I'd really like to move

Re: How to interface with existing Java Code at the API level.

2011-05-21 Thread Robert Clipsham
On 21/05/2011 09:58, Jonathan M Davis wrote: On 2011-05-21 01:04, Matthew Ong wrote: Hi, D has major potential to replace C/C++ at the system API level. What I can see D is doing now is trying to glue to the existing C API instead of replacing that OLD OLD language. But it is too early to see

Re: How to print unicode like: こ ん に ち は 世界

2011-05-19 Thread Robert Clipsham
On 19/05/2011 16:19, Matthew Ong wrote: On 5/19/2011 11:22 PM, Matthew Ong wrote: Hi, import std.stdio; alias immutable(wchar)[] String; String str="Hello, world; orΚαλημέρακόσμε; orこんにちは世界"; writeln(str); // It prints garbage on console. In Java and Go, that just works. I believe UTF-X is han

Re: Can we make auto return type inference a little more lax?

2011-05-17 Thread Robert Clipsham
On 17/05/2011 04:40, Andrej Mitrovic wrote: auto foo() { if (1) { return [0, 0]; } else { size_t one; size_t two; return [one, two]; } } void main(){ } Error: mismatched function return type inference of uint[] and int[] Surely

Re: How To Dynamic Web Rendering?

2011-05-16 Thread Robert Clipsham
On 16/05/2011 09:54, Alexander wrote: On 16.05.2011 01:25, Robert Clipsham wrote: It most definitely does not work perfectly. You highlight those that are not familiar with web development? They're the ones that use it. Visual Studio defaults to not using it now, there's a reason f

Re: How To Dynamic Web Rendering?

2011-05-15 Thread Robert Clipsham
On 15/05/2011 22:44, Alexander wrote: On 15.05.2011 22:56, Nick Sabalausky wrote: It *barely* works. And I *did* stop using it specifically because it worked so poorly. +1 Don't get it too personally, but probably, you didn't read the manual? ;) It works perfectly, even for those who

Re: How To Dynamic Web Rendering?

2011-05-15 Thread Robert Clipsham
On 15/05/2011 22:46, Alexander wrote: On 15.05.2011 23:05, Nick Sabalausky wrote: And like I said at the beginning, the old-style-PHP/ASP of mixing code and HTML is one of the things that *HAS* become widely accepted as bad practice. Could you please back your claims with something? I know al

Re: How To Dynamic Web Rendering?

2011-05-13 Thread Robert Clipsham
On 13/05/2011 08:09, Jacob Carlborg wrote: On 2011-05-12 16:45, Adam Ruppe wrote: Could you share how or show an URL that provide sample code to do that in D? Check out my D api demo: http://arsdnet.net/cgi-bin/apidemo/ Here's the source code (about 50 lines of D) http://arsdnet.net/apidemo.

Re: How to break module into multiple file.

2011-05-12 Thread Robert Clipsham
On 12/05/2011 19:25, Adam Ruppe wrote: Maybe million line programs will be unacceptably slow, but I don't know, I'd have to actually see it being a problem in practice before I get worked up about it. tbh I wouldn't be surprised if the incremental build was actually slower than the all at once in

Re: Linux: How to statically link against system libs?

2011-05-10 Thread Robert Clipsham
On 10/05/2011 04:48, Nick Sabalausky wrote: "Adam D. Ruppe" wrote in message news:iqa7bi$1djh$1...@digitalmars.com... Nick Sabalausky wrote: 2. Remove "-L--no-warn-search-mismatch" Note for readers: this is in dmd.conf and is a relatively new thing. My dmd 2.051 and older installs always wor

Re: Cannot interpret struct at compile time

2011-05-09 Thread Robert Clipsham
On 09/05/2011 16:36, Don wrote: Robert Clipsham wrote: Hey all, I was wondering if anyone could enlighten me as to why the following code does not compile (dmd2, latest release or the beta): Added as bug 5969. Thanks for this, I wasn't sure if it was a bug or not :) -- Robert

Re: Cannot interpret struct at compile time

2011-05-08 Thread Robert Clipsham
On 08/05/2011 19:19, Lutger Blijdestijn wrote: test also doesn't compile normally on my box, dmd errors on Foo.tupleof. Not sure if this is illegal or not. I think you want the allMembers trait or something similar. Something like this: import std.traits; string test(T)() { string str = "s

Re: Cannot interpret struct at compile time

2011-05-07 Thread Robert Clipsham
On 08/05/2011 00:39, Andrej Mitrovic wrote: One simplistic solution is to use alias this to simulate the same type: struct Foo { int x, y; } string structClone(T)() { return "struct " ~ T.stringof ~ "_ { " ~ T.stringof ~ " _inner; alias _inner this; this(T..

Re: Cannot interpret struct at compile time

2011-05-07 Thread Robert Clipsham
On 07/05/2011 23:36, Andrej Mitrovic wrote: Not too sure, CTFE is a pain in the ass sometimes. What exactly are you trying to do, print field names in a custom way? No, I have a struct that I don't have access to in the scope I'm in, I do however have its type - by using the above, I can creat

Cannot interpret struct at compile time

2011-05-07 Thread Robert Clipsham
Hey all, I was wondering if anyone could enlighten me as to why the following code does not compile (dmd2, latest release or the beta): struct Foo { int a; } string test() { string str = "struct " ~ Foo.stringof ~ "_{"; foreach (j, f; Foo.tupleof) {

Re: Problem Passing Struct to C

2011-05-06 Thread Robert Clipsham
On 06/05/2011 19:40, Jacob Carlborg wrote: No, D implicitly casts string literals to zero-terminated const(char)*. That part is fine. -Steve Since when? Since const was introduced, before then they implicitly casted to char* instead. And that has been the case since early D1. -- Robert ht

Re: Coroutines in D

2011-05-03 Thread Robert Clipsham
On 03/05/2011 19:06, Andrej Mitrovic wrote: I'm trying to figure out how to use coroutines in D. First, I think I've run into some kind of bug. I've followed this C++ example: http://www.subatomicglue.com/secret/coro/readme.html, and came up with this: I'm not entirely sure what it is you wan

Re: How to spawn variable-length functions?

2011-04-26 Thread Robert Clipsham
On 26/04/2011 19:48, Andrej Mitrovic wrote: import std.stdio; import std.concurrency; void print(int[] a...) { foreach(b; a) writeln(b); } void main() { int value; spawn(&writeln, value); spawn(&print, value); } Neither of these calls will work. I want to continuou

Re: D CGI test: linux.so.2: bad ELF interpreter: No such file or directory

2011-04-26 Thread Robert Clipsham
On 26/04/2011 00:05, Nick Sabalausky wrote: Thanks. How would I statically link against libc? The way to do this with C is to pass -static to gcc, and I recall doing something similar with dmd to get it working (maybe -L-static?) - I don't have a linux machine near me to test with though, sor

Re: D CGI test: linux.so.2: bad ELF interpreter: No such file or directory

2011-04-25 Thread Robert Clipsham
On 25/04/2011 21:38, Nick Sabalausky wrote: Works on Windows command line and through IIS. And it works on my Kubuntu 10.6 command line. But if I copy the executable from my Kubuntu box to my web host's Debian server: Running it through Apache gives me a 500, and running it directly with ssh give

Re: Web development howto?

2011-04-25 Thread Robert Clipsham
On 25/04/2011 16:56, Jaime Barciela wrote: Robert, I think your effort is much needed. Thank you -- from a fellow Brown Coat :) I just hope Captain Shiny Pants doesn't find out, I don't fancy my chances against him in a fight if he realizes I stole his ship's name ;P I was toying with the

Re: Unable to pass shared class method as delegate

2011-04-24 Thread Robert Clipsham
On 24/04/2011 15:40, d coder wrote: Greetings I am facing problem passing a shared class method as an argument to a function. Look at the following minimized code snippet. class Foo { shared // compiles when commented out void bar() {} } void frop(void delegate() dg) { } void main() {

Re: delegate to shared member function

2011-04-24 Thread Robert Clipsham
On 24/04/2011 09:17, Benjamin Thaut wrote: I'm currently trying to pass a delegate to a shared member function to a function. The compiler tells me that the type I'm passing is (void delegate(const const(char[]) str) shared) When I try to use this as type for the function argument, it does not a

Re: Web development howto?

2011-04-22 Thread Robert Clipsham
On 22/04/2011 03:53, Jaime Barciela wrote: Hello everyone, I'm going though TDPL and I just joined this list. I've been looking for guidance on how to do web applications in D but I haven't found anything. My background is not C/C++ but Java (and Delphi many years ago) so I have not only a new

Re: "optional" func alias template param

2011-04-10 Thread Robert Clipsham
On 10/04/2011 15:31, spir wrote: I'd also like to know why pointer cannot be template *alias* parameters, like in: auto s2 = S!(&f)(); ==> Error: expression & f is not a valid template value argument Denis First of all, that error is useless, you should probably report a bug for that (particu

Re: Anyone have a function to print out the field name and its value?

2011-04-09 Thread Robert Clipsham
On 09/04/2011 18:44, Andrej Mitrovic wrote: On 4/9/11, Andrej Mitrovic wrote: That's great, I can use it to print out all the fields. Thanks! Some error checking should be done, or maybe there's a bug. If a field has a type that is a typedef to say a void*: typedef void* HANDLE struct S {

Re: Anyone have a function to print out the field name and its value?

2011-04-09 Thread Robert Clipsham
On 09/04/2011 18:23, Robert Clipsham wrote: Off the top of my head (untested): void print(T)(T t) if (is(T == struct) || is(T == class)) { foreach (i, field; t.tupleof) { writefln(T.tupleof[i].stringof ~ " = %s", field); } } -- Robert http://octarineparrot.com/ I forgot

Re: Anyone have a function to print out the field name and its value?

2011-04-09 Thread Robert Clipsham
On 09/04/2011 18:13, Andrej Mitrovic wrote: Let's say I have this structure: struct PAINTSTRUCT { bool state; } And somewhere in my main code I want to print out the value of state. But I also want to know what I'm printing out. So usually I'd do this: void main() { PAINTSTRUCT ps;

Re: DMD on linux?

2011-03-02 Thread Robert Clipsham
On 02/03/11 21:52, Sean Eskapp wrote: I'm trying to work with D on Ubuntu, but I keep having this issue: ... function func function func gcc Nullimorphism.o -o Nullimorphism.exe -g -m32 -l -Xlinker -L/usr/bin/../lib32 -Xlinker - L/usr/bin/../lib64 -Xlinker --no-warn-search-mismatch -Xlinker -

Re: Debugging D?

2011-02-07 Thread Robert Clipsham
On 06/02/11 22:28, Sean Eskapp wrote: == Quote from Robert Clipsham (rob...@octarineparrot.com)'s article On 06/02/11 20:29, Sean Eskapp wrote: Are debug symbols compiled with -gc stored in a separate file? Visual Studio refuses to debug my things, and windbg seems to be remarkably unhe

Re: Debugging D?

2011-02-06 Thread Robert Clipsham
On 06/02/11 20:29, Sean Eskapp wrote: Are debug symbols compiled with -gc stored in a separate file? Visual Studio refuses to debug my things, and windbg seems to be remarkably unhelpful. I suggest you take a look at VisualD if you're using visual studio, it will handle converting debug info s

Re: D2 and gdb

2011-01-25 Thread Robert Clipsham
On 25/01/11 20:44, vnm wrote: Hi! Is there any support of D2 in gdb 7.2 ? Little example to clarify my question: // file main.d int glVar = 0x; void main() { glVar = 0x; } --

Re: concatenation

2011-01-24 Thread Robert Clipsham
On 24/01/11 23:09, Ellery Newcomer wrote: in the following: void main(){ char[] x; string s; string y; y = s ~ x; } tok.d(5): Error: cannot implicitly convert expression (cast(const(char)[])s ~ x) of type char[] to string why should typeof(s ~ x) == char[] ? x is a mutable array of mutable

Re: D1: out of memory

2011-01-24 Thread Robert Clipsham
On 24/01/11 22:14, %u wrote: How do I get dmd's memory usage a few hundred MBs down? I keep having to close everything in order not to get an out of memory error while compiling (-w -full). I'd like to get it from 700-800 to below 400 :) Any way to inspect which part is the biggest drain? CTFE

Re: assert vs enforce?

2011-01-22 Thread Robert Clipsham
On 23/01/11 00:33, Sean Eskapp wrote: What's the difference between assert and enforce in D? Use assert() for something that must almost be true, regardless of user input, or anything else. enforce() on the other hand is for things which may or may not be true. The source code should clear

Associative arrays not ?:'d

2010-12-11 Thread Robert Clipsham
I was under the impression that associative arrays now used ?: to find the best type for the array? Or was this change only made in D2? The following: void main() { auto foo = [ 2 : "a", 3 : "ab" ]; } Gives the error: test.d(3): Error: cannot implicitly convert expression ("ab

Re: DMD and C compatibility on Linux

2010-11-27 Thread Robert Clipsham
On 27/11/10 22:04, Bob Cowdery wrote: I've just started to get organised to port my project from Windows to Ubuntu. I see there is now a DMD for Linux which I have installed. My question is can anyone tell me what I need to build the C libraries in to be compatible. On Windows I had to use DMC or

Re: Program option command line

2010-06-22 Thread Robert Clipsham
On 22/06/10 23:15, bioinfornatics wrote: hello, I develop in many language such C/C++ Java etc.. and i want try with D in c++ for example i use boost::program_option for parse command line. I search the same thing for D language. thanks If you're using D1/tango you can use tango.util.ArgParser

Re: shared-object libraries

2010-06-19 Thread Robert Clipsham
On 18/06/10 17:30, Chick Corea wrote: Is it possible to build a shared-object library (dot so) with D ? The only instructions that I saw for building a library are on these OS pages, e.g., for linux: http://www.digitalmars.com/d/2.0/dmd-linux.html#library And they build static/archive libr

Re: template specialization

2010-06-08 Thread Robert Clipsham
On 08/06/10 22:25, Larry Luther wrote: Q: Is this the way it's supposed to be? Yes, byte implicitly casts to ubyte so it's accepted. Try switching the templates round, they will both be byte. The way around this is to add template constraints to the templates: void get(T:ubyte)(T[] buffer)

Re: "D Programming Language"

2010-06-08 Thread Robert Clipsham
On 08/06/10 13:12, Lars T. Kyllingstad wrote: I don't know when you ordered it, but that has changed now, at least. At amazon.co.uk it costs £18.50, while at amazon.com it sells for $42.70 -- roughly £29. Also, for Europeans, the delivery cost is lower if you order from UK. -Lars I ordered i

Re: "D Programming Language"

2010-06-08 Thread Robert Clipsham
On 08/06/10 11:23, Patrick Byrne wrote: Amazon (UK) tells me that publication of this book is delayed. Is it still coming soon, please? -- Patrick Byrne I ordered it from amazon.com, it was half the priceof the UK version ;) I've had no delay message about it for a while now, the last one I g

Re: (no subject)

2010-06-06 Thread Robert Clipsham
On 06/06/10 14:00, new to d wrote: It's a typical hello world program: import std.stdio; void main(string[] args) { writeln("Hello world!"); } I also tried using printf instead of writeln. I'm compiling it with dmd test.d. I'm using dmd v2.046. I'm compiling the c program with gcc -otest2 test

Re: (no subject)

2010-06-06 Thread Robert Clipsham
On 06/06/10 13:40, new to d wrote: After reading on this newsgroup about the use of D with cgi i've tried it on my host. Even a simple hello world program gives me internal server error while equivalent c program compiled with gcc works fine. Does any one here have any idea what the problem could

Re: dynamic type casting in D

2010-05-30 Thread Robert Clipsham
On 30/05/10 19:46, dave wrote: Hi, sort of new to D programming, coming from C++. Basically the question is if there is some sort of a way to dynamically cast a variable in D much like you do in C++? ex: interface A {...} class B {...} class C : B {...} class D : B, A {...} function(B somethi

Re: enum overloading

2010-05-22 Thread Robert Clipsham
On 22/05/10 18:46, strtr wrote: I wanted to overload toString for my enums. test.d(189): Error: toString (ENUM) does not match parameter types (int) not possible? enum ENUM { a, b, c } void toString(ENUM) { } It works here. Could you show an example of some code that isn't wo

Re: help needed with gdb

2010-05-19 Thread Robert Clipsham
On 19/05/10 20:45, eles wrote: as you see, the debug session was unsuccesful. can anybody enlighten me why? what is the line "warning: the debug information found in "/lib/ld-2.11.1.so" does not match "/lib/ld-linux.so.2" (CRC mismatch)."? thank you eles You'd need to talk to the gdb devs abo

Re: Different typeof syntax

2010-05-16 Thread Robert Clipsham
On 16/05/10 21:43, bearophile wrote: Do you know if it's possible to replace typeof(f1) with f1.typeof in D (for symmetry with sizeof too)? import std.stdio: writeln; struct Foo { int x; } void main() { Foo f1; int fsize = f1.sizeof; // OK alias typeof(f1) T1; // OK

Re: Confusing behavior involving array operations.

2010-05-14 Thread Robert Clipsham
On 15/05/10 00:14, Pillsy wrote: I have the following program on Mac OS X 10.6.3 running dmd version 2.043: $ cat if.d import std.stdio; void main (string [] args) { foreach(arg; args) writeln(arg); auto vec = new double[10]; foreach(i, ref x; vec) { x = cast(double) i; } if

Re: compiled gdb

2010-05-14 Thread Robert Clipsham
On 15/05/10 00:14, eles wrote: hello, since gnu debugger (gdb) is free and now there is a version which works properly with D, could someone host (and made available for download) *compiled* versions for windows and linux? of course, patched versions (so that it would work with D). maybe on dsou

Re: Latest GDB version problems

2010-05-10 Thread Robert Clipsham
On 10/05/10 19:48, Piotrek wrote: (gdb) info locals i = 1 s = 578159222890430469 f = 9.55146781e-38 (gdb) show language The current source language is "auto; currently d". You are not using a version of gdb with D support if s is not displayed as a string. This said, I've only ever looked at v

Re: std.complex

2010-05-09 Thread Robert Clipsham
On 09/05/10 14:41, div0 wrote: Though I think there's been discussion about the whole complex number support. Not sure what's going off but I think it's going to overhauled or replaced, so you'd be better off not using std.complex std.complex has just undergone its major rewrite, I'm not sure i

Re: std.complex

2010-05-08 Thread Robert Clipsham
On 09/05/10 02:27, eles wrote: Hello, I just installed dmd 2.045 (unarchived in c:\dmd2) and put c: \dmd2\windows2\bin on path. Compiling the following: import std.complex; int main(){ return 0; } fails with: C:\dmd2>dmd test.d OPTLINK (R) for Win32 Release 8.00.2 Copyright (C)

Re: .ptr and .value

2010-05-05 Thread Robert Clipsham
On 06/05/10 00:11, bearophile wrote: Robert Clipsham: .ptr is only available for arrays. And arr.ptr returns the pointer to the start of the memory that contains the array data. While&arr is the pointer to the struct that contains the pointer and the length. Thanks for adding thi

Re: .ptr and .value

2010-05-05 Thread Robert Clipsham
On 05/05/10 23:58, strtr wrote: But wouldn't this (property sugar?) be nice? I don't like it, I can see why you would though :) int myInt = 6; int* ptrToMyInt = myInt.ptr; int myInt2 = ptrToMyInt.deref; // you probably didn't mean *myInt ;) I guess this is what I get for writing code quickl

Re: .ptr and .value

2010-05-05 Thread Robert Clipsham
On 05/05/10 23:20, strtr wrote: I keep on expecting .ptr to work on all types. What keeps this from being the case? And how about having a .value(.deref) property for known pointers? I feel a lot less comfortable with using stars and ampersands, because I keep on forgetting which one does what

Re: Operators overloading in D2 again

2010-05-02 Thread Robert Clipsham
On 02/05/10 07:14, Dan wrote: Hi everyone, is there anyway to do this with operators overloading? : The following code does it: class Tester { double x = 0.0; T opBinary(string op:"+", T)(T value) if(is(T : double)) { return x+value; }

Re: structs, templates, alias

2010-04-25 Thread Robert Clipsham
On 25/04/10 21:21, Ellery Newcomer wrote: struct Rec2{ ushort index; ushort nparams; ushort options; NoLength!(Parameter[], "nparams") params; } ... foreach(i,m; rec2.tupleof){ static if(isNoLength!(typeof(m))){ auto len = lenField!(rec2, typeof(m)); ... }else{ ... } } The other thing is, once I

Re: structs, templates, alias

2010-04-25 Thread Robert Clipsham
On 25/04/10 20:32, Ellery Newcomer wrote: Hmm. Either I'm not understanding you or I didn't explain something clearly. something like this struct Rec2{ ushort index; ushort nparams; ushort options; ushort[] params; // this has nparams elements } Rec2 rec2 = {index:1, nparams:2, options:~0, par

Re: structs, templates, alias

2010-04-25 Thread Robert Clipsham
On 25/04/10 19:15, Ellery Newcomer wrote: Yeah, that's about what I do. The trouble is getting blit to know which field is the length field. I suppose you could pass an index into the tuple to the substructure. That still wouldn't fix the substructure being able to modify the field length. I do

Re: structs, templates, alias

2010-04-25 Thread Robert Clipsham
On 25/04/10 16:04, Ellery Newcomer wrote: Does anyone have any ideas regarding this problem? I haven't looked into this fully, but for the "the length field and the array/structure are separated by one or more fields" issue, something like this should help: foreach( m; MyStruct.tupleof

Re: Arrays of many different (sub)classes

2010-04-25 Thread Robert Clipsham
On 25/04/10 14:47, Joseph Wakeling wrote: Robert Clipsham wrote: This should do what you want: Thanks! :-) Is it possible to do this with an interface instead of a base class? I'm not familiar with how the former work ... Best wishes, -- Joe Yes it is, providing the base do

Re: Arrays of many different (sub)classes

2010-04-24 Thread Robert Clipsham
On 24/04/10 20:06, Joseph Wakeling wrote: Hello all, Occasionally in C++ I find it useful to build an array which contains classes of multiple different types all using the same interface -- by constructing an array of pointers to some common base class, e.g. class BaseClass { // blah, bla

Re: equivalent of C++ implicit constructors and conversion operators

2010-04-23 Thread Robert Clipsham
On 23/04/10 17:22, #ponce wrote: In C++ implicit constructors and conversion operators allow a user-defined type to act quite like a builtin-type. struct half { half(float x);l inline operator float() const; } allows to write: half x = 1.f; float f = x; and this

Re: Code speed

2010-04-14 Thread Robert Clipsham
On 14/04/10 20:54, Don wrote: I have a vague recollection that correctly-rounded pow() will require bigint (can't quite remember, though). I'm also concerned about build tools -- I don't want them to have to know about the dependency. As a bare minimum, the error message will need to improve (wit

Re: strange template syntax

2010-04-11 Thread Robert Clipsham
On 11/04/10 16:01, Robert Clipsham wrote: When using your method, you have to use: each!(array, typeof(array))((int item) {writefln("%d", item+b)}); (I believe this is a bug, dmd should be able to deduce the type here). As for the syntax, you can do this with any fun

  1   2   >