Re: Optional out parameter of function

2013-11-27 Thread Joseph Rushton Wakeling
On 26/11/13 16:44, bearophile wrote: If you want a single function, dropping out you can write: int foo(size_t N)(in int i, int[N] j...) if (N 2) { static if (N == 1) j[0] = i; return i; } That's a nice thought ... ! Thank you. :-)

Re: Optional out parameter of function

2013-11-27 Thread Joseph Rushton Wakeling
On 27/11/13 10:45, bearophile wrote: It's useless code, you can't have ref variadic, sorry. Ack. :-( I just tried it out myself and found the same thing.

Re: Optional out parameter of function

2013-11-27 Thread bearophile
Joseph Rushton Wakeling: That's a nice thought ... ! Thank you. :-) It's useless code, you can't have ref variadic, sorry. Bye, bearophile

Re: Optional out parameter of function

2013-11-27 Thread Jonathan M Davis
On Wednesday, November 27, 2013 10:57:42 Joseph Rushton Wakeling wrote: On 27/11/13 10:45, bearophile wrote: It's useless code, you can't have ref variadic, sorry. Ack. :-( I just tried it out myself and found the same thing. Personally, I think that it's by far the best approach to just

std.format.format() ... ??!!

2013-11-27 Thread Joseph Rushton Wakeling
Hello all, I'm currently messing around in the internals of std.complex (cf. discussion on main mailing list:-). In Complex.toString there is a deprecation message asking the user to use std.format.format(). However, so far as I can tell both via docs and browsing std/format.d there _is_

Re: Optional out parameter of function

2013-11-27 Thread Joseph Rushton Wakeling
On 27/11/13 11:15, Jonathan M Davis wrote: Personally, I think that it's by far the best approach to just do int foo(int i) { int j; return foo(i, j); } It's clean, and I really don't see a big problem with it. Yea, that's really the conclusion I had

Re: Optional out parameter of function

2013-11-27 Thread monarch_dodra
On Wednesday, 27 November 2013 at 10:16:13 UTC, Jonathan M Davis wrote: On Wednesday, November 27, 2013 10:57:42 Joseph Rushton Wakeling wrote: On 27/11/13 10:45, bearophile wrote: It's useless code, you can't have ref variadic, sorry. Ack. :-( I just tried it out myself and found the same

Re: Optional out parameter of function

2013-11-27 Thread Joseph Rushton Wakeling
On 27/11/13 12:14, monarch_dodra wrote: Interesting trick. That said, doing this (should) also mean you can't use foo in a pure context, since it means the caller needs to access the global dummy (although that seems to work right now). Should be OK in a struct/class method context, if dummy

Re: std.format.format() ... ??!!

2013-11-27 Thread evilrat
On Wednesday, 27 November 2013 at 10:39:56 UTC, Joseph Rushton Wakeling wrote: Hello all, I'm currently messing around in the internals of std.complex (cf. discussion on main mailing list:-). In Complex.toString there is a deprecation message asking the user to use std.format.format().

Re: std.format.format() ... ??!!

2013-11-27 Thread Joseph Rushton Wakeling
On 27/11/13 12:17, evilrat wrote: for string formatting use std.string.format, it is like writefln but for strings. Which I normally do. :-) But in this case my question is slightly more specific ...

Re: std.format.format() ... ??!!

2013-11-27 Thread Jonathan M Davis
On Wednesday, November 27, 2013 11:39:48 Joseph Rushton Wakeling wrote: Hello all, I'm currently messing around in the internals of std.complex (cf. discussion on main mailing list:-). In Complex.toString there is a deprecation message asking the user to use std.format.format(). However,

Re: casting as char at CT fail

2013-11-27 Thread bioinfornatics
On Wednesday, 27 November 2013 at 06:34:27 UTC, Philippe Sigaud wrote: Does std.conv.to have a better behavior? http://www.dpaste.dzfl.pl/6a5d8c72 it segfault

Re: casting as char at CT fail

2013-11-27 Thread Shammah Chancellor
On 2013-11-27 06:06:49 +, bioinfornatics said: On Wednesday, 27 November 2013 at 01:22:07 UTC, Shammah Chancellor wrote: On 2013-11-26 23:31:14 +, bioinfornatics said: Hi, this time i have so many question about CT … iws and ibuclaw help me for this. I stuck currently about a cast

Re: Optional out parameter of function

2013-11-27 Thread monarch_dodra
On Wednesday, 27 November 2013 at 11:20:59 UTC, Joseph Rushton Wakeling wrote: On 27/11/13 12:14, monarch_dodra wrote: Interesting trick. That said, doing this (should) also mean you can't use foo in a pure context, since it means the caller needs to access the global dummy (although that

How to correctly deal with unicode strings?

2013-11-27 Thread Gary Willoughby
I've just been reading this article: http://mortoray.com/2013/11/27/the-string-type-is-broken/ and wanted to test if D performed in the same way as he describes, i.e. unicode strings being 'broken' because they are just arrays. Although i understand the difference between code units and code

Re: How to correctly deal with unicode strings?

2013-11-27 Thread Dicebot
D strings have dual nature. They behave as arrays of code units when slicing or accessing .length directly (because of O(1) guarantees for those operations) but all algorithms in standard library work with them as with arrays of dchar: import std.algorithm; import std.range : walkLength,

Re: How to correctly deal with unicode strings?

2013-11-27 Thread monarch_dodra
On Wednesday, 27 November 2013 at 14:48:07 UTC, David Nadlinger wrote: On Wednesday, 27 November 2013 at 14:34:15 UTC, Gary Willoughby wrote: Here i understand what is happening but how could i improve this example to make the expected asserts true? In this specific example you could e.g. use

Re: How to correctly deal with unicode strings?

2013-11-27 Thread Adam D. Ruppe
The normalize function in std.uni helps a lot here (well, it would if it actually compiled, but that's an easy fix, just import std.typecons in your copy of phobos/src/uni.d. It does so already but only in version(unittest)! LOL) dstrings are a bit easier to use too: import std.algorithm;

Re: How to correctly deal with unicode strings?

2013-11-27 Thread monarch_dodra
Beaophile also linked this article: http://forum.dlang.org/thread/nieoqqmidngwoqwnk...@forum.dlang.org On Wednesday, 27 November 2013 at 14:34:15 UTC, Gary Willoughby wrote: I've just been reading this article: http://mortoray.com/2013/11/27/the-string-type-is-broken/ and wanted to test if D

Re: How to correctly deal with unicode strings?

2013-11-27 Thread David Nadlinger
On Wednesday, 27 November 2013 at 14:34:15 UTC, Gary Willoughby wrote: Here i understand what is happening but how could i improve this example to make the expected asserts true? In this specific example you could e.g. use std.uni.normalize, which by default puts the string into NFC, which

Re: std.format.format() ... ??!!

2013-11-27 Thread H. S. Teoh
On Wed, Nov 27, 2013 at 03:30:51AM -0800, Jonathan M Davis wrote: On Wednesday, November 27, 2013 11:39:48 Joseph Rushton Wakeling wrote: Hello all, I'm currently messing around in the internals of std.complex (cf. discussion on main mailing list:-). In Complex.toString there is a

Re: Two Questions about Linking to C libraries

2013-11-27 Thread Craig Dillabaugh
On Wednesday, 27 November 2013 at 07:30:58 UTC, Jacob Carlborg wrote: On 2013-11-27 02:26, Craig Dillabaugh wrote: 2. Once I think my bindings are stable I would like to add them to Deimos or DUB registries. Are there any recommendations for testing bindings? I checked through some other

Re: std.format.format() ... ??!!

2013-11-27 Thread Joseph Rushton Wakeling
On 27/11/13 16:14, H. S. Teoh wrote: And that would be my fault. I believe it was one of my pulls that contained that wrong doc. Anybody care to submit a pull to fix that? :-) I'll take care of it. I'm working on an Imaginary struct to complement std.complex.Complex so it's trivial to make

template operator overload

2013-11-27 Thread Namespace
Just out of curiosity: Is it possible to call an overloaded operator with a template type? import std.stdio; struct A { void opIndex(T)(size_t index) { } } void main() { A a; a.opIndex!int(0); // [1] a!int[0]; // [2] } [1]

Re: std.format.format() ... ??!!

2013-11-27 Thread monarch_dodra
On Wednesday, 27 November 2013 at 15:54:48 UTC, Joseph Rushton Wakeling wrote: On 27/11/13 16:14, H. S. Teoh wrote: And that would be my fault. I believe it was one of my pulls that contained that wrong doc. Anybody care to submit a pull to fix that? :-) I'll take care of it. I'm working on

Re: template operator overload

2013-11-27 Thread Shammah Chancellor
On 2013-11-27 16:07:50 +, Namespace said: Just out of curiosity: Is it possible to call an overloaded operator with a template type? import std.stdio; struct A { void opIndex(T)(size_t index) { } } void main() { A a; a.opIndex!int(0);

Re: Optional out parameter of function

2013-11-27 Thread Joseph Rushton Wakeling
On 27/11/13 15:05, monarch_dodra wrote: That wouldn't work, because you'd need this to refer said dummy variable. Even if it worked, you'd bloat all instances of your struct/class just for dummy data :/ I'm not saying it's a GOOD idea. :-P

Re: template operator overload

2013-11-27 Thread Namespace
On Wednesday, 27 November 2013 at 17:25:49 UTC, Shammah Chancellor wrote: On 2013-11-27 16:07:50 +, Namespace said: Just out of curiosity: Is it possible to call an overloaded operator with a template type? import std.stdio; struct A { void opIndex(T)(size_t index) {

Re: std.format.format() ... ??!!

2013-11-27 Thread Joseph Rushton Wakeling
On 27/11/13 17:38, monarch_dodra wrote: If what you are doing is non-trivial though, it's better to submit two different pulls for it. Understood. Pull request for the ddoc/deprecation message fix: https://github.com/D-Programming-Language/phobos/pull/1730

Re: template operator overload

2013-11-27 Thread Namespace
On Wednesday, 27 November 2013 at 17:47:13 UTC, bearophile wrote: Namespace: void main() { A a; a.opIndex!int(0); // [1] a!int[0]; // [2] } [1] works, but [2] fails. How can I call opIndex with bracket syntax and a typename? Or is this not possible? I think

Initialization of mutable struct by immutable struct

2013-11-27 Thread Uranuz
It's may be conceptual question. For example I want to create immutable struct instance in module scope like a global default value. But then I need to make mutable copy of this global struct variable in order to init some class instance with it (for example). Main requirement is to do this

Re: std.format.format() ... ??!!

2013-11-27 Thread Joseph Rushton Wakeling
On 27/11/13 18:55, Joseph Rushton Wakeling wrote: Understood. Pull request for the ddoc/deprecation message fix: https://github.com/D-Programming-Language/phobos/pull/1730 Thanks for the quick merge. std.complex.Imaginary to follow :-)

Re: BinaryHeap

2013-11-27 Thread Agustin
On Thursday, 7 November 2013 at 14:31:27 UTC, Agustin wrote: On Thursday, 7 November 2013 at 12:29:44 UTC, bearophile wrote: Agustin: no property 'popFront' for type 'BinaryHeap!(uint[])' Try to use front and removeFront (I don't know why there is removeFront instead of popFront). Bye,

Re: std.format.format() ... ??!!

2013-11-27 Thread Jonathan M Davis
On Wednesday, November 27, 2013 21:12:07 Joseph Rushton Wakeling wrote: On 27/11/13 18:55, Joseph Rushton Wakeling wrote: Understood. Pull request for the ddoc/deprecation message fix: https://github.com/D-Programming-Language/phobos/pull/1730 Thanks for the quick merge.

Re: std.format.format() ... ??!!

2013-11-27 Thread Joseph Rushton Wakeling
On 27/11/13 23:07, Jonathan M Davis wrote: I don't know... Is it actually possible merge imaginary code? ;) Yes, but the lines run up and down the screen ;-)

Re: std.format.format() ... ??!!

2013-11-27 Thread H. S. Teoh
On Wed, Nov 27, 2013 at 05:07:29PM -0500, Jonathan M Davis wrote: On Wednesday, November 27, 2013 21:12:07 Joseph Rushton Wakeling wrote: On 27/11/13 18:55, Joseph Rushton Wakeling wrote: Understood. Pull request for the ddoc/deprecation message fix:

Re: casting as char at CT fail

2013-11-27 Thread Kenji Hara
On Tuesday, 26 November 2013 at 23:31:16 UTC, bioinfornatics wrote: Hi, this time i have so many question about CT … iws and ibuclaw help me for this. I stuck currently about a cast at CT - http://www.dpaste.dzfl.pl/1a28a22c it seem this should works but not… So if you confirm maybe a report

Re: Initialization of mutable struct by immutable struct

2013-11-27 Thread Uranuz
In addition to my letter I wrote some test code following the message. I found out that I can use copy constructor signature: this(immutable(this)), to get a mutable copy of immutable struct. But this is not working with this(const(this)). My thoughts were that if I would define some method

Function literal bug?

2013-11-27 Thread Sergei Nosov
Hi! This is kind of bug report/question. I'm running Ubuntu 12.04 (x64), DMD v2.064.2 and have the following code: T identity(T)(T e) { return e; } struct S(alias Func) { void call() { import std.stdio; writeln(Func(string).length); } } static struct S1 {