Re: Converting multiple inheritance code into C ++ for D language

2017-02-17 Thread Brian Rogoff via Digitalmars-d-learn
On Friday, 17 February 2017 at 23:24:57 UTC, Nicholas Wilson wrote: Something like this would be a goods use for struct multiple alias this, except that we haven't implemented that yet unfortunately. What's the deal with that? It seems someone made progress on this issue 2 years ago and then

Re: Converting multiple inheritance code into C ++ for D language

2017-02-17 Thread Jean Cesar via Digitalmars-d-learn
On Friday, 17 February 2017 at 23:31:41 UTC, Adam D. Ruppe wrote: On Friday, 17 February 2017 at 23:11:25 UTC, Jean Cesar wrote: so I changed the code to use interface but how would I do so I could use the constructor in the same way as such a C ++ code? Interfaces + mixin templates give you

Re: Converting multiple inheritance code into C ++ for D language

2017-02-17 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 17 February 2017 at 23:11:25 UTC, Jean Cesar wrote: so I changed the code to use interface but how would I do so I could use the constructor in the same way as such a C ++ code? Interfaces + mixin templates give you something very similar to multiple inheritance. You can have named

Re: Converting multiple inheritance code into C ++ for D language

2017-02-17 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 17 February 2017 at 23:11:25 UTC, Jean Cesar wrote: import std.stdio; import std.string; I've been reading a bit about multi-inheritance in D, but I have to use interface like C # to use multiple inheritance, but I have the code in C ++ that I've been testing to understand how it

Converting multiple inheritance code into C ++ for D language

2017-02-17 Thread Jean Cesar via Digitalmars-d-learn
import std.stdio; import std.string; I've been reading a bit about multi-inheritance in D, but I have to use interface like C # to use multiple inheritance, but I have the code in C ++ that I've been testing to understand how it would be possible to implement multi-inheritance constructor

Re: Error reading char in read

2017-02-17 Thread Jean Cesar via Digitalmars-d-learn
On Friday, 17 February 2017 at 21:34:16 UTC, ag0aep6g wrote: On 02/17/2017 09:24 PM, Ali Çehreli wrote: It's the Unicode character "U+FFFD REPLACEMENT CHARACTER", which is represented by 2 chars in D. It takes 3 `char`s to represent U+FFFD: void main() { import std.stdio;

Re: Error reading char in read

2017-02-17 Thread ag0aep6g via Digitalmars-d-learn
On 02/17/2017 09:24 PM, Ali Çehreli wrote: It's the Unicode character "U+FFFD REPLACEMENT CHARACTER", which is represented by 2 chars in D. It takes 3 `char`s to represent U+FFFD: void main() { import std.stdio; writeln("\uFFFD".length); /* prints "3" */ }

Re: Strange behaviour of rdmd vs. dmd concerning main function

2017-02-17 Thread ag0aep6g via Digitalmars-d-learn
On 02/17/2017 07:41 PM, berni wrote: The command that works is dmd a.d b.o where b.o is a precompiled c file, similar to https://github.com/dlang/druntime/blob/master/src/core/stdc/errno.c When using rdmd it doesn't work anymore. When I make rdmd --chatty, I can find the reason: b.o is

Re: Error reading char in read

2017-02-17 Thread Ali Çehreli via Digitalmars-d-learn
On 02/17/2017 12:05 PM, wiki wrote: > So I executed it here anyway but still it presents arbitrary characters > in the char .. Right. char[50] is not suitable for user interaction like that. Use string, char[], etc. > What I thought was to create a reader where I could receive, > Char,

Re: scope with if

2017-02-17 Thread Profile Anaysis via Digitalmars-d-learn
On Friday, 17 February 2017 at 20:06:19 UTC, berni wrote: I wonder if it's possible to do something like this: import std.stdio; void main(string[] args) { if (args[1]=="a") { write("A"); scope (exit) write("B"); } write("C"); } I expected the output to be ACB not

scope with if

2017-02-17 Thread berni via Digitalmars-d-learn
I wonder if it's possible to do something like this: import std.stdio; void main(string[] args) { if (args[1]=="a") { write("A"); scope (exit) write("B"); } write("C"); } I expected the output to be ACB not ABC. I understand, that the scope ends at the end of the

Re: Error reading char in read

