Re: Testing for template argument being result of takeExactly

2012-09-23 Thread Timon Gehr
On 09/23/2012 10:57 PM, Ali Çehreli wrote: ... Also, I think your code should have passed a range like R.init to takeExactly, not R, which is a type: takeExactly(R.init, 1) I don't know why your code compiles. See discussion here: http://d.puremagic.com/issues/show_bug.cgi?id=8220

Re: function is not function

2012-09-21 Thread Timon Gehr
On 09/21/2012 10:41 PM, Ellery Newcomer wrote: On 09/21/2012 01:17 PM, bearophile wrote: pragma(msg, is(typeof(a) == function)); // nope! code in pyd suggests this evaluated to true once upon a time. I don't think it ever did. It is just very easy to get wrong.

Re: tuple(tuple(1)) fails to compile, but tuple(tuple(1),1) works

2012-09-20 Thread Timon Gehr
On 09/21/2012 01:04 AM, timotheecour wrote: inconsistent: auto a1=tuple(tuple(1));//CT error auto a2=tuple(tuple(1),1);//works bug? Yes. In general, if there is a compile time error other than a static assertion failure that points to Phobos code, you can assume that it is a library bug.

Re: access enclosing type from shared static this()

2012-09-19 Thread Timon Gehr
On 09/19/2012 09:37 PM, Øivind wrote: I want to access the type of the enclosing struct in in a shared static initializer.. How do I do that? The following code will not compile: mixin template MsgMixin(T ...) { static string getName(this M)() { return M.stringof; } shared static

Re: auto limitation?

2012-09-11 Thread Timon Gehr
On 09/11/2012 08:57 PM, Maxim Fomin wrote: I think it is UB rather than a bug. No, this is a bug. The spec says that return types must match exactly. Exactly. If it was UB, the spec would say the behaviour is undefined if they don't match exactly. AFAIK auto is a feature to infer

Re: auto limitation?

2012-09-11 Thread Timon Gehr
On 09/11/2012 09:29 PM, Namespace wrote: On Tuesday, 11 September 2012 at 19:27:40 UTC, Timon Gehr wrote: On 09/11/2012 08:57 PM, Maxim Fomin wrote: I think it is UB rather than a bug. No, this is a bug. The spec says that return types must match exactly. Exactly. If it was UB, the spec

Re: since when was this valid syntax?

2012-09-10 Thread Timon Gehr
On 09/10/2012 07:07 AM, Ellery Newcomer wrote: On 09/08/2012 09:01 AM, Timon Gehr wrote: On 09/08/2012 04:11 PM, Ellery Newcomer wrote: alias enum int e; It is valid according to the grammar I don't believe you. Show me the derivation. The grammar as shown on dlang.org indeed seems

Re: delegate from lambda expression

2012-09-09 Thread Timon Gehr
On 09/10/2012 01:55 AM, bearophile wrote: Your code doesn't look good, Yes it does.

Re: delegate from lambda expression

2012-09-09 Thread Timon Gehr
On 09/10/2012 01:20 AM, timotheecour wrote: I'd like to achieve the following: import std.stdio,std.range,std.algorithm,std.array; void main(){ auto dg=a=a*2; auto a=iota(0,10); writeln(a.map!dg.array); } but this doesn't compile: Error: variable [...]dg type void is

Re: filter out compile error messages involving _error_

2012-09-09 Thread Timon Gehr
On 09/10/2012 01:52 AM, timotheecour wrote: Can we filter out compiler errors involving _error_ as template parameter? Clearly the error is coming from upstream so there's no need to even show those. eg: Error: template mypackage.mymodule.myfunction cannot deduce template function from argument

Re: inconsistent behavior with implicit imports

2012-09-09 Thread Timon Gehr
On 09/10/2012 01:47 AM, timotheecour wrote: This works: import std.stdio; void main(){ writeln(std.conv.to!double(1)); } This doesn't compile: import std.stdio; void main(){ std.stdio.writeln(std.conv.to!double(1)); } =Error: undefined identifier std So it seems

Re: filter out compile error messages involving _error_

2012-09-09 Thread Timon Gehr
On 09/10/2012 02:14 AM, Jonathan M Davis wrote: On Monday, September 10, 2012 01:52:52 timotheecour wrote: Can we filter out compiler errors involving _error_ as template parameter? Clearly the error is coming from upstream so there's no need to even show those. eg: Error: template

Re: const attribute makes whole element const?

2012-09-09 Thread Timon Gehr
On 09/10/2012 02:05 AM, Namespace wrote: I had never problems with that in C++. clang++ sez: error: cannot define the implicit default assignment operator for 'S', because non-static const member 'x' can't use default assignment operator If I have members which are const because they are

Re: int[3][4]*

2012-09-08 Thread Timon Gehr
On 09/08/2012 01:21 PM, bearophile wrote: Timon Gehr: This may corrupt your heap. I usually don't put the alis this... I prefer this: void main(){ alias int[3][4] fooz; int[3][4]* i = (new fooz[1]).ptr; } This allocates past the size of the array, the information to append

Re: since when was this valid syntax?

2012-09-08 Thread Timon Gehr
On 09/08/2012 04:11 PM, Ellery Newcomer wrote: alias enum int e; It is valid according to the grammar and DMD ignores meaningless attributes. scope shared @disable @trusted package final override deprecated extern __gshared synchronized pure nothrow ref static abstract immutable alias auto

Re: since when was this valid syntax?

2012-09-08 Thread Timon Gehr
On 09/08/2012 06:44 PM, bearophile wrote: Timon Gehr: It is valid according to the grammar and DMD ignores meaningless attributes. Do you know why? No reason. Is it just a unfinished part of dmd, or Walter believes this is an acceptable design for a compiler? Jonathan would say he has

Re: since when was this valid syntax?

2012-09-08 Thread Timon Gehr
On 09/08/2012 09:25 PM, Maxim Fomin wrote: On Saturday, 8 September 2012 at 16:00:44 UTC, Timon Gehr wrote: On 09/08/2012 04:11 PM, Ellery Newcomer wrote: alias enum int e; It is valid according to the grammar and DMD ignores meaningless attributes. scope shared @disable @trusted package

Re: const attribute makes whole element const?

2012-09-08 Thread Timon Gehr
On 09/09/2012 01:16 AM, Namespace wrote: Why fail this code? without const on Name it works fine. http://dpaste.dzfl.pl/9fa0986a const fields cannot be written to. This includes the case when the entire struct is written to at once.

Re: typeof(enum)

2012-09-07 Thread Timon Gehr
Accidentally replied to your private email first. On 09/08/2012 12:55 AM, Minas wrote: import std.stdio; enum PI = 3.14; void main() { writeln(typeid(typeof(PI))); } It prints double. Shouldn't it be immutable(double). No. auto x = PI; x++; I think it would make more sense, as it

Re: int[3][4]*

2012-09-07 Thread Timon Gehr
On 09/08/2012 04:19 AM, bearophile wrote: Ellery Newcomer: alright what's the deal? This is one of the clean ways to do it: void main () { static struct Mat { int[3][4] m; alias m this; } Mat* fooz = new Mat; fooz[1][3] = 5; This may corrupt your

Re: Assigning global and static associative arrays

2012-09-02 Thread Timon Gehr
On 09/02/2012 03:45 PM, monarch_dodra wrote: On Saturday, 1 September 2012 at 09:16:30 UTC, Jonathan M Davis wrote: [SNIP] so it looks like not only do all instances of the same string enum use the same memory, but another enum with the same string literal shares it as well. So, only one is

Re: Assigning global and static associative arrays

2012-09-02 Thread Timon Gehr
On 09/02/2012 06:26 PM, monarch_dodra wrote: On Sunday, 2 September 2012 at 16:20:16 UTC, Timon Gehr wrote: On 09/02/2012 03:45 PM, monarch_dodra wrote: FYI: I get the exact same behavior in Windows. Not that it matters, but it sounded like you were asking. I'm a bit confused now though: Why

Re: Call a function on an entire slice

2012-08-29 Thread Timon Gehr
On 08/29/2012 03:38 PM, monarch_dodra wrote: D provides ways to operate on an entire (sub) slice: int[] a = ... ; a[] *= 5; //Multiply everything by 5. a[0 .. 2] = 3; //Set indexes 0 to 1 to the value 3. I was wondering if there was any way to do this for a specified function? struct S {

Re: float[] → Vertex[] – decreases performance by 1000%

2012-08-28 Thread Timon Gehr
On 08/28/2012 06:35 PM, David wrote: Am 28.08.2012 17:41, schrieb bearophile: David: The arrays are 100% identical (I dumped a Vertex()-array and a raw float-array, they were 100% identical). I hope some people are realizing how much time is being wasted in this thread. Taking a look at the

Re: float[] → Vertex[] – decreases performance by 1000%

2012-08-28 Thread Timon Gehr
On 08/29/2012 01:26 AM, David wrote: Use this to create a minimal test case with minimal user interaction: https://github.com/CyberShadow/DustMite Doesn't help if dmd doesn't crash, or? It doesn't help a lot if compilation succeeds, but you stated that you generally tend to ignore dmd bugs.

Re: Reading bytes and converting to int

2012-08-26 Thread Timon Gehr
On 08/26/2012 04:19 PM, Tommi wrote: On Saturday, 25 August 2012 at 20:58:47 UTC, Jonathan M Davis wrote: auto buf = file.rawRead(new ubyte[](4)); Could we somehow skip making the temporary buffer, and read from the file directly into an existing variable. Can we make a slice of one element

Re: opUnary overloading

2012-08-26 Thread Timon Gehr
On 08/26/2012 10:33 PM, cal wrote: I have a struct wrapping a union of an int and a float, and want to overload opUnary for this struct: struct Value { enum Type { INT, FLOAT } Type type; union { int i; float f; } this(int _i) {

Re: Check for ctfe

2012-08-25 Thread Timon Gehr
On 08/25/2012 12:53 PM, Minas Mina wrote: Why is it if( __ctfe ) and not static if.. ? Both branches need to be compiled in order to have both a ctfe and a runtime version.

Re: struct init property

2012-08-24 Thread Timon Gehr
On 08/24/2012 09:39 AM, nocide wrote: Am 23.08.2012 19:15, schrieb nocide: struct has no default constructor and instances are initialized with the init property. Can I declare or override the init property for a custom defined struct? Ok, the initializer forks fine for me, but I've

Re: Sudoku Py / C++11 / D?

2012-08-24 Thread Timon Gehr
On 08/24/2012 09:32 PM, maarten van damme wrote: I've distiled what I understood from your source and the resulting executable managed to solve the impossible one in 27 seconds while your source takes 41 seconds. It is 10s vs 13s with GDC on my machine.

Re: Check for ctfe

2012-08-24 Thread Timon Gehr
On 08/25/2012 02:06 AM, cal wrote: I saw something on the forum not too long ago about statically checking to see if the current function is being executed at compile time, but can't seem to find it now. Can it be done? (Like static if (__ctfe__) or something) if(__ctfe)

Re: Check for ctfe

2012-08-24 Thread Timon Gehr
On 08/25/2012 02:15 AM, bearophile wrote: cal: I saw something on the forum not too long ago about statically checking to see if the current function is being executed at compile time, but can't seem to find it now. Can it be done? (Like static if (__ctfe__) or something) It's named __ctfe,

Re: Sudoku Py / C++11 / D?

2012-08-24 Thread Timon Gehr
On 08/25/2012 01:01 AM, Timon Gehr wrote: On 08/24/2012 09:32 PM, maarten van damme wrote: I've distiled what I understood from your source and the resulting executable managed to solve the impossible one in 27 seconds while your source takes 41 seconds. It is 10s vs 13s with GDC on my

Re: Sudoku Py / C++11 / D?

2012-08-24 Thread Timon Gehr
On 08/25/2012 02:38 AM, Timon Gehr wrote: On 08/25/2012 01:01 AM, Timon Gehr wrote: On 08/24/2012 09:32 PM, maarten van damme wrote: I've distiled what I understood from your source and the resulting executable managed to solve the impossible one in 27 seconds while your source takes 41

Re: inout functions

2012-08-23 Thread Timon Gehr
On 08/24/2012 12:14 AM, Piotr Szturmaj wrote: Hi, I found this code of std.range.iota's Result struct: @property inout(Value) front() inout { assert(!empty); return current; } What's the purpose of inout on parameterless functions? It is a method of a struct, therefore it is not

Re: reduce!a+b(R) syntax question

2012-08-21 Thread Timon Gehr
On 08/21/2012 07:05 PM, Andrew Spott wrote: When I'm doing an anonymous function for something like reduce, how are the arguments determined? Is it alphabetical? Can I use any names (reduce!d-c(R)?), or are the names defined in the function reduce? They are defined here:

Re: Sudoku Py / C++11 / D?

2012-08-21 Thread Timon Gehr
On 08/21/2012 05:52 PM, maarten van damme wrote: On 08/20/2012 11:49 PM, Timon Gehr wrote: On 08/20/2012 10:43 PM, maarten van damme wrote: Still it comes nowhere near beating timons solution. Is the logic of that documented somewhere because I don't understand it. Try this: http

Re: template and constraints

2012-08-20 Thread Timon Gehr
On 08/20/2012 11:52 PM, bioinfornatics wrote: I got a little problem with these code: double div(T a, U b)() if( a 0 b 0 ){ // not works T and U unknwn identifier return a / b; } double div(T,U)(T a, U b) if( a 0 b 0 ){ // not works, a and b not known at compile

Re: Non-immutable char[] doesn't change?

2012-08-18 Thread Timon Gehr
On 08/18/2012 02:15 PM, Salih Dincer wrote: This may be the solution...:) char[] b = cast(char[])abc.dup; // ok, unique reference Sorry... You don't need the cast in this case. Topic: It is not a bug, but it might be surprising because the behaviour of typeid is different with polymorphic

Re: How create a operator tree?

2012-08-17 Thread Timon Gehr
On 08/17/2012 10:38 AM, Namespace wrote: o_O I was hoping that there is a shorter way than this. I hacked together the following little parser (not extensively tested). http://dpaste.dzfl.pl/e616692e It transforms the input expression into polish notation, ignoring space characters. Note

Re: How create a operator tree?

2012-08-17 Thread Timon Gehr
On 08/17/2012 02:55 PM, Timon Gehr wrote: On 08/17/2012 10:38 AM, Namespace wrote: o_O I was hoping that there is a shorter way than this. I hacked together the following little parser (not extensively tested). http://dpaste.dzfl.pl/e616692e It transforms the input expression into polish

Re: Matrix Multiplication benchmark

2012-08-16 Thread Timon Gehr
On 08/16/2012 03:15 PM, Matthias Pleh wrote: I've created a simple 4x4 Matrix struct and have made some tests, with surprising results. (although I've heard from similar results in c++) struct mat4 { float[4][4] m; mat4 opMul(in mat4 _m); } mat4 mul(in mat4 m1, in mat4 m2); I've tested

Re: Sudoku Py / C++11 / D?

2012-08-16 Thread Timon Gehr
On 08/16/2012 09:52 PM, maarten van damme wrote: I've now ran in something odd. Using a slight variant from my program on dpaste (can't upload modified version atm but changes are minimal) it takes 0.6 seconds to solve the hard puzzle the python version took 180 seconds for. This is because

Re: Sudoku Py / C++11 / D?

2012-08-16 Thread Timon Gehr
On 08/16/2012 11:51 PM, maarten van damme wrote: This is because your specific solution is slow. Mine takes 20ms on the 'hard' puzzle and ~13s on the impossible one. (~2.4 GHZ intel x86_64 machine, with gdmd -O -release -inline -noboundscheck.) There is a constant factor between those

Re: Sudoku Py / C++11 / D?

2012-08-16 Thread Timon Gehr
On 08/17/2012 01:13 AM, maarten van damme wrote: great, going to play around with it tomorrow. Caching the possibilities is going to look really ugly but you're right, it's going to give quiet a boost in performance. I'm also going to format your source code a bit more and see if I can follow

Re: Sudoku Py / C++11 / D?

2012-08-15 Thread Timon Gehr
On 08/15/2012 12:31 AM, bearophile wrote: http://www.reddit.com/r/cpp/comments/y6gwk/norvigs_python_sudoku_solver_ported_to_c11/ http://nonchalantlytyped.net/blog/2012/08/13/sudoku-solver-in-c11/ His C++11 port is 316 lines long: https://gist.github.com/3345676 How many lines for a (not

Re: Iterating through enumeration

2012-08-12 Thread Timon Gehr
On 08/12/2012 01:54 PM, bearophile wrote: Era Scarecrow: But that problem goes away if you turn it into a small array right? (And pass the array to the foreach to cycle over) So throwing that idea out there you get... foo[] array; foreach(m; std.traits.EnumMembers!foo) array ~= m;

Re: Convert little imperative code to functional coding style

2012-08-12 Thread Timon Gehr
On 08/10/2012 09:59 PM, Nathan M. Swan wrote: On Friday, 10 August 2012 at 18:26:56 UTC, Timon Gehr wrote: Is this what you are looking for? import std.stdio; import std.range : iota; import std.algorithm : map, filter, joiner; import std.typecons : tuple; import std.math : sqrt, floor; void

Re: char ***argc problems.

2012-08-12 Thread Timon Gehr
On 08/12/2012 10:33 PM, Andrew wrote: I'm attempting to create a wrapper for MPI, however, MPI_Init wants to read the arguments for main(): MPI_Init(int *argv, char ***argc); How do I get this last level of pointer reference? So far, I have: void main (string[] args) { auto argarr = new

Re: char ***argc problems.

2012-08-12 Thread Timon Gehr
On 08/12/2012 11:38 PM, Andrew wrote: On Sunday, 12 August 2012 at 20:57:34 UTC, Timon Gehr wrote: On 08/12/2012 10:33 PM, Andrew wrote: I'm attempting to create a wrapper for MPI, however, MPI_Init wants to read the arguments for main(): MPI_Init(int *argv, char ***argc); How do I get

Re: Optional extra return value? Multiple return values with auto?

2012-08-11 Thread Timon Gehr
There is no compiler bug. You cannot pass immutable/rvalue by reference to mutable.

Re: Specialize mixin templates

2012-08-11 Thread Timon Gehr
On 08/11/2012 11:42 PM, Henning Pohl wrote: A struct takes a mixin template as argument: struct S(alias Mixin) { mixin Mixin; } How to specialize a mixin template like this one to pass to S? mixin template MixinTemplate(T) { } S(MixinTemplate!float); // Something like this This is a way

Re: Convert little imperative code to functional coding style

2012-08-10 Thread Timon Gehr
Is this what you are looking for? import std.stdio; import std.range: iota; import std.algorithm: map, filter, joiner; import std.typecons : tuple; import std.math : sqrt, floor; void main(){ immutable limit = cast(size_t)floor(sqrt(1_000.0)); auto r =

Re: Why __traits(compile,...) fails here?

2012-08-08 Thread Timon Gehr
On 08/07/2012 03:52 PM, Philippe Sigaud wrote: On Tue, Aug 7, 2012 at 12:42 PM, Zhenyazh...@list.ru wrote: Template alias parameters do not accept built-in types. The trick is: - A template type parameter (like (T)) recognizes types - A template alias parameter(like (alias a)) recognizes

Re: overloading a function taking a void[][]

2012-08-08 Thread Timon Gehr
Try this: template digest(Hash) if(isDigest!Hash){ digestType!Hash digest(Range)(Range data) if(!is(Range:void[][]) isInputRange!Range __traits(compiles,digest!Hash(ElementType!(Range).init))){ //implementation detail } digestType!Hash digest()(scope

Re: overloading a function taking a void[][]

2012-08-08 Thread Timon Gehr
On 08/08/2012 09:11 PM, Johannes Pfau wrote: Am Wed, 08 Aug 2012 18:53:05 +0200 schrieb Timon Gehrtimon.g...@gmx.ch: Try this: template digest(Hash) if(isDigest!Hash){ digestType!Hash digest(Range)(Range data) if(!is(Range:void[][]) isInputRange!Range

Re: How to use read_bool?

2012-08-06 Thread Timon Gehr
On 08/04/2012 03:01 AM, Zeh wrote: Thanks for the help, but i tryed both solutions posted and still not working. :/ I get erros to compile the code posted by simendsjo. I try modify at my own, but without success. The code suggest by Timon Gehr compiles, but not work. Works for me. Maybe

Re: Return doesn't really return

2012-08-04 Thread Timon Gehr
On 08/04/2012 06:23 PM, Jacob Carlborg wrote: I have a piece of code that looks like this: https://github.com/jacob-carlborg/dstep/blob/master/clang/Visitor.d#L168 If I change that first function to look like this: @property ParamCursor first () { assert(any, Cannot get the first parameter of

Re: Return doesn't really return

2012-08-04 Thread Timon Gehr
On 08/04/2012 08:54 PM, Jacob Carlborg wrote: On 2012-08-04 19:08, Timon Gehr wrote: int opApply (Delegate dg) { auto result = clang_visitChildren(cursor, visitorFunction,cast(CXClientData) dg); return result == CXChildVisitResult.CXChildVisit_Break ? 1 : 0; // culprit } Yes

Re: NotNull Parser

2012-08-03 Thread Timon Gehr
On 08/03/2012 12:38 PM, Namespace wrote: In context with my post here: http://forum.dlang.org/thread/gajrorlwnrriljxnx...@forum.dlang.org#post-egvyqwkcqjglhrvujkar:40forum.dlang.org I wrote the last days a NotNull Parser. What is this? The NotNull Parser generate for parameter statements with

Re: How to use read_bool?

2012-08-02 Thread Timon Gehr
On 08/03/2012 06:17 AM, Zeh wrote: Hi, i am just a newbie trying learn D. But, i get having some trouble with read_bool. More specifically on program of this lesson: import std.stdio; import std.conv; import std.string; void main() { write(How many are we? ); int personCount; readf( %s,

Re: Detector for unused variables

2012-08-01 Thread Timon Gehr
On 08/01/2012 12:38 PM, bearophile wrote: Regan Heath: Indeed. IIRC Walter's rationale on things like this has always been that they belong in 3rd party tools. Walter is not always right. It's why the DMD front end is available for use, so people can create tools like this, syntax

Re: Detector for unused variables

2012-07-31 Thread Timon Gehr
On 07/31/2012 11:55 AM, Minas wrote: I agree that having the compiler make warnings about unused variables is a really good idea!!! Java has it and when I program in eclipse it's really useful because the editor can highlight the particular lines. An editor can be configured to point it out

Re: Why must bitfields sum to a multiple of a byte?

2012-07-31 Thread Timon Gehr
On 07/31/2012 06:57 PM, Era Scarecrow wrote: On Tuesday, 31 July 2012 at 16:48:37 UTC, Andrej Mitrovic wrote: On 7/31/12, Era Scarecrow rtcv...@yahoo.com wrote: I wonder, is it really a bug? If you are going to have it fill a whole size it would fit anyways, why even put it in as a bitfield?

Re: sorting failed error

2012-07-30 Thread Timon Gehr
On 07/30/2012 02:36 PM, maarten van damme wrote: For fun I started implementing a program that uses genetics algorithm's to solve the travelling salesman problem. I want to sort an array of chromosome structures according to their fitness. I now get the error:

Re: sorting failed error

2012-07-30 Thread Timon Gehr
On 07/30/2012 03:52 PM, monarch_dodra wrote: ... Your looks OK, and I doubt you are mutating. I only see floating point gotchas: If a chromosome travels nothing, then his fitness is 1/0 = NaN. 1/0 evaluates to Inf NaN then compares false with everything, making it un-transitive, and

Re: sorting failed error

2012-07-30 Thread Timon Gehr
On 07/31/2012 12:30 AM, maarten van damme wrote: 2012/7/31 Timon Gehrtimon.g...@gmx.ch: ... further comments whose application does not lead to immediate benefit: - in contracts are better specified in their dedicated section to push the requirements onto the caller. - consider for(;;) as a

Re: Is delete really going away?

2012-07-29 Thread Timon Gehr
On 07/29/2012 03:03 PM, Minas Mina wrote: Having a destructor and that you know when is going to be called is VERY useful! So by removing the delete keyword, what happens? We won't have a way to destroy objects in a predictable way anymore? (I'm not talking about structs in any way). Thanks

Re: template with more than one tuple parameter

2012-07-29 Thread Timon Gehr
On 07/28/2012 06:17 PM, Zhenya wrote: Why do not D allow templates with more than one tuple parameters,at the same time that C++11 support it: This is a gratuitous restriction. They will be supported at some point.

Re: template with more than one tuple parameter

2012-07-29 Thread Timon Gehr
On 07/28/2012 06:47 PM, Simen Kjaeraas wrote: On Sat, 28 Jul 2012 18:17:14 +0200, Zhenya zh...@list.ru wrote: Why do not D allow templates with more than one tuple parameters,at the same time that C++11 support it: Well, Walter implemented type tuples with automatic flattening, The lack of

Re: A few questions

2012-07-29 Thread Timon Gehr
On 07/27/2012 04:35 PM, bearophile wrote: But implementing good non-null types in library code is hard It is closer to impossible than to hard. (rather harder than implementing vector ops in library code on library defined vectors). I think @disable isn't enough to cover what Spec# shows

Re: A few questions

2012-07-29 Thread Timon Gehr
On 07/29/2012 06:24 PM, bearophile wrote: Timon Gehr: Non-null types in Spec# are unsound. Really? I didn't know it. Surely its non-null design looks quite refined and thought-out. But maybe as say it's not enough still. Do you have a link where it shows it's unsound? Google for freedom

Re: Ranges and backward iteration

2012-07-29 Thread Timon Gehr
On 07/30/2012 01:26 AM, Andrew wrote: I have a use case where I would like to be able to pass both a forward and backward iteration of an array to a function: void foo(InputR, OutputR)(InputR i, OutputR j) if (isInputRange!InputR isOutputRange!(OutputR, InputR)) { ... } main() { //forward:

Re: Compilation failure

2012-07-20 Thread Timon Gehr
On 07/20/2012 01:53 PM, bearophile wrote: Timon Gehr: Usually bugs are reported by the guy who finds them, but here you go: http://d.puremagic.com/issues/show_bug.cgi?id=8400 Thank you, already fixed, it seems. Even if the fix is the opposite of what I have thought (I was thinking about

Re: ~= call copy ctor?

2012-07-19 Thread Timon Gehr
Use std.algorithm.move if you want to avoid the copy ctor call.

Re: Is this actually supposed to be legal?

2012-07-18 Thread Timon Gehr
On 07/18/2012 11:08 PM, monarch_dodra wrote: On Tuesday, 17 July 2012 at 23:38:04 UTC, Jonathan M Davis wrote: It's not that it makes the compiler's life hard. It's the fact that conditional compilation relies on state that doesn't exist yet. It's messed up to be checking whether an object

Re: Is this actually supposed to be legal?

2012-07-18 Thread Timon Gehr
On 07/18/2012 01:37 AM, Jonathan M Davis wrote: On Tuesday, July 17, 2012 23:11:43 Timon Gehr wrote: This issue is unrelated to CRTP. (also, you probably want to negate that static if condition, otherwise the code is valid and poses no challenge to a compiler.) It's not that it makes

Re: Compilation failure

2012-07-18 Thread Timon Gehr
On 07/19/2012 12:42 AM, bearophile wrote: Timon Gehr: You are right; this is a bug. This discussion is not about an obscure language detail, it's a common situation. FWIW, I have never run across it before. So if you think this is a bug, then please Timon file it in Bugzilla. Usually

Re: Is this actually supposed to be legal?

2012-07-17 Thread Timon Gehr
On 07/17/2012 07:23 PM, Jonathan M Davis wrote: On Tuesday, July 17, 2012 14:48:32 David Nadlinger wrote: On Tuesday, 17 July 2012 at 05:24:26 UTC, Jonathan M Davis wrote: This code strikes me as being a bug: class MyBase(T) {} class MySubA : MyBase!MySubA {} class MySubB :

Re: Is this actually supposed to be legal?

2012-07-17 Thread Timon Gehr
On 07/17/2012 10:50 PM, Jonathan M Davis wrote: On Tuesday, July 17, 2012 22:36:10 Timon Gehr wrote: On 07/17/2012 07:23 PM, Jonathan M Davis wrote: On Tuesday, July 17, 2012 14:48:32 David Nadlinger wrote: On Tuesday, 17 July 2012 at 05:24:26 UTC, Jonathan M Davis wrote: This code strikes

Re: Can't create immutable type in template

2012-07-16 Thread Timon Gehr
On 07/16/2012 01:38 AM, Nick Gurrola wrote: import std.stdio; void main() { writeln(typeid(Test!int)); } template Test(T...) { alias immutable(T[0]) Test; } This prints int instead of immutable(int) like I would expect. Is this a bug, or is that what is supposed to happen? This is

Re: ufcs and integer params

2012-07-16 Thread Timon Gehr
On 07/16/2012 10:55 AM, Chris NS wrote: Having been around long enough to remember when the ability to call foo() as foo first appeared, I feel it necessary to point out that this was *not* in fact a deliberate design, but rather a sort of accident that arose out of D's first attempt at

Re: ufcs and integer params

2012-07-15 Thread Timon Gehr
On 07/15/2012 05:40 AM, Jonathan M Davis wrote: On Sunday, July 15, 2012 05:30:55 Jay Norwood wrote: I see from this other discussions that it looks like 2.059 ( or maybe 2.060) does support something like 3.cm(). Not sure from the discussion if it would also accept 3.cm as in the xtext/xtend

Re: ufcs and integer params

2012-07-15 Thread Timon Gehr
On 07/15/2012 09:41 PM, Jonathan M Davis wrote: On Sunday, July 15, 2012 11:56:57 Jonathan M Davis wrote: What is enforced here? Why would it matter if anything is 'enforced'? If you marked it as a property, then it's supposed to be abstracting a variable and should be treated as one, just

Re: ufcs and integer params

2012-07-15 Thread Timon Gehr
On 07/15/2012 08:56 PM, Jonathan M Davis wrote: On Sunday, July 15, 2012 19:50:18 Timon Gehr wrote: On 07/15/2012 05:40 AM, Jonathan M Davis wrote: On Sunday, July 15, 2012 05:30:55 Jay Norwood wrote: I see from this other discussions that it looks like 2.059 ( or maybe 2.060) does support

Re: ufcs and integer params

2012-07-15 Thread Timon Gehr
On 07/15/2012 11:11 PM, Jonathan M Davis wrote: There are two levels to enforcement. Neither exist without -property. The absolutely minimal level is that anything marked with @property must be used as a property. Without this, you can't swap out a property function for a variable without

Re: ufcs and integer params

2012-07-15 Thread Timon Gehr
On 07/15/2012 11:43 PM, Jonathan M Davis wrote: On Sunday, July 15, 2012 23:35:12 Timon Gehr wrote: The second level - i.e. strict property enforcement - also requires that non- property functions be called as functions. Exactly. This part is useless. And there, we will forever disagree

Re: ufcs and integer params

2012-07-15 Thread Timon Gehr
On 07/15/2012 11:35 PM, Jonathan M Davis wrote: On Sunday, July 15, 2012 23:29:04 Timon Gehr wrote: The current plan is (and has been for some time) that -property will become the normal behavior, It is obvious that -property is broken and will not become the normal behaviour. It is obvious

Re: ufcs and integer params

2012-07-15 Thread Timon Gehr
On 07/15/2012 11:56 PM, Jonathan M Davis wrote: On Sunday, July 15, 2012 23:47:58 Timon Gehr wrote: On 07/15/2012 11:43 PM, Jonathan M Davis wrote: On Sunday, July 15, 2012 23:35:12 Timon Gehr wrote: The second level - i.e. strict property enforcement - also requires that non- property

Re: caller trouble

2012-07-14 Thread Timon Gehr
On 07/14/2012 08:53 AM, captaindet wrote: i need a discreet handle on the calling/instantiating source file (module). using __FILE__, it is surprisingly easy for functions (via argument) and templated functions (via template parameter) but i cannot get it working for templated classes. how can i

Re: (a,b,c) syntax

2012-07-11 Thread Timon Gehr
On 07/11/2012 02:44 PM, Andrea Fontana wrote: Why this code print five ? writeln((One, 10, Five)); What does ( ... , ... , ...) means? , is the comma operator inherited from C. a,b means: execute a first, then b, and the result is b.

Re: Return type inference on template

2012-07-10 Thread Timon Gehr
On 07/10/2012 04:14 PM, Andrea Fontana wrote: Simple template: T test(T)() { return T.init; } This code give error: int myVar; myVar = test(); Why? Can't compiler guess T == int? Type deduction only proceeds in the direction the data flows. Reversing this process would in principle work

Re: Compilation failure

2012-07-10 Thread Timon Gehr
On 07/08/2012 11:47 PM, Lemonfiend wrote: Hi, I seem to have run into a strange error.. When I put tmp1 outside the main loop, it compiles fine and gives the expected output. When tmp1 is put inside the main loop, the compiler seems to get stuck in a loop? I've tested it on:

Re: readonly?

2012-07-10 Thread Timon Gehr
On 07/11/2012 12:58 AM, Ali Çehreli wrote: On 07/10/2012 03:53 PM, Namespace wrote: const(T)* ? Example? class Bar {} class Foo { const(Bar) * _b; void SetBar(const(Bar) * b) { _b = b; } } void main() { auto b = new Bar(); auto f = new Foo();

Re: Compilation failure

2012-07-10 Thread Timon Gehr
On 07/11/2012 04:25 AM, ixid wrote: in some way it sees global immutables almost as enums This seems like a bad idea. Consistency of behaviour would seem to be a good principle to expect of a language. You are right; this is a bug.

Re: multiple inheritance

2012-07-08 Thread Timon Gehr
On 07/08/2012 07:31 PM, Namespace wrote: How can i implement C++ behaviour like this: class Shape : Drawable, Transformable { class Sprite : Drawable { class Image : Transformable { ? One way is to declare Transformable or Drawable as interface. But what if i have more then one class which

Re: multiple inheritance

2012-07-08 Thread Timon Gehr
On 07/08/2012 07:47 PM, Namespace wrote: Smart idea. Why the inner class and not direct Transformable _t; ? If it should be true multiple inheritance, the class must be able to override the virtual methods of each superclass and each overridden method must be given access to the fields of the

Re: Portable way to obtain member function pointer (and invoke it)?

2012-07-08 Thread Timon Gehr
On 07/08/2012 09:57 PM, Alex Rønne Petersen wrote: Hi, Is there a portable way to obtain a pointer to a member function and invoke it with the this reference? I seem to recall some discussion about this on the NG in the past, but can't find the thread now. auto mptr = function(Base o,Args

Re: Garbage Collection Pitfall in C++ but not in D?

2012-07-06 Thread Timon Gehr
On 07/06/2012 05:39 PM, Alex Rønne Petersen wrote: On 06-07-2012 16:07, Denis Shelomovskij wrote: 06.07.2012 17:43, akaz пишет: Hi, Reading about the C++11, I stumbled upon this: http://www2.research.att.com/~bs/C++0xFAQ.html#gc-abi Specifically (quote): int* p = new int; p+=10; // ...

Re: why is string not implicit convertable to const(char*) ?

2012-07-05 Thread Timon Gehr
On 07/05/2012 09:32 PM, dcoder wrote: Thanks for the thorough explanation, but it begs the question why not make strings be array of chars that have \0 at the end of it? Because that is inefficient. It disables string slicing and is completely redundant. BTW: String literals are guaranteed

<    1   2   3   4   5   6   7   8   9   >