Re: Intelligent Scope Hierarchy

2013-10-31 Thread Stretto
On Thursday, 31 October 2013 at 22:03:18 UTC, Namespace wrote: The 'it' property is only some 'singleton' approach. You can write: void foo() { auto buffer = Mallocator.allocate(42); /// ... many code } And at the end of the scope buffer is cleared because Mallocator's destructor call

Re: is this invalid code

2013-10-31 Thread Ali Çehreli
On 10/31/2013 08:29 PM, Daniel Davidson wrote: The following crashes on writeln, but looks reasonable. Is some form of initializing ctor required for RateCurve? import std.datetime; import std.range; import std.stdio; struct DateRate { Date date; double value = 0.0; } struct RateCurve {

is this invalid code

2013-10-31 Thread Daniel Davidson
The following crashes on writeln, but looks reasonable. Is some form of initializing ctor required for RateCurve? import std.datetime; import std.range; import std.stdio; struct DateRate { Date date; double value = 0.0; } struct RateCurve { private immutable(DateRate)[] _data; } struct

Re: Dynamic load from another context

2013-10-31 Thread TheFlyingFiddle
On Thursday, 31 October 2013 at 02:45:36 UTC, Wolftein wrote: so my question is, is it possible to build an associative array at compile-time? Yes, by using ctfe it's possible. like so: enum int[string] aa = createAA(); auto createAA() { int[string] aa; aa["hello"] = 1;

Re: new Type[count] takes too much?

2013-10-31 Thread Namespace
On Thursday, 31 October 2013 at 23:48:19 UTC, Jonathan M Davis wrote: On Thursday, October 31, 2013 23:06:22 Namespace wrote: On Thursday, 31 October 2013 at 09:53:39 UTC, Jonathan M Davis wrote: > On Thursday, October 31, 2013 10:15:51 Namespace wrote: >> I'm sure we had already this conversat

Re: new Type[count] takes too much?

2013-10-31 Thread Jonathan M Davis
On Thursday, October 31, 2013 23:06:22 Namespace wrote: > On Thursday, 31 October 2013 at 09:53:39 UTC, Jonathan M Davis > > wrote: > > On Thursday, October 31, 2013 10:15:51 Namespace wrote: > >> I'm sure we had already this conversation but I don't find the > >> thread. > >> > >> T[] buffer = n

Re: improving '$' to work with other functions (eg: indexed)

2013-10-31 Thread Jonathan M Davis
On Thursday, October 31, 2013 14:46:29 Timothee Cour wrote: > well it can be made to work with following rule: > > $ binds as follows, using the 1st pattern matched rule: > > very roughly: > > identifier [$] if typeof(a.length) => a[a.length] //likewise with s/[]/()/ > primary_expression . ident

Re: new Type[count] takes too much?

2013-10-31 Thread Namespace
On Thursday, 31 October 2013 at 09:53:39 UTC, Jonathan M Davis wrote: On Thursday, October 31, 2013 10:15:51 Namespace wrote: I'm sure we had already this conversation but I don't find the thread. T[] buffer = new T[N]; assumes more space than stated (in average 2010 elements more. See: http:

Re: improving '$' to work with other functions (eg: indexed)

2013-10-31 Thread Timothee Cour
well it can be made to work with following rule: $ binds as follows, using the 1st pattern matched rule: very roughly: identifier [$] if typeof(a.length) => a[a.length] //likewise with s/[]/()/ primary_expression . identifier if typeof(primary_expression.length) => primary_expression . identifie

Re: Intelligent Scope Hierarchy

2013-10-31 Thread Namespace
The 'it' property is only some 'singleton' approach. You can write: void foo() { auto buffer = Mallocator.allocate(42); /// ... many code } And at the end of the scope buffer is cleared because Mallocator's destructor call deallocateAll (if I'm not wrong).

Re: [challenge] Lazy flatten/avoiding type forward reference with map

2013-10-31 Thread Ali Çehreli
On 10/31/2013 02:19 PM, Ali Çehreli wrote: > Y Combinator? (No, I have not solved it yet. :) ) http://rosettacode.org/wiki/Y_combinator#D Ok, I was actually trying to find the following one: https://github.com/gecko0307/atrium/blob/master/dlib/functional/combinators.d Ali

Re: [challenge] Lazy flatten/avoiding type forward reference with map

2013-10-31 Thread Ali Çehreli
On 10/31/2013 12:09 PM, David Nadlinger wrote: A while back, somebody raised the topic of implementing a lazy range for traversing/flattening a tree structure on #d. The obvious (in terms of Phobos primitives) solution would be something along the lines of this: --- struct Node(T) { T val;

Re: Assertion failure: '0' on line 1215 in file 'glue.c'

2013-10-31 Thread Jonathan M Davis
On Thursday, October 31, 2013 20:39:36 bearophile wrote: > Wolftein: > > Assertion failure: '0' on line 1215 in file 'glue.c' > > > > When trying to compile this: > > > > TypeTuple!(void delegate(Event), EventPriority, ulong)[uint] > > _ownerList; > > > > Is that a compiler bug or i'm doing some

Re: D / GtkD for SQL Server

2013-10-31 Thread Jacob Carlborg
On 2013-10-31 14:47, ilya-stromberg wrote: John, It's interesting if you can connect to the MS SQL. Just use FreeTDS, nothing special about it. See: http://forum.dlang.org/thread/l403bf$139g$1...@digitalmars.com#post-l4089g:241723:241:40digitalmars.com -- /Jacob Carlborg

Re: new Type[count] takes too much?

2013-10-31 Thread H. S. Teoh
On Thu, Oct 31, 2013 at 01:28:13PM -0700, Ali Çehreli wrote: > On 10/31/2013 01:10 PM, Marco Leise wrote: > >Am Thu, 31 Oct 2013 10:42:35 +0100 > >schrieb "Namespace" : > > > >>On Thursday, 31 October 2013 at 09:27:11 UTC, bearophile wrote: > >>>In Python if you append items to an array, it sovra-a

Re: new Type[count] takes too much?

2013-10-31 Thread Ali Çehreli
On 10/31/2013 01:10 PM, Marco Leise wrote: Am Thu, 31 Oct 2013 10:42:35 +0100 schrieb "Namespace" : On Thursday, 31 October 2013 at 09:27:11 UTC, bearophile wrote: In Python if you append items to an array, it sovra-allocates, Never heard of 'sovra'. What does it mean? That's bearophilian f

Re: new Type[count] takes too much?

2013-10-31 Thread Marco Leise
Am Thu, 31 Oct 2013 10:42:35 +0100 schrieb "Namespace" : > On Thursday, 31 October 2013 at 09:27:11 UTC, bearophile wrote: > > In Python if you append items to an array, it sovra-allocates, > Never heard of 'sovra'. What does it mean? That's bearophilian for 'over'. :p -- Marco

Re: C/C++ struct interfacing

2013-10-31 Thread Rémy Mouëza
Below is a solution to get it to work as a C binding. - Your structure should not be enclosed in the `extern (C)` block; leave it as regular D code. - cppcall should be declared `extern (C)` in D and `extern "C"` in C++; - depending on your platform, you need to link to the C++ standard lib ;

Re: new Type[count] takes too much?

2013-10-31 Thread Marco Leise
Am Thu, 31 Oct 2013 02:52:49 -0700 schrieb Jonathan M Davis : > On Thursday, October 31, 2013 10:15:51 Namespace wrote: > > I'm sure we had already this conversation but I don't find the > > thread. > > > > T[] buffer = new T[N]; assumes more space than stated (in average > > 2010 elements more.

Re: Using reduce() with tuples created by zip()

2013-10-31 Thread bearophile
alias sum(T) = curry!(reduce!q{a + b}, cast(T)0); double euclidDistance(double[] xs, double[] ys) in { assert(xs.length == ys.length); } body { return zip(xs, ys) .map!(xy => (xy[0] - xy[1]) ^^ 2) .sum!double .sqrt; } void main() { auto xs = [0.0, 1.

Re: Assertion failure: '0' on line 1215 in file 'glue.c'

2013-10-31 Thread Wolftein
On Thursday, 31 October 2013 at 19:48:19 UTC, Wolftein wrote: On Thursday, 31 October 2013 at 19:39:37 UTC, bearophile wrote: Wolftein: Assertion failure: '0' on line 1215 in file 'glue.c' When trying to compile this: TypeTuple!(void delegate(Event), EventPriority, ulong)[uint] _ownerList;

Re: Using reduce() with tuples created by zip()

2013-10-31 Thread Craig Dillabaugh
On Thursday, 31 October 2013 at 19:23:56 UTC, Philippe Sigaud wrote: I think reduce takes two arguments: the growing seed and the current front. You're trying to get (a[0]-b[0])^^2 + (a[1]-b[1])^^2 + ..., right? Yep. The (e[1]-e[0])*(e[1]-e[0]) bit was, I supposed was effectively calculating (a

Re: Using reduce() with tuples created by zip()

2013-10-31 Thread bearophile
Craig Dillabaugh: I know I could use a simple foreach loop with my zip command, or even std.numeric.euclidean( ... ), but I am trying to be cute here! import std.stdio, std.algorithm, std.range, std.math, std.functional; alias sum(T) = curry!(reduce!q{a + b}, cast(T)0); double euclidDista

Re: Assertion failure: '0' on line 1215 in file 'glue.c'

2013-10-31 Thread Wolftein
On Thursday, 31 October 2013 at 19:39:37 UTC, bearophile wrote: Wolftein: Assertion failure: '0' on line 1215 in file 'glue.c' When trying to compile this: TypeTuple!(void delegate(Event), EventPriority, ulong)[uint] _ownerList; Is that a compiler bug or i'm doing something that i don't s

Re: Assertion failure: '0' on line 1215 in file 'glue.c'

2013-10-31 Thread Jonathan M Davis
On Thursday, October 31, 2013 20:30:25 Wolftein wrote: > Assertion failure: '0' on line 1215 in file 'glue.c' > > When trying to compile this: > > TypeTuple!(void delegate(Event), EventPriority, ulong)[uint] > _ownerList; > > Is that a compiler bug or i'm doing something that i don't > suppose t

Re: Assertion failure: '0' on line 1215 in file 'glue.c'

2013-10-31 Thread bearophile
Wolftein: Assertion failure: '0' on line 1215 in file 'glue.c' When trying to compile this: TypeTuple!(void delegate(Event), EventPriority, ulong)[uint] _ownerList; Is that a compiler bug or i'm doing something that i don't suppose to do. It seems both a compiler bug fit for bugzilla, an

Re: fieldPostBlit - what is wrong with this and workarounds

2013-10-31 Thread Jonathan M Davis
On Thursday, October 31, 2013 15:03:26 Daniel Davidson wrote: > Given this code: > > import plus.tvm.rate_curve; > struct T { > RateCurve m; > } > struct S { > const(T) rc; > } > > I get this error: Error: mutable method > plus.models.dossier.__unittestL42_1.T.__fieldPostBlit is not > callable us

Assertion failure: '0' on line 1215 in file 'glue.c'

2013-10-31 Thread Wolftein
Assertion failure: '0' on line 1215 in file 'glue.c' When trying to compile this: TypeTuple!(void delegate(Event), EventPriority, ulong)[uint] _ownerList; Is that a compiler bug or i'm doing something that i don't suppose to do.

Re: Using reduce() with tuples created by zip()

2013-10-31 Thread Philippe Sigaud
I think reduce takes two arguments: the growing seed and the current front. You're trying to get (a[0]-b[0])^^2 + (a[1]-b[1])^^2 + ..., right? Try this: module euclid; import std.stdio; double euclid_dist( double[] pt1, double[] pt2 ) { assert( pt1.length == pt2.length ); import std.al

Using reduce() with tuples created by zip()

2013-10-31 Thread Craig Dillabaugh
I am trying to calculate the Euclidean Distance between two points. I currently have the following function (that doesn't compile): double euclid_dist( double[] pt1, double[] pt2 ) { assert( pt1.length == pt2.length ); return sqrt( zip(pt1, pt2).reduce!(function(e) { return (e[1]-e[0]

Re: structs holding on to reference data by pointer

2013-10-31 Thread Maxim Fomin
On Thursday, 31 October 2013 at 18:51:46 UTC, bearophile wrote: Maxim Fomin: You can check whether data is on heap, stack, tls, or just global object by inspecting pointer at runtime. Ideally there would be such function in druntime. This seems like a nice enhancement request for Bugzilla :-

[challenge] Lazy flatten/avoiding type forward reference with map

2013-10-31 Thread David Nadlinger
A while back, somebody raised the topic of implementing a lazy range for traversing/flattening a tree structure on #d. The obvious (in terms of Phobos primitives) solution would be something along the lines of this: --- struct Node(T) { T val; Node!T[] children; } auto flatten(T)(Node!T

Intelligent Scope Hierarchy

2013-10-31 Thread Stretto
Hi, I'm new to D and stumbled on the new allocators thread. In the help there is code like auto buffer = Mallocator.it.allocate(1024 * 1024 * 4); scope(exit) Mallocator.it.deallocate(buffer); which seems redundant and error prone. Would it not be possible for allocate to automatically

Re: structs holding on to reference data by pointer

2013-10-31 Thread bearophile
Maxim Fomin: You can check whether data is on heap, stack, tls, or just global object by inspecting pointer at runtime. Ideally there would be such function in druntime. This seems like a nice enhancement request for Bugzilla :-) Are you going to open it? It seems useful for me too. It is

Re: fieldPostBlit - what is wrong with this and workarounds

2013-10-31 Thread Maxim Fomin
On Thursday, 31 October 2013 at 17:22:07 UTC, Daniel Davidson wrote: I'm think you may be correct... but what specifically is incorrect about the language? When I see __fieldPostBlit I get the feeling it is more an implementation issue than the language. __postblit also looks like implementa

Re: structs holding on to reference data by pointer

2013-10-31 Thread Maxim Fomin
On Thursday, 31 October 2013 at 17:34:21 UTC, Daniel Davidson wrote: On Thursday, 31 October 2013 at 16:16:36 UTC, bearophile wrote: That's wrong code, you are escaping a reference to memory (of rc variable) allocated in the stack frame of foo(). The D compiler is not smart enough to recogniz

Re: structs holding on to reference data by pointer

2013-10-31 Thread Daniel Davidson
On Thursday, 31 October 2013 at 16:16:36 UTC, bearophile wrote: That's wrong code, you are escaping a reference to memory (of rc variable) allocated in the stack frame of foo(). The D compiler is not smart enough to recognize the bug. There are optimizations that patch and avoid this bug (lik

Re: fieldPostBlit - what is wrong with this and workarounds

2013-10-31 Thread Daniel Davidson
On Thursday, 31 October 2013 at 15:56:45 UTC, Maxim Fomin wrote: On Thursday, 31 October 2013 at 14:03:28 UTC, Daniel Davidson wrote: Given this code: import plus.tvm.rate_curve; struct T { RateCurve m; } struct S { const(T) rc; } I get this error: Error: mutable method plus.models

Re: structs holding on to reference data by pointer

2013-10-31 Thread Maxim Fomin
On Thursday, 31 October 2013 at 15:11:48 UTC, Daniel Davidson wrote: The following seems to work, but feels like luck. When foo returns rc should be taken off the stack. If I recall, in C++ something like this would crash, but why not here? This ineed runs by luck. In C++ it would not necessar

Re: structs holding on to reference data by pointer

2013-10-31 Thread bearophile
Daniel Davidson: import std.stdio; struct RC { this(this) { data = data.dup; } int[] data; } struct T { const(RC) *rc; void goo() { writeln("Data is ", rc.data); } } T foo() { RC rc = { [1,2,3] }; return T(&rc); } void main() { T t = foo(); t.goo(); } That's wrong code,

Re: fieldPostBlit - what is wrong with this and workarounds

2013-10-31 Thread Maxim Fomin
On Thursday, 31 October 2013 at 14:03:28 UTC, Daniel Davidson wrote: Given this code: import plus.tvm.rate_curve; struct T { RateCurve m; } struct S { const(T) rc; } I get this error: Error: mutable method plus.models.dossier.__unittestL42_1.T.__fieldPostBlit is not callable

Re: fieldPostBlit - what is wrong with this and workarounds

2013-10-31 Thread Daniel Davidson
On Thursday, 31 October 2013 at 14:28:31 UTC, bearophile wrote: Daniel Davidson: I get this error: Error: mutable method plus.models.dossier.__unittestL42_1.T.__fieldPostBlit is not callable using a const object Related: http://d.puremagic.com/issues/show_bug.cgi?id=4867 Bye, bearophile T

structs holding on to reference data by pointer

2013-10-31 Thread Daniel Davidson
The following seems to work, but feels like luck. When foo returns rc should be taken off the stack. If I recall, in C++ something like this would crash, but why not here? import std.stdio; struct RC { this(this) { data = data.dup; } int[] data; } struct T { const(RC) *rc; void goo() {

Re: fieldPostBlit - what is wrong with this and workarounds

2013-10-31 Thread bearophile
Daniel Davidson: I get this error: Error: mutable method plus.models.dossier.__unittestL42_1.T.__fieldPostBlit is not callable using a const object Related: http://d.puremagic.com/issues/show_bug.cgi?id=4867 Bye, bearophile

fieldPostBlit - what is wrong with this and workarounds

2013-10-31 Thread Daniel Davidson
Given this code: import plus.tvm.rate_curve; struct T { RateCurve m; } struct S { const(T) rc; } I get this error: Error: mutable method plus.models.dossier.__unittestL42_1.T.__fieldPostBlit is not callable using a const object Is this fundamentally incorrect? I abandoned i

Re: D / GtkD for SQL Server

2013-10-31 Thread ilya-stromberg
On Sunday, 27 October 2013 at 00:06:35 UTC, John Joyus wrote: On 10/25/2013 04:04 AM, Gary Willoughby wrote: 1). Does D has any support for MSSQL? See here: http://forum.dlang.org/thread/qcxoafwuachwnnwqk...@forum.dlang.org Thanks for the link, but what I meant by MSSQL is Microsoft SQL Se

Re: Cast delegate and functions.

2013-10-31 Thread qznc
On Thursday, 31 October 2013 at 13:12:31 UTC, Wolftein wrote: void delegate(Event) void delegate(T) Where T is a class that inherits Event. I'm trying to cast (void delegate(T)) to (void delegate(Event)) to be able to store them in a map, but when i cast them i get null exeception. Same thin

Cast delegate and functions.

2013-10-31 Thread Wolftein
void delegate(Event) void delegate(T) Where T is a class that inherits Event. I'm trying to cast (void delegate(T)) to (void delegate(Event)) to be able to store them in a map, but when i cast them i get null exeception. Same thing for cast things like this TemplateClass!Plugin TemplateClass

Re: Cast delegate and functions.

2013-10-31 Thread Wolftein
On Thursday, 31 October 2013 at 13:12:31 UTC, Wolftein wrote: void delegate(Event) void delegate(T) Where T is a class that inherits Event. I'm trying to cast (void delegate(T)) to (void delegate(Event)) to be able to store them in a map, but when i cast them i get null exeception. Same thin

Re: UFCS and error messages

2013-10-31 Thread Marco Leise
Am Thu, 31 Oct 2013 11:58:18 +0100 schrieb "Andrea Fontana" : > Check this simple code: > > import std.stdio; > import std.conv; > > bool is_zero(T)(T i) { return to!int(i) == 0; } > > void main() { "0".is_zero.writeln; } > > This code print "true" of course. > > If you replace "to!int(i) ==

Re: UFCS and error messages

2013-10-31 Thread bearophile
Andrea Fontana: Shoudn't "0".is_zero give this error too? Possibly yes. I put this enhancement request in Bugzilla few months ago, but I don't remember its number now. Bye, bearophile

UFCS and error messages

2013-10-31 Thread Andrea Fontana
Check this simple code: import std.stdio; import std.conv; bool is_zero(T)(T i) { return to!int(i) == 0; } void main() { "0".is_zero.writeln; } This code print "true" of course. If you replace "to!int(i) == 0" with "i == 0" compiler gives this error: "Error: no property 'is_zero' for type

Re: howto make a function get types form compile-time-parameters AND from arguments ?

2013-10-31 Thread Uplink_Coder
by changeing T[] makeArray(T,U)(immutable U[] paramArray) into T[] makeArray(T,U)(const U paramArray) if (isAggregateType!(U) || is Array!(U)) everything works perfectly Thanks very much --- Uplink_Coder

Re: std.range.chunk without length

2013-10-31 Thread Stephan Schiffels
On Wednesday, 30 October 2013 at 20:43:54 UTC, qznc wrote: On Wednesday, 30 October 2013 at 00:20:12 UTC, Stephan Schiffels wrote: Hi, I'd like a version of std.range.chunk that does not require the range to have the "length" property. As an example, consider a file that you would like parse

Re: howto make a function get types form compile-time-parameters AND from arguments ?

2013-10-31 Thread John Colvin
On Thursday, 31 October 2013 at 10:18:25 UTC, Uplink_Coder wrote: Maybe I shuold be more specific : for now It's: T[] arr = makeArray!(T,U)([some,instances,of,U]); but I would like it to be: auto arr = makeArray!(T)([some,instances,of,U]); void foo(T,U)(U arg){} int a; foo!(double)(a); //U

Re: new Type[count] takes too much?

2013-10-31 Thread Jonathan M Davis
On Thursday, October 31, 2013 11:16:35 Namespace wrote: > Hm, seems not very performant for a *system* language. But fine, > thanks for your explanation. :) I believe that C's malloc does the same thing. - Jonathan M Davis

Re: howto make a function get types form compile-time-parameters AND from arguments ?

2013-10-31 Thread Uplink_Coder
Maybe I shuold be more specific : for now It's: T[] arr = makeArray!(T,U)([some,instances,of,U]); but I would like it to be: auto arr = makeArray!(T)([some,instances,of,U]);

Re: new Type[count] takes too much?

2013-10-31 Thread Namespace
On Thursday, 31 October 2013 at 10:12:10 UTC, Jonathan M Davis wrote: On Thursday, October 31, 2013 10:59:48 Namespace wrote: On Thursday, 31 October 2013 at 09:48:23 UTC, safety0ff wrote: > On Thursday, 31 October 2013 at 09:15:53 UTC, Namespace > wrote: >> I'm sure we had already this convers

Re: new Type[count] takes too much?

2013-10-31 Thread Jonathan M Davis
On Thursday, October 31, 2013 10:59:48 Namespace wrote: > On Thursday, 31 October 2013 at 09:48:23 UTC, safety0ff wrote: > > On Thursday, 31 October 2013 at 09:15:53 UTC, Namespace wrote: > >> I'm sure we had already this conversation but I don't find the > >> thread. > >> > >> T[] buffer = new T[

Re: Error when trying to compile with --profile.

2013-10-31 Thread Dmitry Olshansky
31-Oct-2013 13:28, bearophile пишет: Wolftein: Using --debug or --release works fine. But when i use --profile i get: c:\Program Files (x86)\DLang\dmd2\windows\bin\..\..\src\phobos\std\path.d(2187): Error: balancedParens is not nothrow c:\Program Files (x86)\DLang\dmd2\windows\bin\..\..\src\p

Re: new Type[count] takes too much?

2013-10-31 Thread Namespace
On Thursday, 31 October 2013 at 09:48:23 UTC, safety0ff wrote: On Thursday, 31 October 2013 at 09:15:53 UTC, Namespace wrote: I'm sure we had already this conversation but I don't find the thread. T[] buffer = new T[N]; assumes more space than stated (in average 2010 elements more. See: http

Re: new Type[count] takes too much?

2013-10-31 Thread Jonathan M Davis
On Thursday, October 31, 2013 10:15:51 Namespace wrote: > I'm sure we had already this conversation but I don't find the > thread. > > T[] buffer = new T[N]; assumes more space than stated (in average > 2010 elements more. See: http://dpaste.dzfl.pl/af92ad22c). It > behaves exactly like reserve an

Re: improving '$' to work with other functions (eg: indexed)

2013-10-31 Thread Jonathan M Davis
On Thursday, October 31, 2013 02:46:32 Timothee Cour wrote: > can we support this and similar use cases ? > > import std.range; > void main(){ > auto a=[1,2,3,4]; > auto b1=a.indexed([0,a.length-1]);//OK > auto b2=a.indexed([0,$-1]);//NG > } Aren't you creating new arrays to pass to indexed

Re: new Type[count] takes too much?

2013-10-31 Thread safety0ff
On Thursday, 31 October 2013 at 09:15:53 UTC, Namespace wrote: I'm sure we had already this conversation but I don't find the thread. T[] buffer = new T[N]; assumes more space than stated (in average 2010 elements more. See: http://dpaste.dzfl.pl/af92ad22c). It behaves exactly like reserve a

howto make a function get a types form compilte-time-parameters AND from the arguments ?

2013-10-31 Thread Uplink_Coder
(this is my first post so please alert me to any breaches of forum etiquette) Hello, I have a problem with a helper function I'm writeting. T[] makeArray(T,U)(immutable U[] paramArray) { T[] result; foreach (param;paramArray) { result ~= T(param); }

improving '$' to work with other functions (eg: indexed)

2013-10-31 Thread Timothee Cour
can we support this and similar use cases ? import std.range; void main(){ auto a=[1,2,3,4]; auto b1=a.indexed([0,a.length-1]);//OK auto b2=a.indexed([0,$-1]);//NG }

Re: new Type[count] takes too much?

2013-10-31 Thread Namespace
On Thursday, 31 October 2013 at 09:27:11 UTC, bearophile wrote: Namespace: T[] buffer = new T[N]; assumes more space than stated (in average 2010 elements more. See: http://dpaste.dzfl.pl/af92ad22c). It behaves exactly like reserve and that is IMO wrong. If I reserve memory with buffer.reser

Re: new Type[count] takes too much?

2013-10-31 Thread bearophile
Namespace: T[] buffer = new T[N]; assumes more space than stated (in average 2010 elements more. See: http://dpaste.dzfl.pl/af92ad22c). It behaves exactly like reserve and that is IMO wrong. If I reserve memory with buffer.reserve(N), I want to have at least N elements. That behaviour is cor

Re: Error when trying to compile with --profile.

2013-10-31 Thread bearophile
Wolftein: Using --debug or --release works fine. But when i use --profile i get: c:\Program Files (x86)\DLang\dmd2\windows\bin\..\..\src\phobos\std\path.d(2187): Error: balancedParens is not nothrow c:\Program Files (x86)\DLang\dmd2\windows\bin\..\..\src\phobos\std\path.d(2188): Error: b

new Type[count] takes too much?

2013-10-31 Thread Namespace
I'm sure we had already this conversation but I don't find the thread. T[] buffer = new T[N]; assumes more space than stated (in average 2010 elements more. See: http://dpaste.dzfl.pl/af92ad22c). It behaves exactly like reserve and that is IMO wrong. If I reserve memory with buffer.reserve(N)