2017-02-17 Thread wiki via Digitalmars-d-learn
On Friday, 17 February 2017 at 18:57:55 UTC, Ali Çehreli wrote: On 02/17/2017 07:48 AM, Jean Cesar wrote: import std.stdio; import std.string; auto read(C)(ref C c, char[80] message) if (isSomeChar!C) { writef("\n\t%s: ", message); c = strip(readf()); readf(" %s", ); return c;

Re: how to pass stderr to core.stdc.stdio.fileno

2017-02-17 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 17 February 2017 at 19:36:50 UTC, berni wrote: What I didn't understand was that large box below write in stdio. Maybe, it's because I'm not familiar with templates yet. That's the function signature, listing the arguments, types, etc. On write, it is mostly empty, write is

Re: how to pass stderr to core.stdc.stdio.fileno

2017-02-17 Thread berni via Digitalmars-d-learn
On Friday, 17 February 2017 at 19:16:44 UTC, Adam D. Ruppe wrote: Yes, that is my documentation fork, it has a search feature if you do dpldocs.info/some_term and it tries to be easier to read and navigate, let me know how you like it! What I've seen so far, looks quite good. What I didn't

Re: Error reading char in read

2017-02-17 Thread Ali Çehreli via Digitalmars-d-learn
On 02/17/2017 07:48 AM, Jean Cesar wrote: import std.stdio; import std.string; auto read(C)(ref C c, char[80] message) if (isSomeChar!C) { writef("\n\t%s: ", message); c = strip(readf()); readf(" %s", ); return c; } void main() { char[50] message; read(message,"Digite Seu

Re: how to pass stderr to core.stdc.stdio.fileno

2017-02-17 Thread berni via Digitalmars-d-learn
On Friday, 17 February 2017 at 16:08:11 UTC, Adam D. Ruppe wrote: Try fileno(core.stdc.stdio.stderr); to force it to use the C stderr object instead of the D one. Alternatively, fileno(stderr.getFP()) should do it too. http://dpldocs.info/experimental-docs/std.stdio.File.getFP.html Many

Re: Strange behaviour of rdmd vs. dmd concerning main function

2017-02-17 Thread berni via Digitalmars-d-learn
Something similar happend now, but this time it works with dmd and rdmd produces the error: The command that works is dmd a.d b.o where b.o is a precompiled c file, similar to https://github.com/dlang/druntime/blob/master/src/core/stdc/errno.c When using rdmd it doesn't work anymore. When

Re: how to pass stderr to core.stdc.stdio.fileno

2017-02-17 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 17 February 2017 at 16:02:39 UTC, berni wrote: int no = fileno(stderr); Try fileno(core.stdc.stdio.stderr); to force it to use the C stderr object instead of the D one. Alternatively, fileno(stderr.getFP()) should do it too.

how to pass stderr to core.stdc.stdio.fileno

2017-02-17 Thread berni via Digitalmars-d-learn
The following code doesn't work: int no = fileno(stderr); The error message is: test.d(7): Error: function core.stdc.stdio.fileno (shared(_IO_FILE)*) is not callable using argument types (File) How can I cast stderr to something, that fileno() accepts?

Error reading char in read

2017-02-17 Thread Jean Cesar via Digitalmars-d-learn
import std.stdio; import std.string; auto read(C)(ref C c, char[80] message) if (isSomeChar!C) { writef("\n\t%s: ", message); c = strip(readf()); readf(" %s", ); return c; } void main() { char[50] message; read(message,"Digite Seu nome: "); writeln(message); } estou

Re: Copying and moving directories

2017-02-17 Thread Chris via Digitalmars-d-learn
On Friday, 17 February 2017 at 11:40:35 UTC, Jonathan M Davis wrote: Well, there's a _long_ history of it being called rename on POSIX systems, and since the D function is a simple wrapper around rename, it makes sense that it's called rename, much as I agree that the name isn't the best for

Re: A bug?

2017-02-17 Thread bauss via Digitalmars-d-learn
On Wednesday, 15 February 2017 at 19:56:31 UTC, berni wrote: On Wednesday, 15 February 2017 at 16:11:36 UTC, drug wrote: No, you recursively call main() and get segfault (due to stack overflow) as expected I thought, that an stack overflow leeds to an exception. But that's not true, as I now

Re: Copying and moving directories

2017-02-17 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, February 17, 2017 11:00:30 Chris via Digitalmars-d-learn wrote: > On Thursday, 16 February 2017 at 17:06:30 UTC, Jonathan M Davis > > wrote: > > Well, there's zero difference between renaming the file or > > directory and moving it. It's simply a difference in name. > > rename actually

Re: Copying and moving directories

2017-02-17 Thread Chris via Digitalmars-d-learn
On Thursday, 16 February 2017 at 17:06:30 UTC, Jonathan M Davis wrote: Well, there's zero difference between renaming the file or directory and moving it. It's simply a difference in name. rename actually comes from POSIX, where rename is used in C code, and mv is used in the shell. So, I

Re: Copying and moving directories

2017-02-17 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, February 17, 2017 08:48:03 Kagamin via Digitalmars-d-learn wrote: > On Thursday, 16 February 2017 at 17:06:30 UTC, Jonathan M Davis > > wrote: > > Well, there's zero difference between renaming the file or > > directory and moving it. It's simply a difference in name. > > Isn't there a

Re: Copying and moving directories

2017-02-17 Thread Kagamin via Digitalmars-d-learn
On Thursday, 16 February 2017 at 17:06:30 UTC, Jonathan M Davis wrote: Well, there's zero difference between renaming the file or directory and moving it. It's simply a difference in name. Isn't there a difference? I though move("/path/dir1","dir2") moves folder to current directory and