Re: Getting a safe path for a temporary file

2017-10-27 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, October 27, 2017 21:38:55 Jonathan M Davis via Digitalmars-d- learn wrote: > Also, toStringz specifically returns an immutable(char)* - though looking > it over right now, I'd say that that's a bug for the overload that takes > const(char)[] instead of string. It really should return

Re: Getting a safe path for a temporary file

2017-10-27 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, October 28, 2017 02:46:00 Shriramana Sharma via Digitalmars-d- learn wrote: > On Wednesday, 25 October 2017 at 00:35:29 UTC, Ali Çehreli wrote: > > > char[] name = "/tmp/XX".dup; > > > > remain valid. The actual issue is the missing '\0'. So, > > > > consider toStringz in this

Re: Why is length being tested on an int?

2017-10-27 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, October 28, 2017 02:38:43 Shriramana Sharma via Digitalmars-d- learn wrote: > Hello. I want a function to be able to take any arguments like > write() and print them out but quoting string arguments of length > more than 1. So I write the following quote: > > import std.stdio; >

Re: Why is length being tested on an int?

2017-10-27 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 28 October 2017 at 02:38:43 UTC, Shriramana Sharma wrote: if (is(typeof(arg) == string) && arg.length > 1) I am not sure why, given short circuit evaluation, it is testing the length of the int argument? That's a runtime check and therefore the code must run to be short

Re: Getting a safe path for a temporary file

2017-10-27 Thread Shriramana Sharma via Digitalmars-d-learn
On Wednesday, 25 October 2017 at 00:35:29 UTC, Ali Çehreli wrote: > char[] name = "/tmp/XX".dup; remain valid. The actual issue is the missing '\0'. So, consider toStringz in this case: https://dlang.org/library/std/string/to_stringz.html Thanks for your reply, but can you clarify

Why is length being tested on an int?

2017-10-27 Thread Shriramana Sharma via Digitalmars-d-learn
Hello. I want a function to be able to take any arguments like write() and print them out but quoting string arguments of length more than 1. So I write the following quote: import std.stdio; string myFunc(string arg) { return '\"' ~ arg ~ '\"'; } void myWrite(T ...)(T args) { foreach

Re: Just starting with D (linking with C++)

2017-10-27 Thread codephantom via Digitalmars-d-learn
On Friday, 27 October 2017 at 17:14:20 UTC, sivakon wrote: I want to use C++ libraries for machine learning and deep learning. How do I add C++ libraries to my d code. on FreeBSD, I use: for C static binding: -- clang -c sample.c dmd -L-lc foo.d sample.o or ldc -L-lc

Re: Why 2 ^^ 1 ^^ 2 = 2?

2017-10-27 Thread Ivan Kazmenko via Digitalmars-d-learn
On Thursday, 26 October 2017 at 10:02:54 UTC, Kagamin wrote: On Sunday, 22 October 2017 at 22:28:48 UTC, Ivan Kazmenko wrote: Yeah, and a height-3 tower $a^{b^c}$ (TEX notation) Is $a^{b^c}$ the same as ${a^b}^c$ ? They are drawn slightly differently, so I suppose it's ambiguous indeed.

Re: Just starting with D (linking with C++)

2017-10-27 Thread Joakim via Digitalmars-d-learn
On Friday, 27 October 2017 at 17:43:08 UTC, sivakon wrote: On Friday, 27 October 2017 at 17:21:39 UTC, Joakim wrote: This should work: dmd foo.d Sample.o Just like the C examples from the D blog: https://dlang.org/blog/2017/10/25/dmd-windows-and-c/ Just used this! Got this error!

Re: Just starting with D (linking with C++)

2017-10-27 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/27/17 1:43 PM, sivakon wrote: On Friday, 27 October 2017 at 17:21:39 UTC, Joakim wrote: This should work: dmd foo.d Sample.o Just like the C examples from the D blog: https://dlang.org/blog/2017/10/25/dmd-windows-and-c/ Just used this! Got this error! sample.o: In function

Re: Just starting with D (linking with C++)

2017-10-27 Thread sivakon via Digitalmars-d-learn
On Friday, 27 October 2017 at 17:21:39 UTC, Joakim wrote: This should work: dmd foo.d Sample.o Just like the C examples from the D blog: https://dlang.org/blog/2017/10/25/dmd-windows-and-c/ Just used this! Got this error! sample.o: In function `foo(int, int, int)':

Re: Just starting with D (linking with C++)

2017-10-27 Thread Joakim via Digitalmars-d-learn
On Friday, 27 October 2017 at 17:14:20 UTC, sivakon wrote: Hi, Just started to work with D. Great language. I want to use C++ libraries for machine learning and deep learning. How do I add C++ libraries to my d code. For example, //sample.cpp #include using namespace std; int foo(int i,

Just starting with D (linking with C++)

2017-10-27 Thread sivakon via Digitalmars-d-learn
Hi, Just started to work with D. Great language. I want to use C++ libraries for machine learning and deep learning. How do I add C++ libraries to my d code. For example, //sample.cpp #include using namespace std; int foo(int i, int j, int k) { cout << "i = " << i << endl; cout

Re: Role of third argument to GC.addRange

2017-10-27 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/27/17 10:18 AM, Nordlöw wrote: The docs for the third argument to https://dlang.org/library/core/memory/gc.add_range.html says: "The GC might use this information to improve scanning for pointers or to call finalizers." Can somebody elaborate a bit on what "improve scanning" means

Re: Role of third argument to GC.addRange

2017-10-27 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 27 October 2017 at 14:18:02 UTC, Nordlöw wrote: Can somebody elaborate a bit on what "improve scanning" means here? I believe it is so it can skip scanning stuff like ubyte[] for pointers and in the future might be used for precise scanning on structs with pointers and data

Role of third argument to GC.addRange

2017-10-27 Thread Nordlöw via Digitalmars-d-learn
The docs for the third argument to https://dlang.org/library/core/memory/gc.add_range.html says: "The GC might use this information to improve scanning for pointers or to call finalizers." Can somebody elaborate a bit on what "improve scanning" means here?

Re: Empty UDA for classes not allowed?

2017-10-27 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 26 October 2017 at 15:09:48 UTC, bauss wrote: Why is it not allowed to have empty UDAs for classes? Let's say we have an UDA like this: struct Exclude { } Then we want to put it on a class like: @Exclude class Foo { ... } This will fail with the following error: Error: type