Re: typeof(string.front) should be char

2012-03-03 Thread Jonathan M Davis
On Friday, March 02, 2012 20:41:35 Ali Çehreli wrote: On 03/02/2012 06:30 PM, Piotr Szturmaj wrote: Hello, For this code: auto c = testc; auto w = testw; auto d = testd; pragma(msg, typeof(c.front)); pragma(msg, typeof(w.front)); pragma(msg, typeof(d.front));

Sending Tid in a struct

2012-03-03 Thread Nicolas Silva
Hi, I'm trying to send structs using std.concurrency. the struct contains a Tid (the id of the sender) so that the receiver can send an answer. say: struct Foo { Tid tid; string str; } // ... Foo f = { tid: thisTid, str: hello! }; std.concurrency.send(someThread, f); //

Re: Evaluating __FILE__ and __LINE__ of caller?

2012-03-03 Thread bioinfornatics
Le samedi 03 mars 2012 à 02:39 +0100, Adam D. Ruppe a écrit : On Saturday, 3 March 2012 at 01:36:51 UTC, H. S. Teoh wrote: int opIndex(int x) { Make that (int x, string file = __FILE__, int line = __LINE__) and use file/line in there. The exception consturctors do this, so

Re: Dumb question about git

2012-03-03 Thread Jacob Carlborg
On 2012-03-02 20:30, David Nadlinger wrote: On Friday, 2 March 2012 at 18:10:56 UTC, Jonathan M Davis wrote: Both should work, and the man page is going to be for git-rebase. Pretty much all of the git commands can be used with or without a -. On my system, the dashed commands are not

Re: typeof(string.front) should be char

2012-03-03 Thread Jacob Carlborg
On 2012-03-03 03:30, Piotr Szturmaj wrote: Hello, For this code: auto c = testc; auto w = testw; auto d = testd; pragma(msg, typeof(c.front)); pragma(msg, typeof(w.front)); pragma(msg, typeof(d.front)); compiler prints: dchar dchar immutable(dchar) I thought all these would be either dchar

Re: typeof(string.front) should be char

2012-03-03 Thread Piotr Szturmaj
Jonathan M Davis wrote: On Friday, March 02, 2012 20:41:35 Ali Çehreli wrote: On 03/02/2012 06:30 PM, Piotr Szturmaj wrote: Hello, For this code: auto c = testc; auto w = testw; auto d = testd; pragma(msg, typeof(c.front)); pragma(msg, typeof(w.front));

Re: typeof(string.front) should be char

2012-03-03 Thread Ali Çehreli
On 03/03/2012 04:36 AM, Jacob Carlborg wrote: On 2012-03-03 03:30, Piotr Szturmaj wrote: Hello, For this code: auto c = testc; auto w = testw; auto d = testd; pragma(msg, typeof(c.front)); pragma(msg, typeof(w.front)); pragma(msg, typeof(d.front)); compiler prints: dchar dchar

Build error about LockingTextWriter

2012-03-03 Thread bioinfornatics
Dear, i do not understand what is wrong in my code and produce this: - $ ldc2 ../../lib/libdscience-ldc.a -I=../.. fasta.d /usr/include/d/std/range.d(295): Error: static assert Cannot put a Sequence into a LockingTextWriter instantiatied in

Re: typeof(string.front) should be char

2012-03-03 Thread Ali Çehreli
On 03/03/2012 05:57 AM, Piotr Szturmaj wrote: Consider a custom range of char: struct CharRange { @property bool empty(); @property char front(); void popFront(); } typeof(CharRange.front) and ElementType!CharRange both return _char_ Yes, and I would expect both to the same type.

Re: Evaluating __FILE__ and __LINE__ of caller?

2012-03-03 Thread Andrej Mitrovic
On 3/3/12, bioinfornatics bioinfornat...@fedoraproject.org wrote: I think __LINE__ is size_t not int I'd love to see a 2_147_483_648 line source file! :D

Delegator

2012-03-03 Thread bioinfornatics
hi, In ruby we can delegate some method. by example: Ruby class MineArray include Forwardable def_delegators: @array, :[], :[]=, :each_with_index, :length def initialize( array ) @array = array end end - this code delegate opIndexAssign opIndex, length ...

Re: Delegator

2012-03-03 Thread bioinfornatics
Le samedi 03 mars 2012 à 17:42 +0100, bioinfornatics a écrit : hi, In ruby we can delegate some method. by example: Ruby class MineArray include Forwardable def_delegators: @array, :[], :[]=, :each_with_index, :length def initialize( array ) @array = array end end

Re: Build error about LockingTextWriter

2012-03-03 Thread bioinfornatics
Le samedi 03 mars 2012 à 07:38 -0800, Ali Çehreli a écrit : On 03/03/2012 06:11 AM, bioinfornatics wrote: Dear, i do not understand what is wrong in my code and produce this: - $ ldc2 ../../lib/libdscience-ldc.a -I=../.. fasta.d

Re: typeof(string.front) should be char

2012-03-03 Thread Timon Gehr
On 03/03/2012 09:40 AM, Jonathan M Davis wrote: ... but operating on code points is _far_ more correct than operating on code units. It's also more efficient. [snip.] No, it is less efficient.

Re: Sending Tid in a struct

2012-03-03 Thread Timon Gehr
On 03/03/2012 12:09 PM, Nicolas Silva wrote: Hi, I'm trying to send structs using std.concurrency. the struct contains a Tid (the id of the sender) so that the receiver can send an answer. say: struct Foo { Tid tid; string str; } // ... Foo f = { tid: thisTid, str: hello! };

cluster computing

2012-03-03 Thread dsmith
Any suggestions for using std.parallelism (like MPI for C/C++) for server clusters? Alternatively, how might I use MPI with D?

Re: typeof(string.front) should be char

2012-03-03 Thread Jacob Carlborg
On 2012-03-03 15:10, Ali Çehreli wrote: On 03/03/2012 04:36 AM, Jacob Carlborg wrote: On 2012-03-03 03:30, Piotr Szturmaj wrote: Hello, For this code: auto c = testc; auto w = testw; auto d = testd; pragma(msg, typeof(c.front)); pragma(msg, typeof(w.front)); pragma(msg, typeof(d.front));

Re: Delegator

2012-03-03 Thread Jacob Carlborg
On 2012-03-03 17:50, bioinfornatics wrote: Le samedi 03 mars 2012 à 17:42 +0100, bioinfornatics a écrit : hi, In ruby we can delegate some method. by example: Ruby class MineArray include Forwardable def_delegators: @array, :[], :[]=, :each_with_index, :length def

Re: Delegator

2012-03-03 Thread bioinfornatics
Le samedi 03 mars 2012 à 19:18 +0100, Jacob Carlborg a écrit : On 2012-03-03 17:50, bioinfornatics wrote: Le samedi 03 mars 2012 à 17:42 +0100, bioinfornatics a écrit : hi, In ruby we can delegate some method. by example: Ruby class MineArray include Forwardable

Re: Delegator

2012-03-03 Thread Adam D. Ruppe
On Saturday, 3 March 2012 at 16:50:45 UTC, bioinfornatics wrote: can w do same in D ? alias this does that, although it does for all unknown methods, not specific ones: struct A { int[] data; alias data this; } A a; a[0] = 10; // this works like a.data[0] = 10; alias this also lets

Re: Delegator

2012-03-03 Thread bioinfornatics
Le samedi 03 mars 2012 à 19:45 +0100, Adam D. Ruppe a écrit : On Saturday, 3 March 2012 at 16:50:45 UTC, bioinfornatics wrote: can w do same in D ? alias this does that, although it does for all unknown methods, not specific ones: struct A { int[] data; alias data this; } A

Re: Delegator

2012-03-03 Thread bioinfornatics
Le samedi 03 mars 2012 à 19:18 +0100, Jacob Carlborg a écrit : On 2012-03-03 17:50, bioinfornatics wrote: Le samedi 03 mars 2012 à 17:42 +0100, bioinfornatics a écrit : hi, In ruby we can delegate some method. by example: Ruby class MineArray include Forwardable

Re: Evaluating __FILE__ and __LINE__ of caller?

2012-03-03 Thread Jonathan M Davis
On Saturday, March 03, 2012 13:21:05 bioinfornatics wrote: Le samedi 03 mars 2012 à 02:39 +0100, Adam D. Ruppe a écrit : On Saturday, 3 March 2012 at 01:36:51 UTC, H. S. Teoh wrote: int opIndex(int x) { Make that (int x, string file = __FILE__, int line = __LINE__)

Re: typeof(string.front) should be char

2012-03-03 Thread Jonathan M Davis
On Saturday, March 03, 2012 18:38:44 Timon Gehr wrote: On 03/03/2012 09:40 AM, Jonathan M Davis wrote: ... but operating on code points is _far_ more correct than operating on code units. It's also more efficient. [snip.] No, it is less efficient. Operating on code points is more

Re: typeof(string.front) should be char

2012-03-03 Thread Jonathan M Davis
On Saturday, March 03, 2012 14:57:59 Piotr Szturmaj wrote: This discrepancy pushes the range writer to handle special string cases. Yes it does. And there's _no_ way around that if you want to handle unicode both correctly and efficiently. To handle it correctly, you must operate on code

Re: typeof(string.front) should be char

2012-03-03 Thread Timon Gehr
On 03/03/2012 08:46 PM, Jonathan M Davis wrote: On Saturday, March 03, 2012 18:38:44 Timon Gehr wrote: On 03/03/2012 09:40 AM, Jonathan M Davis wrote: ... but operating on code points is _far_ more correct than operating on code units. It's also more efficient. [snip.] No, it is less

Problem when building LDC

2012-03-03 Thread a
When I try to build LDC on Debian Squeeze I get the following error when running cmake: CMake Error at /usr/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:70 (MESSAGE): REQUIRED_VARS (missing: VERSION_VAR) Does anyone here know what VERSION_VAR is and what should I set it

Re: Evaluating __FILE__ and __LINE__ of caller?

2012-03-03 Thread H. S. Teoh
On Sat, Mar 03, 2012 at 03:52:55PM +0100, Andrej Mitrovic wrote: On 3/3/12, bioinfornatics bioinfornat...@fedoraproject.org wrote: I think __LINE__ is size_t not int I'd love to see a 2_147_483_648 line source file! :D It *could* happen if the source file was auto-generated... and the

Re: Build error about LockingTextWriter

2012-03-03 Thread Ali Çehreli
On 03/03/2012 09:00 AM, bioinfornatics wrote: Le samedi 03 mars 2012 à 07:38 -0800, Ali Çehreli a écrit : On 03/03/2012 06:11 AM, bioinfornatics wrote: Dear, i do not understand what is wrong in my code and produce this: - $ ldc2

Re: typeof(string.front) should be char

2012-03-03 Thread H. S. Teoh
On Sat, Mar 03, 2012 at 12:42:53PM -0800, Jonathan M Davis wrote: [...] The current solution encourages correct usage (or at least usage which is closer to correct, since it still isn't at the grapheme level) without disallowing more optimized code. [...] Speaking of graphemes, is anyone

Re: typeof(string.front) should be char

2012-03-03 Thread H. S. Teoh
On Sat, Mar 03, 2012 at 11:53:41AM -0800, Jonathan M Davis wrote: [...] If you want to iterate by char, then use foreach or use a wrapper range (or cast to ubyte[] and operate on that). Or use: string str = ...; for (size_t i=0; i str.length; i++) { /* do

Re: typeof(string.front) should be char

2012-03-03 Thread Ali Çehreli
On 03/03/2012 01:42 PM, H. S. Teoh wrote: On Sat, Mar 03, 2012 at 12:42:53PM -0800, Jonathan M Davis wrote: [...] The current solution encourages correct usage (or at least usage which is closer to correct, since it still isn't at the grapheme level) without disallowing more optimized code.

Re: Evaluating __FILE__ and __LINE__ of caller?

2012-03-03 Thread Andrej Mitrovic
On 3/3/12, H. S. Teoh hst...@quickfur.ath.cx wrote: Of course, with D's templates, CTFE, and compile-time introspection capabilities, I can't imagine when autogeneration would actually be required, but we're talking about hypotheticals here. It can be if you need an OOP D binding to a C/C++

Re: Delegator

2012-03-03 Thread bioinfornatics
Le samedi 03 mars 2012 à 19:18 +0100, Jacob Carlborg a écrit : On 2012-03-03 17:50, bioinfornatics wrote: Le samedi 03 mars 2012 à 17:42 +0100, bioinfornatics a écrit : hi, In ruby we can delegate some method. by example: Ruby class MineArray include Forwardable

How to avoid code duplication in static if branches?

2012-03-03 Thread Andrej Mitrovic
import std.stdio; void check() { writeln(check); } struct Foo { bool isTrue = true; } struct Bar { } void test(T)(T t) { static if (is(T == Foo)) { if (t.isTrue) check(); } else { check(); } } void main() { Foo foo; Bar bar;

Re: typeof(string.front) should be char

2012-03-03 Thread Jonathan M Davis
On Saturday, March 03, 2012 13:46:16 Ali Çehreli wrote: On 03/03/2012 01:42 PM, H. S. Teoh wrote: On Sat, Mar 03, 2012 at 12:42:53PM -0800, Jonathan M Davis wrote: [...] The current solution encourages correct usage (or at least usage which is closer to correct, since it still isn't at

[SUCCESS] delegator

2012-03-03 Thread bioinfornatics
dear, I have a little code who is able to delegate to an array see below code: https://gist.github.com/1969776 It should realy great to have same into std.array and into std.range (for reach different range )

Re: typeof(string.front) should be char

2012-03-03 Thread Jonathan M Davis
On Saturday, March 03, 2012 13:46:16 Ali Çehreli wrote: On 03/03/2012 01:42 PM, H. S. Teoh wrote: On Sat, Mar 03, 2012 at 12:42:53PM -0800, Jonathan M Davis wrote: [...] The current solution encourages correct usage (or at least usage which is closer to correct, since it still isn't at

Re: How to avoid code duplication in static if branches?

2012-03-03 Thread Mantis
04.03.2012 3:42, Andrej Mitrovic пишет: [...code...] I want to avoid writing check() twice. I only have to statically check a field of a member if it's of a certain type (Foo). One solution would be to use a boolean: void test(T)(T t) { bool isTrue = true; static if (is(T == Foo))

Re: Evaluating __FILE__ and __LINE__ of caller?

2012-03-03 Thread Andrej Mitrovic
Ok, well a quick search shows socket.d:132 needs fixing. Also there's two versioned out enforces in object_.d which use int line = __LINE__. Interestingly, earlier versions of Phobos used int a lot (I guess in pre-64bit compatible D days). I'm also seeing int used in Derelict, pspemu, plot2kill

Re: Evaluating __FILE__ and __LINE__ of caller?

2012-03-03 Thread Jonathan M Davis
On Sunday, March 04, 2012 03:38:03 Andrej Mitrovic wrote: Ok, well a quick search shows socket.d:132 needs fixing. Also there's two versioned out enforces in object_.d which use int line = __LINE__. Interestingly, earlier versions of Phobos used int a lot (I guess in pre-64bit compatible D

Re: How to avoid code duplication in static if branches?

2012-03-03 Thread Daniel Murphy
Andrej Mitrovic andrej.mitrov...@gmail.com wrote in message news:mailman.364.1330825349.24984.digitalmars-d-le...@puremagic.com... import std.stdio; void check() { writeln(check); } struct Foo { bool isTrue = true; } struct Bar { } void test(T)(T t) { static if (is(T == Foo)) {

Re: How to avoid code duplication in static if branches?

2012-03-03 Thread Andrej Mitrovic
You're right it should be able do that dead-code elimination thing. Slipped my mind. :) On 3/4/12, Daniel Murphy yebbl...@nospamgmail.com wrote: Andrej Mitrovic andrej.mitrov...@gmail.com wrote in message news:mailman.364.1330825349.24984.digitalmars-d-le...@puremagic.com... import std.stdio;

Re: How to avoid code duplication in static if branches?

2012-03-03 Thread Jérôme M. Berger
Andrej Mitrovic wrote: ...snip... I want to avoid writing check() twice. I only have to statically check a field of a member if it's of a certain type (Foo). One solution would be to use a boolean: void test(T)(T t) { bool isTrue = true; static if (is(T == Foo)) isTrue =