Re: Tuts/Aritcles: Incrementasl C++-to-D conversion?

2018-02-22 Thread Timothee Cour via Digitalmars-d-learn
also related: https://github.com/Syniurge/Calypso/issues/85 (feasibility of extending calypso to do source to source translation (eg C++ => D or C=>D) ) On Thu, Feb 22, 2018 at 12:43 AM, ketmar via Digitalmars-d-learn wrote: > Nick Sabalausky (Abscissa) wrote:

Re: Tuts/Aritcles: Incrementasl C++-to-D conversion?

2018-02-22 Thread ketmar via Digitalmars-d-learn
Nick Sabalausky (Abscissa) wrote: Are there any tutorials or articles out there for "getting started with converting a C++ codebase to D one module at a time?" Or at the very least: tips, tricks, lessions learned, from those who have come before. from my experience (various codebases up to

Re: array/Array: "hard" bounds checking

2018-02-22 Thread bauss via Digitalmars-d-learn
On Thursday, 22 February 2018 at 05:22:19 UTC, TheFlyingFiddle wrote: Eg: uint a = 3; int b = -1; assert(a > b); //No idea what should happen here. This is what happens: assert(cast(int)a > b);

Re: How to use Com object (it comes from other dll) in D? Thanks.

2018-02-22 Thread rikki cattermole via Digitalmars-d-learn
On 23/02/2018 2:12 AM, FrankLike wrote: Hi,everyone,  I want use the Com object (it comes from other dll) in D,but the core.sys.windows.objidl:QueryInterface Fuction not work. For example: import core.sys.windows.windef; import core.sys.windows.basetyps; import core.sys.windows.uuid; import

Re: Understanding the AST...

2018-02-22 Thread joe via Digitalmars-d-learn
On Monday, 12 February 2018 at 08:47:58 UTC, RazvanN wrote: Hi Joe, /SNIP On Tuesday, 6 February 2018 at 12:03:06 UTC, joe wrote: [...] The FuncDeclaration node contains all the information for that. For example, you can access fd.parent to see if the function is declared at top-level (in

Re: How to use Com object (it comes from other dll) in D? Thanks.

2018-02-22 Thread FrankLike via Digitalmars-d-learn
On Thursday, 22 February 2018 at 13:15:11 UTC, rikki cattermole wrote: Reminder classes in D are already references, no need for pointers to them. Thank you,but get the same error. [D CODE] if(lpszLnkFileDir is null) return; HRESULT hr; IShellLink pLink;

Re: Negative index range violation

2018-02-22 Thread joe via Digitalmars-d-learn
On Thursday, 22 February 2018 at 02:41:30 UTC, Steven Schveighoffer wrote: On 2/21/18 7:30 PM, SrMordred wrote: But with a slice negative indexes are never allowed, even on a pointer. youd have to do (c-1)[0 .. 1]; Nice! Thank you both! In D Slice article it says "You can even use

How to use Com object (it comes from other dll) in D? Thanks.

2018-02-22 Thread FrankLike via Digitalmars-d-learn
Hi,everyone, I want use the Com object (it comes from other dll) in D,but the core.sys.windows.objidl:QueryInterface Fuction not work. For example: import core.sys.windows.windef; import core.sys.windows.basetyps; import core.sys.windows.uuid; import core.sys.windows.com; import

Re: Understanding the AST...

2018-02-22 Thread Stefan Koch via Digitalmars-d-learn
On Thursday, 22 February 2018 at 13:21:04 UTC, joe wrote: On Monday, 12 February 2018 at 08:47:58 UTC, RazvanN wrote: [...] Follow up question... Why is *.parent always null? e.g.: extern(C++) class MyVisitor(AST): ParseTimeTransitiveVisitor!AST { override void visit(AST.Import i) {

Re: Understanding the AST...

2018-02-22 Thread RazvanN via Digitalmars-d-learn
On Thursday, 22 February 2018 at 13:21:04 UTC, joe wrote: On Monday, 12 February 2018 at 08:47:58 UTC, RazvanN wrote: Hi Joe, /SNIP On Tuesday, 6 February 2018 at 12:03:06 UTC, joe wrote: [...] The FuncDeclaration node contains all the information for that. For example, you can access

Re: How to use Com object (it comes from other dll) in D? Thanks.

2018-02-22 Thread FrankLike via Digitalmars-d-learn
On Thursday, 22 February 2018 at 13:15:11 UTC, rikki cattermole wrote: On 23/02/2018 2:12 AM, FrankLike wrote: IShellLink* pLink; IPersistFile* ppf; Reminder classes in D are already references, no need for pointers to them. Ok,I delete the pointers ,It's ok! Thank you very

Re: Understanding the AST...

2018-02-22 Thread joe via Digitalmars-d-learn
On Thursday, 22 February 2018 at 13:44:51 UTC, RazvanN wrote: On Thursday, 22 February 2018 at 13:21:04 UTC, joe wrote: [...] Indeed, @Stefan is right. The ParseTimeVisitor only contains information available at parse time. If you are interested in the parent you have 2 options: either (1)

Re: Understanding the AST...

2018-02-22 Thread joe via Digitalmars-d-learn
On Monday, 12 February 2018 at 08:47:58 UTC, RazvanN wrote: Hi Joe, I suggest you watch this video which explains how the parse time visitors work: https://www.youtube.com/watch?v=tK072jcoWv4 . On Tuesday, 6 February 2018 at 12:03:06 UTC, joe wrote: [...] The FuncDeclaration node

Re: array/Array: "hard" bounds checking

2018-02-22 Thread ag0aep6g via Digitalmars-d-learn
On 02/22/2018 10:39 AM, bauss wrote: On Thursday, 22 February 2018 at 05:22:19 UTC, TheFlyingFiddle wrote: Eg: uint a = 3; int b = -1; assert(a > b); //No idea what should happen here. This is what happens: assert(cast(int)a > b); Nope. It's `assert(a > cast(uint)b);`.

Re: How to use strip or stripRight on char[len] ? Thanks.

2018-02-22 Thread FrankLike via Digitalmars-d-learn
On Thursday, 22 February 2018 at 16:59:40 UTC, Adam D. Ruppe wrote: On Thursday, 22 February 2018 at 16:55:14 UTC, FrankLike wrote: It is simply that these functions require a slice so it can resize it and you can't resize a static array. char[100] abc ="aabc"; string aa =

How to use strip or stripRight on char[len] ? Thanks.

2018-02-22 Thread FrankLike via Digitalmars-d-learn
Hi,everyone, How to use strip or stripRight on char[len]? For example: string abcs ="aabc"; auto abcsaa = abcs.stripRight; writeln(abcsaa); writeln("---abcsaa--stripRight ok "); char[100] abc ="aabc"; auto abcaa = ((abc).dup).stripRight; writeln(abcaa); writeln("stripRight

Re: How to use strip or stripRight on char[len] ? Thanks.

2018-02-22 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 22 February 2018 at 17:44:53 UTC, FrankLike wrote: SHGetSpecialFolderPath(NULL,cast(char*)Path.ptr,CSIDL_DESKTOP,0); You don't strip that at all, the function writes a zero-terminated string to the buffer. So either: use the pointer as-is to other C functions, or call the

Re: How to use strip or stripRight on char[len] ? Thanks.

2018-02-22 Thread FrankLike via Digitalmars-d-learn
On Thursday, 22 February 2018 at 16:59:40 UTC, Adam D. Ruppe wrote: On Thursday, 22 February 2018 at 16:55:14 UTC, FrankLike wrote: char[100] abc ="aabc"; auto abcaa = ((abc).dup).stripRight; try: auto abcaa = stripRight(abc[]) Now,I want to get the result: char[100] Path;

Re: How to use strip or stripRight on char[len] ? Thanks.

2018-02-22 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 22 February 2018 at 16:55:14 UTC, FrankLike wrote: char[100] abc ="aabc"; auto abcaa = ((abc).dup).stripRight; try: auto abcaa = stripRight(abc[]) just make sure you do NOT return that abcaa from the function or store it in an object. It still refers to the static array

Re: Tuts/Aritcles: Incrementasl C++-to-D conversion?

2018-02-22 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Feb 22, 2018 at 10:43:24AM +0200, ketmar via Digitalmars-d-learn wrote: > Nick Sabalausky (Abscissa) wrote: > > > Are there any tutorials or articles out there for "getting started > > with converting a C++ codebase to D one module at a time?" Or at the > > very least: tips, tricks,

Re: Negative index range violation

2018-02-22 Thread SrMordred via Digitalmars-d-learn
On Thursday, 22 February 2018 at 02:41:30 UTC, Steven Schveighoffer wrote: Hah! I never thought of doing a slice with negative indexes ;) Maybe is my past of python: arr[-3:] to get the last 3 elements for eg. :)

Re: How to use strip or stripRight on char[len] ? Thanks.

2018-02-22 Thread FrankLike via Digitalmars-d-learn
On Thursday, 22 February 2018 at 17:08:14 UTC, FrankLike wrote: On Thursday, 22 February 2018 at 16:59:40 UTC, Adam D. Ruppe wrote: On Thursday, 22 February 2018 at 16:55:14 UTC, FrankLike wrote: It is simply that these functions require a slice so it can resize it and you can't resize a

Re: Function overloading between modules

2018-02-22 Thread ketmar via Digitalmars-d-learn
JN wrote: same idea? absolutely the same. non-qualified imports (be it template, or function) won't take part in overload resoultion.

Re: Function overloading between modules

2018-02-22 Thread ketmar via Digitalmars-d-learn
JN wrote: Is this expected behaviour? bar.d --- void foo(string s) { } app.d --- import std.stdio; import bar; void foo(int x) { } void main() { foo("hi"); }; === Error: function app.foo (int x) is not callable using argument types (string) yes. this is done so unqualified won't

Re: Function overloading between modules

2018-02-22 Thread JN via Digitalmars-d-learn
On Thursday, 22 February 2018 at 21:19:12 UTC, ketmar wrote: yes. this is done so unqualified won't silently "steal" your functions. this can cause some unexpected (and hard to find) bugs. if you want it to work, you can either do qualified import import bar : foo; or manuall

Function overloading between modules

2018-02-22 Thread JN via Digitalmars-d-learn
Is this expected behaviour? bar.d --- void foo(string s) { } app.d --- import std.stdio; import bar; void foo(int x) { } void main() { foo("hi"); }; === Error: function app.foo (int x) is not callable using argument types (string)

Re: array/Array: "hard" bounds checking

2018-02-22 Thread TheFlyingFiddle via Digitalmars-d-learn
On Thursday, 22 February 2018 at 12:50:43 UTC, ag0aep6g wrote: On 02/22/2018 10:39 AM, bauss wrote: On Thursday, 22 February 2018 at 05:22:19 UTC, TheFlyingFiddle wrote: Eg: uint a = 3; int b = -1; assert(a > b); //No idea what should happen here. This is what happens: assert(cast(int)a

Re: How to use strip or stripRight on char[len] ? Thanks.

2018-02-22 Thread FrankLike via Digitalmars-d-learn
On Thursday, 22 February 2018 at 18:02:11 UTC, Adam D. Ruppe wrote: You don't strip that at all, the function writes a zero-terminated string to the buffer. Thank you very much ! I forgot it.

Re: Game and GC

2018-02-22 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, February 23, 2018 01:54:07 Leonardo via Digitalmars-d-learn wrote: > Hi, I'm new to language and games. > Many people say that GC is bad and can slow down your project in > some moments. > What can happen if I create a game using D without worrying with > memory management? > (using

Re: Game and GC

2018-02-22 Thread Leonardo via Digitalmars-d-learn
On Friday, 23 February 2018 at 02:02:12 UTC, StickYourLeftFootIn wrote: On Friday, 23 February 2018 at 01:54:07 UTC, Leonardo wrote: Hi, I'm new to language and games. Many people say that GC is bad and can slow down your project in some moments. What can happen if I create a game using D

Re: Game and GC

2018-02-22 Thread StickYourLeftFootIn via Digitalmars-d-learn
On Friday, 23 February 2018 at 01:54:07 UTC, Leonardo wrote: Hi, I'm new to language and games. Many people say that GC is bad and can slow down your project in some moments. What can happen if I create a game using D without worrying with memory management? (using full GC) What do you

Re: Game and GC

2018-02-22 Thread Leonardo via Digitalmars-d-learn
On Friday, 23 February 2018 at 02:16:38 UTC, Jonathan M Davis wrote: The GC won't slow down your code in general (in fact, it will probably speed it up in comparison to reference counting), but whenever the GC does a collection, that means that it stops all threads that it manages. So, you

Re: Game and GC

2018-02-22 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 23 February 2018 at 01:54:07 UTC, Leonardo wrote: What can happen if I create a game using D without worrying with memory management? (using full GC) It depends what kind of game it is and how sloppy your code is in general. Every game I have written in D i don't think about it,

Re: Game and GC

2018-02-22 Thread Mike Franklin via Digitalmars-d-learn
On Friday, 23 February 2018 at 01:54:07 UTC, Leonardo wrote: Hi, I'm new to language and games. Many people say that GC is bad and can slow down your project in some moments. What can happen if I create a game using D without worrying with memory management? (using full GC) Don't let the GC

Game and GC

2018-02-22 Thread Leonardo via Digitalmars-d-learn
Hi, I'm new to language and games. Many people say that GC is bad and can slow down your project in some moments. What can happen if I create a game using D without worrying with memory management? (using full GC)

Re: Game and GC

2018-02-22 Thread Norm via Digitalmars-d-learn
On Friday, 23 February 2018 at 01:54:07 UTC, Leonardo wrote: Hi, I'm new to language and games. Many people say that GC is bad and can slow down your project in some moments. What can happen if I create a game using D without worrying with memory management? (using full GC) Have a look at

Re: Understanding the AST...

2018-02-22 Thread Seb via Digitalmars-d-learn
On Tuesday, 6 February 2018 at 12:03:06 UTC, joe wrote: Hello everybody! Last week end I found this post ( https://dlang.org/blog/2017/08/01/a-dub-case-study-compiling-dmd-as-a-library/ ) on the Blog and thought to myself awesome. [...] BTW I know it's not as powerful as DMD (and not the

Re: Understanding the AST...

2018-02-22 Thread joe via Digitalmars-d-learn
On Thursday, 22 February 2018 at 14:53:11 UTC, Seb wrote: On Tuesday, 6 February 2018 at 12:03:06 UTC, joe wrote: Hello everybody! Last week end I found this post ( https://dlang.org/blog/2017/08/01/a-dub-case-study-compiling-dmd-as-a-library/ ) on the Blog and thought to myself awesome.

Re: Negative index range violation

2018-02-22 Thread Timon Gehr via Digitalmars-d-learn
On 22.02.2018 01:26, Adam D. Ruppe wrote: On Thursday, 22 February 2018 at 00:13:43 UTC, SrMordred wrote: string x = "123"; auto c = x.ptr; c++; writeln(c[-1]); // 1 That's only happening because pointers bypass range checks. writeln(c[-1..0]); //BOOM Range violation But with a slice