Re: Confused by refusal to expand template

2012-03-23 Thread Timon Gehr
On 03/23/2012 11:52 PM, H. S. Teoh wrote: Code: struct S { int f(K)(K x) { return 1; } void func(K)(inout(K) x) { auto h = f(x); } } void main() {

Re: Confused by refusal to expand template

2012-03-23 Thread Timon Gehr
On 03/23/2012 11:58 PM, David wrote: Am 23.03.2012 23:52, schrieb H. S. Teoh: Code: struct S { int f(K)(K x) { return 1; } void func(K)(inout(K) x) { auto h = f(x); } } void main() { S s; s.func(abc); // This is line 44 } This refuses to compile: test2.d(44): Error: template test2.S.func(K)

Re: Converting C .h Files to D Modules

2012-03-21 Thread Timon Gehr
On 03/20/2012 07:01 PM, Pedro Lacerda wrote: Hi all, How to convert the following struct to D? typedef struct S { int type; void *obj; } S; I didn't found anything at http://dlang.org/htomodule.html. (Assuming your 'int' is 32 bits) struct S{ int type; void* obj; }

Re: Calculating/Averaging over a struct value

2012-03-21 Thread Timon Gehr
#! /usr/bin/rdmd import std.array; import std.csv; import std.stdio; import std.string; struct Data{ string Date; double d1; double d2; int i4; } double average(Data[] x, string para){ double result = 0.0; theswitch:switch(strip(para)){

Re: Simple operator precidence chart (and associativity)?

2012-03-14 Thread Timon Gehr
On 03/14/2012 01:20 AM, Nick Sabalausky wrote: Timon Gehrtimon.g...@gmx.ch wrote in message // 8 shift operators == !=== \ // 9 relational operators ! ! != !=\ ! = != in \ !in is !is // 10 bitwise AND (ambiguous with 9) ^ // 11 bitwise XOR

Re: Simple operator precidence chart (and associativity)?

2012-03-14 Thread Timon Gehr
On 03/14/2012 01:23 PM, Jos van Uden wrote: On 14-3-2012 0:14, Timon Gehr wrote: I don't think there is, but I think I can create one: ! // 1 template instantiation = // 2 goesto, binds weaker to the right . ++ -- ( [ // 3 postfix operators ^^ // 4 power (right-associative

Re: Simple operator precidence chart (and associativity)?

2012-03-13 Thread Timon Gehr
On 03/13/2012 11:29 PM, Nick Sabalausky wrote: I'm reading through D's grammar spec, and maybe it's just not enough sleep or some such, but my brain is turning to mud: Is there a simple operator precidence chart somewhere? I don't think there is, but I think I can create one: !

Re: inout/const issue: assignments to field not allowed if field initializer present

2012-03-11 Thread Timon Gehr
On 03/11/2012 02:46 AM, Andrej Mitrovic wrote: It took me a while to narrow this down: struct Foo { int val = int.init; this(inout(int) nval) inout { this.val = nval; } } test.d(18): Error: cannot modify const/immutable/inout expression this.val Is there any special

Re: Frustrations with const

2012-03-09 Thread Timon Gehr
On 03/08/2012 09:06 PM, H. S. Teoh wrote: On Thu, Mar 08, 2012 at 02:50:50PM -0500, Steven Schveighoffer wrote: On Thu, 08 Mar 2012 14:49:12 -0500, H. S. Teoh hst...@quickfur.ath.cx wrote: On Thu, Mar 08, 2012 at 08:22:05PM +0100, Timon Gehr wrote: [...] inout(Slot)* findSlot(Key key

Re: Can I do an or in a version block?

2012-03-09 Thread Timon Gehr
On 03/09/2012 02:25 AM, Ary Manzana wrote: On 3/8/12 6:11 PM, H. S. Teoh wrote: On Thu, Mar 08, 2012 at 05:56:09PM -0300, Ary Manzana wrote: [...] I don't think it would be hard to implement boolean logic inside version. It's not hard at all. Would it make sense if I make a pull request

Re: matrix and fibonacci

2012-03-09 Thread Timon Gehr
On 03/09/2012 06:50 AM, newcomer[bob] wrote: The following is a matrix implementation of the fibonacci algorithm: int fib(int n) { int M[2][2] = {{1,0},{0,1}} for (int i = 1; i n; i++) M = M * {{1,1},{1,0}} return M[0][0]; } problem is I don't really understand how matrix multiplication works

Re: Assert and the optional Message

2012-03-09 Thread Timon Gehr
On 03/09/2012 01:20 PM, Jacob Carlborg wrote: On 2012-03-09 12:12, Jonathan M Davis wrote: On Friday, March 09, 2012 11:03:38 Regan Heath wrote: On Fri, 09 Mar 2012 08:20:33 -, Chris Ponscmp...@gmail.com wrote: Any idea why, system(PAUSE) does work? As Jonathan says, assert throws

Re: Assert and the optional Message

2012-03-09 Thread Timon Gehr
On 03/09/2012 03:24 PM, Jacob Carlborg wrote: On 2012-03-09 15:13, Timon Gehr wrote: On 03/09/2012 01:20 PM, Jacob Carlborg wrote: On 2012-03-09 12:12, Jonathan M Davis wrote: On Friday, March 09, 2012 11:03:38 Regan Heath wrote: On Fri, 09 Mar 2012 08:20:33 -, Chris Ponscmp...@gmail.com

Re: Method invocation -- why it's not working?

2012-03-09 Thread Timon Gehr
On 03/09/2012 07:08 PM, Andrej Mitrovic wrote: Yeah I understood it as a general concept as well. Probably many people did. Why doesn't Andrei chime in? I think he does not read the D.learn newsgroup.

Re: Assert and the optional Message

2012-03-09 Thread Timon Gehr
On 03/09/2012 07:37 PM, H. S. Teoh wrote: On Fri, Mar 09, 2012 at 07:23:20PM +0100, Timon Gehr wrote: On 03/09/2012 05:56 PM, Jonathan M Davis wrote: [...] It was never intended that AssertError or any other Error be particularly catchable, but it's also true that D is a systems programming

Re: Assert and the optional Message

2012-03-09 Thread Timon Gehr
On 03/09/2012 10:43 PM, Jonathan M Davis wrote: ... Jonathan is just speculating. And I think he is wrong. Speculating about what? - Jonathan M Davis About how assertion failures affect struct destructors, finally statements and scope statements. If they wouldn't be executed upon thrown

Re: 0 negative loop condition bug or misunderstanding on my part

2012-03-08 Thread Timon Gehr
On 03/08/2012 03:39 AM, Ary Manzana wrote: On 3/7/12 2:28 AM, Ali Çehreli wrote: On 03/06/2012 09:11 PM, ixid wrote: I'm writing my first basic algorithms, this one is merge sort. This version throws an exception when array.length - setSize is negative (which should be fine, the rest of my

Re: Frustrations with const

2012-03-08 Thread Timon Gehr
On 03/08/2012 08:09 PM, H. S. Teoh wrote: I'm writing an AA implementation, and ran into this problem with the way const behaves in D. Basically, I have an auxiliary function that searches the internal hash table for a given key, and returns the slot containing the matching entry, if found. The

Re: Frustrations with const

2012-03-08 Thread Timon Gehr
On 03/08/2012 08:49 PM, H. S. Teoh wrote: On Thu, Mar 08, 2012 at 08:22:05PM +0100, Timon Gehr wrote: On 03/08/2012 08:09 PM, H. S. Teoh wrote: [...] The problem is, how to write this function so that it can be called from *both* a const public method and a non-const public method? Since

Re: 0 negative loop condition bug or misunderstanding on my part

2012-03-07 Thread Timon Gehr
On 03/07/2012 07:05 AM, ixid wrote: Ah, thank you, so it's wrapping. That seems like a bad idea, what is the benefit to size being unsigned rather than signed? This case would seem like one where allowing negatives is clearly better and more intuitive. The problem is not that length is

Re: 0 negative loop condition bug or misunderstanding on my part

2012-03-07 Thread Timon Gehr
On 03/07/2012 11:01 AM, Timon Gehr wrote: On 03/07/2012 07:05 AM, ixid wrote: Ah, thank you, so it's wrapping. That seems like a bad idea, what is the benefit to size being unsigned rather than signed? This case would seem like one where allowing negatives is clearly better and more intuitive

Re: Why is std.algorithm.reduce impure?

2012-03-07 Thread Timon Gehr
On 03/07/2012 05:29 PM, Simen Kjærås wrote: On Wed, 07 Mar 2012 01:41:22 +0100, Jonathan M Davis jmdavisp...@gmx.com wrote: It really takes very little for something to be impure, and optimizations often do it, because they end up using low-level constructs which aren't pure - some of which

Re: D RTTI?

2012-03-06 Thread Timon Gehr
On 03/06/2012 01:51 AM, Artur Skawina wrote: ... Real programmers don't use mixins, :^) You got it reverse.

Re: D RTTI?

2012-03-06 Thread Timon Gehr
On 03/06/2012 08:37 PM, H. S. Teoh wrote: On Tue, Mar 06, 2012 at 01:51:51AM +0100, Artur Skawina wrote: [...] class A { string prop1; int prop2; void serialize(this THIS)() { __serialize(cast(THIS*)this); } } void __serialize(T)(T* obj) { writef(%s {\n,

Re: D RTTI?

2012-03-05 Thread Timon Gehr
On 03/05/2012 11:33 PM, H. S. Teoh wrote: On Mon, Mar 05, 2012 at 08:41:53PM +, Justin Whear wrote: On Mon, 05 Mar 2012 12:16:14 -0800, H. S. Teoh wrote: I know D doesn't really have RTTI yet, but I'm experimenting with faking it by doing something like: class A {

Re: abstract base class and class members

2012-03-04 Thread Timon Gehr
On 03/04/2012 06:16 PM, David wrote: Is this intended behaviour? http://ideone.com/xrvvL shouldn't the 2nd writeln print the same as the first, well at least the same content of i? This is intended behaviour. You have two distinct definitions of i. If you want to set i to 2 in the derived

Re: abstract base class and class members

2012-03-04 Thread Timon Gehr
On 03/04/2012 07:22 PM, H. S. Teoh wrote: Makes one wonder, though... from an OO perspective, does it make sense to have overridable non-function members? What semantics would (should) that have? Yes, it does make sense. const/immutable/(final) fields can be covariant. OTOH, it is not

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! };

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

Re: Using lazily ?

2012-03-02 Thread Timon Gehr
On 03/02/2012 12:12 AM, bearophile wrote: Ali: Note that Timon's inner foreach is a compile-time foreach, which is the equivalent of the following three lines: I'd like it to be written: static foreach (...) {... In the meantime an annotation helps clarify the code for the person that will

Re: Regarding std.array.Appender

2012-03-01 Thread Timon Gehr
On 03/01/2012 03:40 AM, Jonathan M Davis wrote: On Wednesday, February 29, 2012 21:23:54 bearophile wrote: Jonathan M Davis: put is a function on output ranges, and Appender is an output range. Also, given that it doesn't define ~ (and it wouldn't really make sense for it to), it would be

Re: Using lazily ?

2012-03-01 Thread Timon Gehr
On 03/01/2012 10:50 PM, bioinfornatics wrote: dear, Noob question for know if D provide a shorter way i explain we have a struct S: struct S{ string member1; string member2; string member3; } we parse a file: File f = File(a path, r); S s; sise_t tokenLength =

Re: Reflection

2012-02-28 Thread Timon Gehr
On 02/28/2012 07:27 AM, Joshua Niehus wrote: On Tuesday, 28 February 2012 at 06:10:11 UTC, Jesse Phillips wrote: It is a template. I see, thanks. And I bet its not possible to figure out if a template is a function template or a class template etc... You can trivially test whether the

Re: struct init() method

2012-02-26 Thread Timon Gehr
On 02/26/2012 12:18 AM, Jonathan M Davis wrote: On Saturday, February 25, 2012 17:07:14 Timon Gehr wrote: This is useful: struct S{ @disable enum init = 0; } I thought that the way that you were supposed to do that was @disable this(); - Jonathan M Davis struct S{@disable

Re: A very strange bug. DMD 2.058 64-bit Linux

2012-02-26 Thread Timon Gehr
On 02/26/2012 09:06 PM, Caligo wrote: Once you have those two files, compile with this: dmd -unittest t1.d bug.d and then run t1: ./t1 The output you get should look like this: ... [0, 4, 0, 0, 0, 0, 0, 2, 0, 0, 1, 2, 0, 1, 0, 0] I get: ... [0, 4, 0, 0, 0, 0, 0, 2, 0, 0, 1, 2, 0, 1, 0,

Re: delegate as memeber

2012-02-25 Thread Timon Gehr
On 02/25/2012 03:32 PM, Stewart Gordon wrote: On 21/02/2012 17:46, Jacob Carlborg wrote: On 2012-02-21 16:55, deadalnix wrote: snip You can implement a static opCall and use that instead of the constructor. But you don't have to call a static opCall. You can just declare a struct instance

Re: Template Inheritance

2012-02-25 Thread Timon Gehr
On 02/22/2012 01:13 AM, BLM wrote: That last one looks a lot better than my solution. It's certainly a lot clearer. One problem I discovered with using templates was that I ended up needing virtual functions, which means that I had to convert the template functions to mixins and just

Re: struct init() method

2012-02-25 Thread Timon Gehr
On 02/25/2012 04:52 PM, H. S. Teoh wrote: On Sat, Feb 25, 2012 at 01:23:21PM +0100, Alex Rønne Petersen wrote: On 25-02-2012 05:05, bearophile wrote: This program comes from a reduction of a bug I've found: struct Foo { void init() {} } void main() { Foo*[] foos;

Re: Write struct to file

2012-02-25 Thread Timon Gehr
On 02/25/2012 07:03 PM, Chopin wrote: Hello! import std.stdio; struct nagger { string name; int age; double weight; string msg; } void main() { auto lal = new nagger(); lal.name = AHAHAHAHHA; lal.age = 23; lal.weight = 108.5; lal.msg = fgfdgfdgfdgfdgfdgfdg; writeln(cast(ubyte[])(lal)); }

Re: Write struct to file

2012-02-25 Thread Timon Gehr
On 02/25/2012 07:15 PM, Timon Gehr wrote: On 02/25/2012 07:03 PM, Chopin wrote: Hello! import std.stdio; struct nagger { string name; int age; double weight; string msg; } void main() { auto lal = new nagger(); lal.name = AHAHAHAHHA; lal.age = 23; lal.weight = 108.5; lal.msg

Re: inout problems

2012-02-22 Thread Timon Gehr
On 02/22/2012 05:01 AM, Andrej Mitrovic wrote: class Foo { this(int) inout { } Foo makeFoo() { return new Foo(1); } } void main() { } test.d(8): Error: cannot implicitly convert expression (new Foo(1)) of type inout(Foo) to test.Foo Is this a bug? Yes. See

Re: Avoiding const?

2012-02-22 Thread Timon Gehr
On 02/22/2012 02:13 AM, ixid wrote: I apologize for what I'm sure is a very basic question. How should I do this elegantly? bool set[char[]]; Use bool set[string]. You cannot index an AA with a mutable array. The declaration you give will be rejected by the compiler soon. //Stuff

Re: inout problems

2012-02-22 Thread Timon Gehr
On 02/22/2012 01:22 PM, deadalnix wrote: Le 22/02/2012 05:01, Andrej Mitrovic a écrit : class Foo { this(int) inout { } Foo makeFoo() { return new Foo(1); } } void main() { } test.d(8): Error: cannot implicitly convert expression (new Foo(1)) of type inout(Foo) to test.Foo Is this a bug?

Re: delegate as memeber

2012-02-22 Thread Timon Gehr
On 02/21/2012 04:24 PM, deadalnix wrote: struct stuff { private Exception delegate() exceptionBuilder = delegate Exception() { return new Exception(foobar); }; } The following piece of code trigger a compiler error : delegate module.stuff.__dgliteral1 function literals cannot be class members

Re: Everything on the Stack

2012-02-21 Thread Timon Gehr
On 02/21/2012 11:27 AM, Daniel Murphy wrote: scope/scoped isn't broken, they're just not safe. It's better to have an unsafe library feature than an unsafe language feature. scope is broken because it is not enforced by the means of flow-analysis. As a result, it is not safe. Copying it to

Re: A inner pure function problem

2012-02-20 Thread Timon Gehr
On 02/20/2012 02:26 PM, bearophile wrote: This code looks interesting (maybe this code is also able to spot a bug in DMD, or it is able to show something I have not fully understood in D). Do you know if there are interesting ways to compile it? T outer(T)(T function(in T) pure foo) pure {

Re: Template Inheritance

2012-02-18 Thread Timon Gehr
On 02/19/2012 01:55 AM, %u wrote: I've been working on porting an old D library to D2, and I'm running into a nasty issue with templates and inheritance. I've got a base class like this: class Reader { void get(T)(ref T[] buffer); } and a subclass like this: class SubReader { void

Re: Let this() figure out T implicitly?

2012-02-17 Thread Timon Gehr
On 02/17/2012 02:07 PM, Kevin Cox wrote: Yes. At least as the compiler would say. It's a little odd but I believe that is how the D Nam mangling works. I personally just think of Foo!(Class) as the type. class Foo(T){ ... } Is syntactic sugar for template Foo(T){ class Foo{ ... } }

Re: Hex floats

2012-02-17 Thread Timon Gehr
On 02/17/2012 10:45 AM, Don Clugston wrote: On 16/02/12 17:36, Timon Gehr wrote: On 02/16/2012 05:06 PM, Don Clugston wrote: On 16/02/12 13:28, Stewart Gordon wrote: On 16/02/2012 12:04, Don Clugston wrote: On 15/02/12 22:24, H. S. Teoh wrote: What's the original rationale for requiring

Re: writeln(Range) fails on 2.058

2012-02-17 Thread Timon Gehr
On 02/17/2012 12:58 PM, simendsjo wrote: On Fri, 17 Feb 2012 12:51:11 +0100, simendsjo simend...@gmail.com wrote: On Wed, 15 Feb 2012 11:10:45 +0100, simendsjo simend...@gmail.com wrote: On 02/15/2012 09:33 AM, simendsjo wrote: import std.array; import std.stdio; struct S { string txt;

Re: Let this() figure out T implicitly?

2012-02-17 Thread Timon Gehr
On 02/18/2012 12:04 AM, Ali Çehreli wrote: On 02/17/2012 09:08 AM, Steven Schveighoffer wrote: What you are asking for is IFTI (Implicit Function Template Instantiation) on constructors, and is perfectly possible, but not implemented: http://d.puremagic.com/issues/show_bug.cgi?id=6082

Re: Let this() figure out T implicitly?

2012-02-17 Thread Timon Gehr
On 02/18/2012 03:22 AM, Ali Çehreli wrote: On 02/17/2012 05:59 PM, Timon Gehr wrote: On 02/18/2012 12:04 AM, Ali Çehreli wrote: On 02/17/2012 09:08 AM, Steven Schveighoffer wrote: What you are asking for is IFTI (Implicit Function Template Instantiation) on constructors

Re: Hex floats

2012-02-16 Thread Timon Gehr
On 02/16/2012 05:06 PM, Don Clugston wrote: On 16/02/12 13:28, Stewart Gordon wrote: On 16/02/2012 12:04, Don Clugston wrote: On 15/02/12 22:24, H. S. Teoh wrote: What's the original rationale for requiring that hex float literals must always have an exponent? For example, 0xFFi obviously

Re: Hex floats

2012-02-16 Thread Timon Gehr
On 02/16/2012 08:36 PM, H. S. Teoh wrote: More questions about hex floats. So we've established that hex floats have decimal exponents. So how should the following be tokenized? 0x1p1E8 Should it be tokenized as (Float: 0x1p1)(Identifier: E8), or should it be an error? T It should

Re: More octal questions

2012-02-15 Thread Timon Gehr
On 02/15/2012 09:30 AM, Andrej Mitrovic wrote: Where do you see those literals? I'm only seeing strings. Line 8322: _assertPred!==(SysTime.fromISOString(20101222T172201), SysTime(DateTime(2010, 12, 22, 17, 22, 01)));

Re: Anti-OOP... stupid?

2012-02-15 Thread Timon Gehr
On 02/15/2012 03:30 PM, foobar wrote: ... 1. D templates are an enhanced version of C++ templates which are a poor design. The problem stems IMO not from issues with OOP but rather with the horrible idea of C++-like templates. Other languages have *much* better solutions which integrate better.

Re: Const module globals and static this()

2012-02-15 Thread Timon Gehr
On 02/15/2012 07:29 PM, H. S. Teoh wrote: Why doesn't this compile? const int map[dstring]; static this() { map[abc] = 123; } It seems utterly pointless to be able to declare a const associative array yet be unable to initialize it (trying to initialize

Re: Anti-OOP... stupid?

2012-02-15 Thread Timon Gehr
On 02/15/2012 09:17 PM, foobar wrote: On Wednesday, 15 February 2012 at 15:35:53 UTC, Timon Gehr wrote: On 02/15/2012 03:30 PM, foobar wrote: ... 1. D templates are an enhanced version of C++ templates which are a poor design. The problem stems IMO not from issues with OOP but rather

Re: More octal questions

2012-02-14 Thread Timon Gehr
lexer accept them? T Yes. On 02/11/2012 05:37 PM, Timon Gehr wrote: Octal literals whose value is larger than 7 must be rejected. Octal literals with values up to 7 must be accepted.

Re: Anti-OOP... stupid?

2012-02-14 Thread Timon Gehr
On 02/14/2012 11:06 PM, deadalnix wrote: IMO, what would be stupid is that everything has to be object oriented. You have problems where OOP is good, and other where it isn't. Use the tool that fit what you want to accomplish. Screwdriver are great, but are useless when you are dealing with a

Re: Anti-OOP... stupid?

2012-02-14 Thread Timon Gehr
On 02/14/2012 11:00 PM, Zero wrote: Hello! I've recently started to work with D, and I'll start a bigger project soon, using it. For a few days I've been thinking about the approach I'll take here, and since I don't /have/ to use full OOP in D, I was wondering... how crazy is it to not use full

Re: Anti-OOP... stupid?

2012-02-14 Thread Timon Gehr
On 02/15/2012 12:12 AM, H. S. Teoh wrote: On Tue, Feb 14, 2012 at 11:47:52PM +0100, Timon Gehr wrote: [...] It does not hurt at all if your code base is more flexible than necessary. [...] This needs to be taken in moderation, though. I've had to work with code that was unnecessarily

Re: Delimited strings

2012-02-14 Thread Timon Gehr
On 02/15/2012 01:38 AM, H. S. Teoh wrote: I've finally got my lexer to the point where it can successfully tokenize /usr/include/d2/4.3.2/std/*.d. Yay! :-) Now I'm going back to fill in the gaps that still haven't been implemented yet. Among which are delimited strings. According to the online

Re: Delimited strings

2012-02-14 Thread Timon Gehr
On 02/15/2012 02:03 AM, H. S. Teoh wrote: On Wed, Feb 15, 2012 at 01:46:51AM +0100, Timon Gehr wrote: [...] No, qabca is illegal. The pattern is qidentifier string identifier (The terminating new line is kept, so the string in this case is string\n) I see. The online specs need

Re: Arrays - Inserting and moving data

2012-02-13 Thread Timon Gehr
On 02/13/2012 03:19 PM, James Miller wrote: On 11 February 2012 10:45, Jonathan M Davisjmdavisp...@gmx.com wrote: On Friday, February 10, 2012 13:32:56 Marco Leise wrote: I know that feeling. I had no exposure to functional programming and options like chain never come to my head. Although

Re: Stride

2012-02-13 Thread Timon Gehr
On 02/13/2012 11:27 PM, Artur Skawina wrote: On 02/13/12 22:58, Jonathan M Davis wrote: On Monday, February 13, 2012 22:24:38 Artur Skawina wrote: The important thing here is - the order absolutely *must* be foo(), then bar(), what happens under the hood is completely irrelevant. The reason is

Re: Arrays - Inserting and moving data

2012-02-13 Thread Timon Gehr
On 02/14/2012 12:34 AM, James Miller wrote: On 14 February 2012 06:25, Timon Gehrtimon.g...@gmx.ch wrote: On 02/13/2012 03:19 PM, James Miller wrote: On 11 February 2012 10:45, Jonathan M Davisjmdavisp...@gmx.comwrote: On Friday, February 10, 2012 13:32:56 Marco Leise wrote: I know

Re: dmd thrashes fedora

2012-02-12 Thread Timon Gehr
On 02/10/2012 08:38 PM, Ellery Newcomer wrote: when I run dmd -gc -oftopo topo.d multi_index.d replace.d on the contents of http://personal.utulsa.edu/~ellery-newcomer/bad.zip in fedora 16 x86_64 with dmd 2.057 64 bit dmd starts thrashing like there is no tomorrow and generally locks up my

Re: Object.factory failed with nested class

2012-02-12 Thread Timon Gehr
On 02/13/2012 12:15 AM, Eyyub wrote: Hi all, I'd like to know, why Object.factory(classname) failed with nested class ? Source code : http://paste.pocoo.org/show/N6BJPMbGn2vVtJo649BJ/ . Thanks in advance, In theory it could work for only static local classes, but that does not work too. It

Re: toString multiple overrides

2012-02-11 Thread Timon Gehr
On 02/11/2012 08:48 AM, Jonathan M Davis wrote: On Friday, February 10, 2012 22:41:20 Ellery Newcomer wrote: dmd 2.057 Two mixin templates, each define toString, mix them in to your class and .. Error: function test.X.T2!().toString multiple overrides of same function So this behavior is

Re: dmd thrashes fedora

2012-02-11 Thread Timon Gehr
On 02/11/2012 02:29 PM, Manfred Nowak wrote: Ellery Newcomer wrote: Can anyone confirm this behavior? The behavior has nothing to do with fedora, because I can confirm it for win32. It seems to be rooted in an infinite loop of memory allocations. Is this the first time of a report that an

Re: dmd thrashes fedora

2012-02-11 Thread Timon Gehr
On 02/11/2012 05:19 PM, Manfred Nowak wrote: Timon Gehr wrote: This would make it a Phobos bug. Not necassarily. You didn't quote everything that is relevant: Timon Gehr wrote: Probably not, but the error message suggests the problem might be in std.functional. This would make

Re: Signature conditions

2012-02-10 Thread Timon Gehr
On 02/10/2012 07:50 PM, H. S. Teoh wrote: On Fri, Feb 10, 2012 at 07:36:38PM +0100, David Nadlinger wrote: On 2/10/12 7:35 PM, David Nadlinger wrote: class(T) if (__traits(compiles, { std.utf.decode(T.init); } )) { … } (untested, you might have to return the value from the delegate to avoid

Re: dmd thrashes fedora

2012-02-10 Thread Timon Gehr
On 02/10/2012 08:38 PM, Ellery Newcomer wrote: when I run dmd -gc -oftopo topo.d multi_index.d replace.d on the contents of http://personal.utulsa.edu/~ellery-newcomer/bad.zip in fedora 16 x86_64 with dmd 2.057 64 bit dmd starts thrashing like there is no tomorrow and generally locks up my

Re: dmd thrashes fedora

2012-02-10 Thread Timon Gehr
On 02/11/2012 12:16 AM, Ellery Newcomer wrote: On 02/10/2012 01:59 PM, Timon Gehr wrote: I seem to have more RAM than you. The behavior is apparently caused by a Phobos bug: That is likely. The code is a dustmite reduction, so I don't really care what the error is, just that it shouldn't

Re: How to reverse char[]?

2012-02-08 Thread Timon Gehr
On 02/08/2012 03:56 PM, Steven Schveighoffer wrote: On Wed, 08 Feb 2012 04:30:04 -0500, Jos van Uden user@domain.invalid wrote: On 8-2-2012 2:36, Timon Gehr wrote: char[] is handled by Phobos as a range of dchar, ergo it does not have swappable elements. I'm surprised that array.reverse

Re: is this a bug? opUnary!++ Error: var has no effect

2012-02-08 Thread Timon Gehr
On 02/08/2012 10:48 PM, Zach the Mystic wrote: My goal is to be able to overload the ++ operator transparently to the code, but I can't. import std.stdio; struct Arc { int I = 0; // This is void, but the error appears under all return types void opUnary(string op)() if( op == ++ ) { ++I; } }

Re: Conversion to output ranges

2012-02-07 Thread Timon Gehr
On 02/07/2012 02:35 PM, Mafi wrote: Hi, does anybody know how to bring std.conv.to or something similar to output into an output range? int a = 42; char[25] buffer; to!typeof(buffer[])(a, buffer[]); I want to send these texts throw sockets. Therefore I'd like to reuse the buffer. Mafi You

Re: Conversion to output ranges

2012-02-07 Thread Timon Gehr
On 02/07/2012 04:49 PM, Timon Gehr wrote: On 02/07/2012 02:35 PM, Mafi wrote: Hi, does anybody know how to bring std.conv.to or something similar to output into an output range? int a = 42; char[25] buffer; to!typeof(buffer[])(a, buffer[]); I want to send these texts throw sockets. Therefore

Re: Conversion to output ranges

2012-02-07 Thread Timon Gehr
On 02/07/2012 04:50 PM, Timon Gehr wrote: On 02/07/2012 04:49 PM, Timon Gehr wrote: On 02/07/2012 02:35 PM, Mafi wrote: Hi, does anybody know how to bring std.conv.to or something similar to output into an output range? int a = 42; char[25] buffer; to!typeof(buffer[])(a, buffer[]); I want

Re: For: [your code hear]

2012-02-07 Thread Timon Gehr
On 02/07/2012 08:16 PM, Manfred Nowak wrote: Goal: show some skill of D for implementing mathematics. A definition: Let T1, T2, T3 be sets. A problem P of type ( T1, T2, T3) is interpretable as a function from the domain cartesian product of T1 and powerset of T2 to the codomain T3.

Re: post/pre-increment/decrement and property

2012-02-07 Thread Timon Gehr
On 02/07/2012 11:54 PM, Robert Clipsham wrote: 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

Re: How to reverse char[]?

2012-02-07 Thread Timon Gehr
On 02/08/2012 02:29 AM, H. S. Teoh wrote: Hi all, I'm trying to reverse a character array. Why doesn't the following work? import std.algorithm; void main() { char[] array = ['a', 'b', 'c']; reverse(array); } I get: Error: template

Re: Pitfall

2012-02-06 Thread Timon Gehr
On 02/06/2012 08:20 PM, Manfred Nowak wrote: Today I got the nice message Error: undefined identifier missing from DMD2.057/win and was baffled for several minutes until I recognized the meaning. -manfred Single quotes would indeed be helpful.

Re: Mixture of type tuple and expression tuple

2012-02-06 Thread Timon Gehr
On 02/06/2012 11:26 PM, Matthias Walter wrote: Hi, I'd like to have a function foo which shall depend on several compile-time expressions (e.g. strings) and gets several arguments whose types are templatized. Here, several means in both cases that the number of expressions/arguments are to be

Re: Pure Contract bug?

2012-02-04 Thread Timon Gehr
On 02/04/2012 08:51 PM, Era Scarecrow wrote: If I'm reading how pure works, my original example was likely broken as it was part of a struct that returned a state value (although the contract constraints meaning was still valid). So is pure fully usable or is it not yet ready? Makes me think

Re: Contracts vs debug

2012-02-04 Thread Timon Gehr
On 02/04/2012 06:18 PM, F i L wrote: Why/where should I use contracts vs debug statements? Is it completely arbitrary? If so, I wonder if contracts syntax is even needed: int foo(int bar) in { assert(bar != 0); } body { return bar + 1; } The thing I like more about debug statements, is that I

Re: Segment violation (was Re: Why I could not cast string to int?)

2012-02-04 Thread Timon Gehr
On 02/04/2012 06:55 PM, Artur Skawina wrote: On 02/04/12 02:03, Timon Gehr wrote: On 02/03/2012 11:08 AM, Artur Skawina wrote: On 02/03/12 00:20, Jonathan M Davis wrote: in is pointless on value types. All it does is make the function parameter const, which really doesn't do much for you

Re: Pure Contract bug?

2012-02-04 Thread Timon Gehr
On 02/04/2012 11:04 PM, Era Scarecrow wrote: Pure does not imply const in D. If you want stronger guarantees, just turn 'test' into a const (or immutable) member function. In D, a function can change anything that is mutable and reachable through its parameters, this includes the implicit 'this'

Re: Segment violation (was Re: Why I could not cast string to int?)

2012-02-04 Thread Timon Gehr
On 02/04/2012 11:23 PM, Artur Skawina wrote: On 02/04/12 22:20, Timon Gehr wrote: On 02/04/2012 06:55 PM, Artur Skawina wrote: On 02/04/12 02:03, Timon Gehr wrote: On 02/03/2012 11:08 AM, Artur Skawina wrote: On 02/03/12 00:20, Jonathan M Davis wrote: in is pointless on value types. All

Re: Pure Contract bug?

2012-02-04 Thread Timon Gehr
On 02/05/2012 12:15 AM, Era Scarecrow wrote: Probably the restriction was lifted after TDPL was out. Yes. The compiler will only reorder/run in parallel/optimize if it is safe (not changing execution semantics). Pure can be used to prove that certain optimizations are safe. If a pure

Re: Pure Contract bug?

2012-02-04 Thread Timon Gehr
On 02/05/2012 01:20 AM, Era Scarecrow wrote: the signature I meant looks like pure int squaredPlus(int)immutable; Which then the only way you could call it, was if the object itself was immutable, which is definitely safe (I think). Hmmm... Alternatively you can use pure int

Re: How far can CTFE go?

2012-02-03 Thread Timon Gehr
On 02/03/2012 04:26 AM, Manfred Nowak wrote: H. S. Teoh wrote: I don't think that should be grounds to get rid of CTFE, though. In contrast to your remark, I do not see the benefits of reducing two compiling phases to one. For me CTFE ist nothing else than running the executables of a first

Re: How far can CTFE go?

2012-02-03 Thread Timon Gehr
On 02/03/2012 12:22 AM, H. S. Teoh wrote: I'm experimenting with pluggable expression parser modules, and I'm wondering if I can use CTFE to build parser tables and such. What are the current limitations of CTFE? Are dynamic arrays of structs supported? Associative arrays? What about

Re: Segment violation (was Re: Why I could not cast string to int?)

2012-02-03 Thread Timon Gehr
On 02/03/2012 11:08 AM, Artur Skawina wrote: On 02/03/12 00:20, Jonathan M Davis wrote: in is pointless on value types. All it does is make the function parameter const, which really doesn't do much for you, and in some instances, is really annoying. Personally, I see no point in using in

Re: Segment violation (was Re: Why I could not cast string to int?)

2012-02-03 Thread Timon Gehr
On 02/03/2012 01:06 PM, Jonathan M Davis wrote: On Friday, February 03, 2012 11:08:54 Artur Skawina wrote: BTW, scope should have been the default for *all* reference type function arguments, with an explicit modifier, say esc, required to let the thing escape. It's an all-or-nothing thing,

Re: Segment violation (was Re: Why I could not cast string to int?)

2012-02-02 Thread Timon Gehr
On 02/02/2012 08:04 PM, xancorreu wrote: Al 02/02/12 19:30, En/na bearophile ha escrit: xancorreu: I get segment violation error with ./factorial 40 How can I resolve it? You are having a stack overflow. DMD currently doesn't print a good message because of this regression that is being

Re: Segment violation (was Re: Why I could not cast string to int?)

2012-02-02 Thread Timon Gehr
On 02/02/2012 11:47 PM, H. S. Teoh wrote: On Thu, Feb 02, 2012 at 10:55:06PM +0100, Timon Gehr wrote: On 02/02/2012 08:04 PM, xancorreu wrote: [...] For the other hand, how can increase the stack in linux? [...] I don't know, but it is best to just rewrite the code so that it does not use

Re: opAssign and references

2012-01-31 Thread Timon Gehr
On 01/31/2012 03:03 PM, Nicolas Silva wrote: Hi, I'm playing with variants and I noticed that opAssign is not invoked when an assignation is done on a reference. here is the test case: import std.variant; struct Foo { Variant a; Variant b; ref Variant refA() {

<    1   2   3   4   5   6   7   8   9   >