Re: Operator overloading through UFCS doesn't work

2016-05-25 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, May 25, 2016 23:31:18 Elie Morisse via Digitalmars-d-learn wrote: > On Wednesday, 25 May 2016 at 21:50:06 UTC, Jonathan M Davis wrote: > > It's not an overloaded operator anymore at that point, and that > > definitely fails to work for generic code, since not all > > operators are ov

Re: import in mixin template

2016-05-25 Thread Era Scarecrow via Digitalmars-d-learn
On Thursday, 26 May 2016 at 05:20:25 UTC, vitus wrote: Why 'alias wln1 = writeln;' doesnt't work but 'alias wln2 = std.stdio.writeln;' work when import is not static? Why 'wln2("test");' work but 'std.stdio.writeln("test");' doesn't? (changing import to static import doesn't change anything)

Re: Is there a way to clear an OutBuffer?

2016-05-25 Thread Jon Degenhardt via Digitalmars-d-learn
On Wednesday, 25 May 2016 at 19:42:43 UTC, Gary Willoughby wrote: On Monday, 23 May 2016 at 03:03:12 UTC, Jon Degenhardt wrote: Currently not possible. Enhancement request perhaps? Looking at the implementation, setting its 'offset' member seems to work. Based on example from documentation:

import in mixin template

2016-05-25 Thread vitus via Digitalmars-d-learn
Code: mixin template MIXIN(){ import std.stdio; alias m = writeln; //OK } class CLASS{ mixin MIXIN; alias wln1 = writeln; //Error: 'writeln' is not defined, perhaps you need to import std.stdio; ? alias wln2 = std.stdio.writeln; //OK void test(){

Re: Operator overloading through UFCS doesn't work

2016-05-25 Thread Elie Morisse via Digitalmars-d-learn
On Wednesday, 25 May 2016 at 21:50:06 UTC, Jonathan M Davis wrote: It's not an overloaded operator anymore at that point, and that definitely fails to work for generic code, since not all operators are overloaded operators. Free functions don't have that problem. Sorry to reiterate the previo

Re: Operator overloading through UFCS doesn't work

2016-05-25 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, May 25, 2016 15:46:23 Elie Morisse via Digitalmars-d-learn wrote: > On Tuesday, 24 May 2016 at 23:43:46 UTC, Jonathan M Davis wrote: > > On Tuesday, May 24, 2016 23:19:32 Elie Morisse via > > > > Digitalmars-d-learn wrote: > >> On Saturday, 13 October 2012 at 22:58:56 UTC, Timon Gehr

Re: Is there a way to clear an OutBuffer?

2016-05-25 Thread Gary Willoughby via Digitalmars-d-learn
On Monday, 23 May 2016 at 03:03:12 UTC, Jon Degenhardt wrote: Currently not possible. Enhancement request perhaps? Looking at the implementation, setting its 'offset' member seems to work. Based on example from documentation: import std.outbuffer; void main() { OutBuffer b = new OutBuffe

Re: What's wrong with my usage of std.algorithm.map in this code example?

2016-05-25 Thread Era Scarecrow via Digitalmars-d-learn
On Wednesday, 25 May 2016 at 13:27:28 UTC, Chris wrote: Why can the tuple be iterated with foreach, as in my quick fix, and indexed with tuple[0..], but is not accepted as a range? What are the differences? Is there a way to rangify a tuple? The tuple is identified/used at compile-time, as su

Re: std.conv.parse not accepting ByCodeUnitImpl

2016-05-25 Thread Jack Stouffer via Digitalmars-d-learn
On Wednesday, 25 May 2016 at 18:43:05 UTC, Steven Schveighoffer wrote: If parse can do it, to should as well. I think it's a question of how the template constraints are done. Please file an issue. Found this: https://issues.dlang.org/show_bug.cgi?id=15800

Re: std.conv.parse not accepting ByCodeUnitImpl

2016-05-25 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/25/16 2:23 PM, Jack Stouffer wrote: On Wednesday, 25 May 2016 at 16:53:30 UTC, Steven Schveighoffer wrote: to should work wherever parse works (in fact, whenever you call to!someType(someString), I believe it just forwards to parse). This is not the case; to doesn't work with ranges:

Re: std.conv.parse not accepting ByCodeUnitImpl

2016-05-25 Thread Jack Stouffer via Digitalmars-d-learn
On Wednesday, 25 May 2016 at 16:53:30 UTC, Steven Schveighoffer wrote: to should work wherever parse works (in fact, whenever you call to!someType(someString), I believe it just forwards to parse). This is not the case; to doesn't work with ranges: auto str = "1234567".byCodeUnit; auto

Re: stdout.flush

2016-05-25 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/25/16 2:09 PM, Charles Hixson via Digitalmars-d-learn wrote: Using: dmd --version DMD64 D Compiler v2.071.0 on debian Linux, and importing: importstd.stdio; the line: flush(); causes: nt.d(29): Error: undefined identifier 'flush', did you mean function 'fflush'? This appears solv

stdout.flush

2016-05-25 Thread Charles Hixson via Digitalmars-d-learn
Using: dmd --version DMD64 D Compiler v2.071.0 on debian Linux, and importing: importstd.stdio; the line: flush(); causes: nt.d(29): Error: undefined identifier 'flush', did you mean function 'fflush'? This appears solved by doing stdout.flush; (compiles, but I'm still writing the c

Re: std.conv.parse not accepting ByCodeUnitImpl

2016-05-25 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/25/16 12:10 PM, Jack Stouffer wrote: On Wednesday, 25 May 2016 at 15:34:45 UTC, Steven Schveighoffer wrote: parse consumes data from the string as it goes. I know that, I'm asking why. This disallows the natural range chaining and forces you to save to a variable before calling parse even

Re: std.conv.parse not accepting ByCodeUnitImpl

2016-05-25 Thread Jack Stouffer via Digitalmars-d-learn
On Wednesday, 25 May 2016 at 15:34:45 UTC, Steven Schveighoffer wrote: parse consumes data from the string as it goes. I know that, I'm asking why. This disallows the natural range chaining and forces you to save to a variable before calling parse even though the function works just as well w

Re: Operator overloading through UFCS doesn't work

2016-05-25 Thread Elie Morisse via Digitalmars-d-learn
On Tuesday, 24 May 2016 at 23:43:46 UTC, Jonathan M Davis wrote: On Tuesday, May 24, 2016 23:19:32 Elie Morisse via Digitalmars-d-learn wrote: On Saturday, 13 October 2012 at 22:58:56 UTC, Timon Gehr wrote: > Afaik free-function operator overloads (but not in the > context of UFCS) were conside

Re: full copies on assignment

2016-05-25 Thread Marc Schütz via Digitalmars-d-learn
On Tuesday, 24 May 2016 at 20:58:11 UTC, John Nixon wrote: On Tuesday, 24 May 2016 at 15:17:37 UTC, Adam D. Ruppe wrote: On Tuesday, 24 May 2016 at 14:29:53 UTC, John Nixon wrote: This naively doesn’t seem right because the RHS of an assignment should not be altered by it. It's because the ch

Re: std.conv.parse not accepting ByCodeUnitImpl

2016-05-25 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/25/16 11:15 AM, Jack Stouffer wrote: On Tuesday, 24 May 2016 at 05:01:39 UTC, ag0aep6g wrote: You're missing that `parse`'s parameter is `ref`. Do you what the rationale behind this is? I just removed the ref from the floating point from input range overload and it works fine for strings.

Re: std.conv.parse not accepting ByCodeUnitImpl

2016-05-25 Thread Jack Stouffer via Digitalmars-d-learn
On Tuesday, 24 May 2016 at 05:01:39 UTC, ag0aep6g wrote: You're missing that `parse`'s parameter is `ref`. Do you what the rationale behind this is? I just removed the ref from the floating point from input range overload and it works fine for strings.

Re: Newbie to D, first impressions and feedback on the 5 (and more) first minutes.

2016-05-25 Thread Seb via Digitalmars-d-learn
On Wednesday, 25 May 2016 at 11:24:44 UTC, Russel Winder wrote: […] [...] I thought DMD and Phobos were separate. Given proper versioning (which I think we have) there should be no problem. The problem are parts like std.math which contain compiler-specific optimizations. That being said I

Re: What's wrong with my usage of std.algorithm.map in this code example?

2016-05-25 Thread Chris via Digitalmars-d-learn
On Wednesday, 25 May 2016 at 14:48:14 UTC, ag0aep6g wrote: On 05/25/2016 04:39 PM, Chris wrote: I see. Maybe it would be worth adding a wrapper to typecons.Tuple or std.range that helps to rangify tuples. std.range.only is that wrapper. Duh! Of course! :-) I cannot think of any use case r

Re: OpenGL with D tutorials

2016-05-25 Thread Seb via Digitalmars-d-learn
On Wednesday, 25 May 2016 at 03:09:02 UTC, dvrein wrote: On Sunday, 22 May 2016 at 21:21:33 UTC, Rishub Nagpal wrote: On Sunday, 22 May 2016 at 12:13:07 UTC, ixid wrote: What is the best OpenGL tutorial with D to use? I've tried to use d-gamedev-intro and opengl-tutorials and seem to get error

Re: What's wrong with my usage of std.algorithm.map in this code example?

2016-05-25 Thread ag0aep6g via Digitalmars-d-learn
On 05/25/2016 04:39 PM, Chris wrote: I see. Maybe it would be worth adding a wrapper to typecons.Tuple or std.range that helps to rangify tuples. std.range.only is that wrapper. I cannot think of any use case right now. I never needed this and in the example that started this thread, it would

Re: What's wrong with my usage of std.algorithm.map in this code example?

2016-05-25 Thread ag0aep6g via Digitalmars-d-learn
On 05/25/2016 03:27 PM, Chris wrote: Why can the tuple be iterated with foreach, as in my quick fix, and indexed with tuple[0..], but is not accepted as a range? What are the differences? popFront doesn't make sense with a tuple (aka expression list). When you remove the first element of a tup

Re: What's wrong with my usage of std.algorithm.map in this code example?

2016-05-25 Thread Chris via Digitalmars-d-learn
On Wednesday, 25 May 2016 at 14:32:11 UTC, ag0aep6g wrote: On 05/25/2016 03:27 PM, Chris wrote: Why can the tuple be iterated with foreach, as in my quick fix, and indexed with tuple[0..], but is not accepted as a range? What are the differences? popFront doesn't make sense with a tuple (aka

Re: What's wrong with my usage of std.algorithm.map in this code example?

2016-05-25 Thread Chris via Digitalmars-d-learn
On Wednesday, 25 May 2016 at 13:27:28 UTC, Chris wrote: On Wednesday, 25 May 2016 at 12:08:20 UTC, Steven Schveighoffer wrote: On 5/25/16 6:24 AM, pineapple wrote: On Tuesday, 24 May 2016 at 20:18:34 UTC, Steven Schveighoffer wrote: Slice assignment from range to array is not supported. In yo

Re: Newbie to D, first impressions and feedback on the 5 (and more) first minutes.

2016-05-25 Thread qznc via Digitalmars-d-learn
On Wednesday, 25 May 2016 at 09:41:10 UTC, Russel Winder wrote: I do not really have the proper resources to host such a repository and because of this I have not built one. I know I should rather than just moan, but Debian is my main platform and that is covered. Yes, this is the core proble

Re: Template mixin Instantiation

2016-05-25 Thread Jorge Lima via Digitalmars-d-learn
Hi Adam, Thanks for your explanation. On Wednesday, 25 May 2016 at 12:15:17 UTC, Adam D. Ruppe wrote: On Wednesday, 25 May 2016 at 07:45:32 UTC, Jorge Lima wrote: I can understand that array1 is not expanded to its value representation in the first call, but why is then when passed as an argu

Re: What's wrong with my usage of std.algorithm.map in this code example?

2016-05-25 Thread Chris via Digitalmars-d-learn
On Wednesday, 25 May 2016 at 12:08:20 UTC, Steven Schveighoffer wrote: On 5/25/16 6:24 AM, pineapple wrote: On Tuesday, 24 May 2016 at 20:18:34 UTC, Steven Schveighoffer wrote: Slice assignment from range to array is not supported. In your example, I'm curious why the efforts to specify the t

Re: Is there an easy way to convert a pointer to malloc'd memory to an array?

2016-05-25 Thread Era Scarecrow via Digitalmars-d-learn
On Wednesday, 25 May 2016 at 12:06:58 UTC, Adam D. Ruppe wrote: Slicing and indexing are both allowed (actually, that's a way to disable bounds checking on an individual expression, see tip: http://arsdnet.net/this-week-in-d/dec-06.html ) on pointers, though it isn't considered @safe. Be care

Re: Newbie to D, first impressions and feedback on the 5 (and more) first minutes.

2016-05-25 Thread Guillaume Piolat via Digitalmars-d-learn
On Tuesday, 24 May 2016 at 15:27:45 UTC, llaine wrote: The only bad point here is that I can't find a "Effective D" page. A document that gives tips for writing clear, idiomatic D code. A must read for any new D programmer. It augments the tour and the language specification, both of which sh

Re: Template mixin Instantiation

2016-05-25 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 25 May 2016 at 07:45:32 UTC, Jorge Lima wrote: I can understand that array1 is not expanded to its value representation in the first call, but why is then when passed as an argument to the Constructor of the literal argument in the second call? Am I missing something obvious? It

Re: Is there a way to make a class variable visible but constant to outsiders, but changeable (mutable) to the class itself?

2016-05-25 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/24/16 6:47 PM, Jonathan M Davis via Digitalmars-d-learn wrote: On Tuesday, May 24, 2016 18:28:44 Meta via Digitalmars-d-learn wrote: On Tuesday, 24 May 2016 at 15:07:55 UTC, Jonathan M Davis wrote: On Tuesday, May 24, 2016 10:10:16 Steven Schveighoffer via Digitalmars-d-learn wrote: A wh

Re: What's wrong with my usage of std.algorithm.map in this code example?

2016-05-25 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/25/16 6:24 AM, pineapple wrote: On Tuesday, 24 May 2016 at 20:18:34 UTC, Steven Schveighoffer wrote: Slice assignment from range to array is not supported. In your example, I'm curious why the efforts to specify the type? I think it would work with just saying auto itemstrings = ... I s

Re: Is there an easy way to convert a pointer to malloc'd memory to an array?

2016-05-25 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 24 May 2016 at 19:52:17 UTC, Era Scarecrow wrote: You can do that??? I thought slices weren't allowed on raw pointers. You just blew my mind away! Slicing and indexing are both allowed (actually, that's a way to disable bounds checking on an individual expression, see tip: http:/

Re: What's wrong with my usage of std.algorithm.map in this code example?

2016-05-25 Thread Chris via Digitalmars-d-learn
On Wednesday, 25 May 2016 at 11:14:26 UTC, FreeSlave wrote: Works with 'only', 'array' and static array slicing. import std.algorithm : map; import std.range : only; import std.conv : to; import std.stdio : writeln; import std.string : join; import std.array : array; string test(Args...)(in Ar

Re: What's wrong with my usage of std.algorithm.map in this code example?

2016-05-25 Thread Chris via Digitalmars-d-learn
On Wednesday, 25 May 2016 at 10:24:19 UTC, pineapple wrote: On Tuesday, 24 May 2016 at 20:18:34 UTC, Steven Schveighoffer wrote: Slice assignment from range to array is not supported. In your example, I'm curious why the efforts to specify the type? I think it would work with just saying auto

Re: Newbie to D, first impressions and feedback on the 5 (and more) first minutes.

2016-05-25 Thread Russel Winder via Digitalmars-d-learn
On Wed, 2016-05-25 at 10:18 +, Richard Delorme via Digitalmars-d- learn wrote: […] > The main problem is that ldc, dmd and gdc cannot share the same  > runtime library yet. So the three compilers do not cohabit well  > in a system wide environment. The manual installation puts each  > compiler

Re: What's wrong with my usage of std.algorithm.map in this code example?

2016-05-25 Thread FreeSlave via Digitalmars-d-learn
On Tuesday, 24 May 2016 at 20:03:14 UTC, pineapple wrote: I would've expected this to work, but instead I get a compile error. Is my syntax wrong? Is this just not a case that map can handle, and I should be doing something else? import std.algorithm : map; import std.conv : to; im

Re: Is there an easy way to convert a pointer to malloc'd memory to an array?

2016-05-25 Thread Marco Leise via Digitalmars-d-learn
Am Tue, 24 May 2016 20:58:14 + schrieb Gary Willoughby : > On Tuesday, 24 May 2016 at 18:43:22 UTC, Adam D. Ruppe wrote: > > On Tuesday, 24 May 2016 at 18:42:41 UTC, Gary Willoughby wrote: > >> I have a T* pointer to the start of a malloc'd chunk of > >> memory, the type T and the number of

Re: What's wrong with my usage of std.algorithm.map in this code example?

2016-05-25 Thread pineapple via Digitalmars-d-learn
On Tuesday, 24 May 2016 at 20:18:34 UTC, Steven Schveighoffer wrote: Slice assignment from range to array is not supported. In your example, I'm curious why the efforts to specify the type? I think it would work with just saying auto itemstrings = ... -Steve I still get an error if I use a

Re: Newbie to D, first impressions and feedback on the 5 (and more) first minutes.

2016-05-25 Thread Richard Delorme via Digitalmars-d-learn
On Wednesday, 25 May 2016 at 09:41:10 UTC, Russel Winder wrote: D is a problem on Fedora: dmd, gdc, and dub are not packaged. ldc is so there is that – many would argue that having ldc is much more important than dmd or gdc. The main problem is that ldc, dmd and gdc cannot share the same run

Re: Newbie to D, first impressions and feedback on the 5 (and more) first minutes.

2016-05-25 Thread Russel Winder via Digitalmars-d-learn
On Wed, 2016-05-25 at 09:54 +, llaine via Digitalmars-d-learn wrote: > […] > > So in your opinion Debian is the best platform for D development?  > Which IDE/Editor to you use? Use of Debian is not really a D thing , but because of D-Apt Debian is good for D working. I am sure Arch is as well

Re: Newbie to D, first impressions and feedback on the 5 (and more) first minutes.

2016-05-25 Thread llaine via Digitalmars-d-learn
On Wednesday, 25 May 2016 at 09:41:10 UTC, Russel Winder wrote: On Wed, 2016-05-25 at 07:43 +, llaine via Digitalmars-d-learn wrote: […] [...] D is a problem on Fedora: dmd, gdc, and dub are not packaged. ldc is so there is that – many would argue that having ldc is much more important

Re: Newbie to D, first impressions and feedback on the 5 (and more) first minutes.

2016-05-25 Thread Russel Winder via Digitalmars-d-learn
On Wed, 2016-05-25 at 07:43 +, llaine via Digitalmars-d-learn wrote: […] > > Thank your for your answer! Maybe all thoses are Fedora related  > yes :) But I guess that for the moment I have to keep it  > unfortunatly but that's OK, let's try to make dlang great on  > fedora ! D is a problem o

Re: Is there an easy way to convert a pointer to malloc'd memory to an array?

2016-05-25 Thread ZombineDev via Digitalmars-d-learn
On Tuesday, 24 May 2016 at 18:42:41 UTC, Gary Willoughby wrote: I have a T* pointer to the start of a malloc'd chunk of memory, the type T and the number of T's stored in the chunk. Is there an efficient way of converting this information to a D array of type T[] or even T[n]? BTW, the simpl

Re: Newbie to D, first impressions and feedback on the 5 (and more) first minutes.

2016-05-25 Thread ZombineDev via Digitalmars-d-learn
On Tuesday, 24 May 2016 at 15:27:45 UTC, llaine wrote: Hi everybody, As written in the description I'm really new to D, I discovered it a few weeks ago thanks to the D Conf in Berlin. After playing around for couple of days with it, I wanted to share my journey with you guys on several point

Re: Newbie to D, first impressions and feedback on the 5 (and more) first minutes.

2016-05-25 Thread llaine via Digitalmars-d-learn
On Tuesday, 24 May 2016 at 19:32:11 UTC, Seb wrote: On Tuesday, 24 May 2016 at 18:03:17 UTC, cy wrote: https://p0nce.github.io/d-idioms/ I wanted to mention as well, if you like idioms. That guy has some good ideas. On Tuesday, 24 May 2016 at 17:36:45 UTC, Ali Çehreli wrote: Yes, a link from t

Template mixin Instantiation

2016-05-25 Thread Jorge Lima via Digitalmars-d-learn
Can someone explain me why in the following code the alias parameter expands differently for first and second Instantiation? module main; import std.stdio; import std.conv; struct Cascade { this(int a, immutable(Cascade)[] b) { f1 = a; f2 = b; } this(int a) {

Re: Newbie to D, first impressions and feedback on the 5 (and more) first minutes.

2016-05-25 Thread llaine via Digitalmars-d-learn
On Tuesday, 24 May 2016 at 16:17:25 UTC, Daniel Kozak wrote: Dne 24.5.2016 v 17:27 llaine via Digitalmars-d-learn napsal(a): [...] On Archlinux this is even easier than on Mac just sudo yaourt -Sy dlang dub [...] As I said earlier it is fedora who should be blamed here :D [...] Again on