Re: Unexpected behaviour on socket

2010-02-11 Thread downs
On 10.02.2010 14:41, daoryn wrote: The buffer you are passing to receive is 0 bytes long. The std.socket.Socket.receive function is a wrapper over the normal socket function, and includes a test for an empty buffer. Daniel Ohh, I see. Thank you! I thought that the function would

Re: Are named variadic arguments possible?

2010-01-05 Thread downs
Alex wrote: Is it possible, using templates, tuples, or some other mechanism, to implement named variadic arguments in D? For example, I'd like to be able to do something like... foo( 2, bar, age : 10, status : down); and so forth. Yes, with a small hack. typedef int age_type;

Re: something weird about polymorphism

2009-11-15 Thread downs
funog wrote: The following code : -- import std.stdio; class A { void foo(A a) { writefln(A); } } class B : A { void foo(B b) { writefln(B); } } void main() { B b = new B; A a = b; assert(a is b); b.foo(b);

Re: Different class template args to generate same template instance?

2009-11-02 Thread downs
Nick Sabalausky wrote: BCS n...@anon.com wrote in message news:a6268ffc3898cc29d1f554d...@news.digitalmars.com... Hello Nick, So...is there any trickery I could do so that SubFoo!(sam) and SubFoo!(sam, human) would resolve to the same subclass of Foo? Make a SubFoo!(char[] s) that does

Re: Getting started - D meta-program question

2009-10-07 Thread downs
an if-specific syntax. Thank you for taking the time downs, -- Justin Anytime.

Re: Getting started - D meta-program question

2009-10-04 Thread downs
Justin Johansson wrote: Daniel Keep Wrote: Justin Johansson wrote: There was mention** on the general discussion group that the D foreach_reverse language construct could be replaced (emulated?) with a (D) meta-program. ** Even a novice programmer can write a meta-program to replace

Re: D1: std.md5: corrections for the given example

2009-09-17 Thread downs
notna wrote: Stewart Gordon schrieb: The .ptr is necessary, but the cast(uint) isn't. Even if a change of type were necessary, just 1U would do. (U is a suffix meaning unsigned. There's also L meaning long.) Stewart. Thank Stewart. As the std.md5-example is not working with unicode

Re: D1: std.md5: corrections for the given example

2009-09-17 Thread downs
Stewart Gordon wrote: downs wrote: snip while (auto len = file.readBlock(buffer.ptr, buffer.sizeof)) snip md5_example_2.d(7): expression expected, not 'auto' md5_example_2.d(7): found 'len' when expecting ')' md5_example_2.d(7): found '=' instead of statement (this is line 7 after I

Re: CRTP in D?

2009-08-19 Thread downs
bearophile wrote: I don't know much C++. Can CRTP be used in D1 too, to improve the performance of some D1 code? http://en.wikipedia.org/wiki/Curiously_Recurring_Template_Pattern Bye, bearophile We have this, except we call it template mixin :)

Re: Specify the type but not number of function arguments in an interface?

2009-07-07 Thread downs
downs wrote: Jarrett Billingsley wrote: On Sun, Jul 5, 2009 at 5:44 AM, downsdefault_357-l...@yahoo.de wrote: Doctor J wrote: I want to write an interface that expresses the following idea: classes implementing this interface must have a void function named update, with a fixed

Re: Specify the type but not number of function arguments in an interface?

2009-07-05 Thread downs
Doctor J wrote: I want to write an interface that expresses the following idea: classes implementing this interface must have a void function named update, with a fixed but indeterminate number of parameters of the same (template parameter) type. Use a typesafe variadic function, i.e.

Re: bitfields

2009-06-27 Thread downs
novice2 wrote: does anyone know: is D2 std.bitmanip compatible with C bitfields? can i use it, if i need translate .h file with something like this: typedef struct { unsigned int can_compress : 1; unsigned int can_uncompress : 1; unsigned int can_get_info : 1; unsigned int

Re: Should be easy

2009-06-12 Thread downs
Saaa wrote: I can't figure out how to create the IndexArray function, it should work on arrays of any depth int[][][] array; //any depth array.length=10; array[1].length=3; array[1][2].length=4; array[1][2][1]=99; writefln(array); //[[],[[],[],[0,99,0,0]],[],[],[],[],[],[],[],[]]

Re: Should be easy

2009-06-12 Thread downs
Saaa wrote: Thanks! I thought about the idea of just creating the code and mix it in, but now I can see why I failed at that: Your code is kind of read-only to me, for now, because I need to change it a bit to accept an array instead of seperat indices. Wouldn't it be nice if it worked

Re: legal identifier check

2009-05-30 Thread downs
Saaa wrote: Is there a function to check whether some string is a legal identifier? Sure. static if(is(typeof({ /* code to be checked for validity goes here */ }))) ...

Re: SQLite with D

2009-04-26 Thread downs
reimi gibbons wrote: downs Wrote: reimi gibbons wrote: im failry new to D, is there any D library project with support for SQLite, if not is there any guide so i can integrate sqlite amalgamated c source (sqlite3.c, sqlite3.h) into my D code. tools.sqlite3 might work for you. Ask me

Re: SQLite with D

2009-04-24 Thread downs
reimi gibbons wrote: im failry new to D, is there any D library project with support for SQLite, if not is there any guide so i can integrate sqlite amalgamated c source (sqlite3.c, sqlite3.h) into my D code. tools.sqlite3 might work for you. Ask me if you have any questions about it.

Re: wchar[] and wchar*

2009-04-09 Thread downs
to mention the 'T' word for fear of Downs accusing me of proselytizing. :snort: I do agree in this case. I just don't like it when Tango is proposed as an alternative and the existence of a perfectly valid Phobos solution is ignored.

Re: Sockets and D?

2009-04-05 Thread downs
Jimi_Hendrix wrote: Hi, I am new to D but not to programming. I have had some socket experience before. How would i connect to a server using sockets in D? A link to a D socket tutorial (if one exists) would also be appreciated. by the way, first post to a newsgroup for me As certain

Re: -profile and threaded code

2009-03-28 Thread downs
BCS wrote: Hello BCS, I have a program that runs an easily parallelizable loop. When I run it as a single thread it only takes about 10% longer than 2 threads (on a dual-core). I'm trying to track down the lossed time and am wondering if turning on -profile is even worth looking at. The

Re: lvalue - opIndexAssign - Tango

2009-03-15 Thread downs
The Anh Tran wrote: Hi, When porting from c++ to D, i encounter this strange discrimination: 1. Built-in AA: int[int] arr; arr[123] += 12345; arr[321]++; 2. Tango HashMap: auto hm = new HashMap!(int, int)(); hm[123] += 12345; // error not lvalue hm[123]++;

Re: Access Vialotation

2009-02-28 Thread downs
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 mechanism that D

Re: Reading and writing Unicode files

2009-02-28 Thread downs
downs wrote: jicman wrote: Greetings. Sorry guys, please be patient with me. I am having a hard time understanding this Unicode, ANSI, UTF* ideas. I know how to get an UTF8 File and turn it into ANSI. and I know how to take a ANSI file and turn it into an UTF file. But, now I have

Re: object splitting in multiple threads

2009-01-10 Thread downs
Jarrett Billingsley wrote: On Sat, Jan 10, 2009 at 12:30 AM, Jarrett Billingsley jarrett.billings...@gmail.com wrote: On Sat, Jan 10, 2009 at 12:18 AM, yes y...@no.com wrote: Does Phobos also do threadpools? From what I understand, not without modification. At least, not efficiently. Downs