Re: char[] == null

2015-11-19 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, November 18, 2015 22:15:19 anonymous via Digitalmars-d-learn wrote: > On 18.11.2015 22:02, rsw0x wrote: > > slices aren't arrays > > http://dlang.org/d-array-article.html > > The language reference/specification [1] uses the term "dynamic array" > for T[] types. Let's not enforce a

Re: char[] == null

2015-11-19 Thread Kagamin via Digitalmars-d-learn
On Thursday, 19 November 2015 at 03:53:48 UTC, Meta wrote: On Wednesday, 18 November 2015 at 23:53:01 UTC, Chris Wright wrote: --- char[] buffer; if (buffer.length == 0) {} --- This is not true. Consider the following code: import std.stdio; void main() { int[] a = [0, 1, 2];

Re: opEquals default behaviour - poorly documented or am I missing something?

2015-11-19 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, November 17, 2015 20:25:30 user123ABCabc via Digitalmars-d-learn wrote: > On Tuesday, 17 November 2015 at 19:44:36 UTC, Ali Çehreli wrote: > > if (typeid(a) == typeid(b)) return a.opEquals(b); > > Wow this is terrible to compare two objects in D. The line I > quoted means that two

Re: char[] == null

2015-11-19 Thread Spacen Jasset via Digitalmars-d-learn
On Thursday, 19 November 2015 at 08:30:54 UTC, Jonathan M Davis wrote: On Wednesday, November 18, 2015 22:15:19 anonymous via Digitalmars-d-learn wrote: [...] Exactly. T[] _is_ a dynamic array. Steven's otherwise wonderful article on arrays in D ( http://dlang.org/d-array-article.html )

Re: dataframe implementations

2015-11-19 Thread John Colvin via Digitalmars-d-learn
On Thursday, 19 November 2015 at 06:33:06 UTC, Jay Norwood wrote: On Wednesday, 18 November 2015 at 22:46:01 UTC, jmh530 wrote: My sense is that any data frame implementation should try to build on the work that's being done with n-dimensional slices. I've been watching that development, but

Re: Thread in detached state?

2015-11-19 Thread Ali Çehreli via Digitalmars-d-learn
On 11/19/2015 08:40 AM, Ish wrote: > Does not produce the desired effect. Will you tell us what that is? :) > For 380 threads (Linux limit) it works, for 381 threads it > dies. As I understand it, it hit a limit. Sounds like it works as designed though. I should go read about this topic to

Re: scope keyword

2015-11-19 Thread Jeremy DeHaan via Digitalmars-d-learn
On Thursday, 19 November 2015 at 23:16:04 UTC, Spacen Jasset wrote: I thought scope was deprecated, but I see that this is still here: http://dlang.org/attribute.html#scope Is it just the uses on classes and local variables that are discouraged, but the use in a function signature will

Re: Thread in detached state?

2015-11-19 Thread Ali Çehreli via Digitalmars-d-learn
On 11/19/2015 08:40 AM, Ish wrote: > For 380 threads (Linux limit) it works, for 381 threads it > dies. The program termination is exactly same as in 381 threads > created using spawn(). I've read some more about this. It looks like there are no separate counts or limits for detached versus

Re: Thread in detached state?

2015-11-19 Thread ZombineDev via Digitalmars-d-learn
On Friday, 13 November 2015 at 15:35:11 UTC, Ish wrote: I was directed here from General list, so be patient with me. I am looking for syntax for creating a detached-state thread in the spirit of POSIX thread attribute PTHREAD_CREATE_DETACHED (the thread resources are released on termination

Re: dataframe implementations

2015-11-19 Thread ZombineDev via Digitalmars-d-learn
On Thursday, 19 November 2015 at 06:33:06 UTC, Jay Norwood wrote: On Wednesday, 18 November 2015 at 22:46:01 UTC, jmh530 wrote: My sense is that any data frame implementation should try to build on the work that's being done with n-dimensional slices. I've been watching that development, but

scope keyword

2015-11-19 Thread Spacen Jasset via Digitalmars-d-learn
I thought scope was deprecated, but I see that this is still here: http://dlang.org/attribute.html#scope Is it just the uses on classes and local variables that are discouraged, but the use in a function signature will continue? in == const scope?

Re: Arty of Constructor

2015-11-19 Thread John Colvin via Digitalmars-d-learn
On Thursday, 19 November 2015 at 06:20:28 UTC, Andrew wrote: The documentation gives plenty of examples of how to use a static if with the arity trait, but how do I specify the constructor of an object as the parameter to arity? Thanks Ugly but works: import std.traits; struct A {

Re: char[] == null

2015-11-19 Thread Jack Applegame via Digitalmars-d-learn
I prefer import std.array; if(!arr.empty) {}

Re: char[] == null

2015-11-19 Thread BBaz via Digitalmars-d-learn
On Wednesday, 18 November 2015 at 20:57:08 UTC, Spacen Jasset wrote: Should this be allowed ? IMHO no. It's better to use `.length` to test if an array is empty. Why ? Because the day you'll have a function whose parameter is a pointer to an array, comparing to null will become completly

Re: pure vs immutable

2015-11-19 Thread Jack Applegame via Digitalmars-d-learn
Heh immutable Foo foo2 = new Foo("bar"); // compiles

pure vs immutable

2015-11-19 Thread Jack Applegame via Digitalmars-d-learn
I believe that object constructed with pure constructor should be implicitly convertible to immutable. It is, but only for default constructor. class Foo { string s; this() pure { s = "fpp"; } this(string p) pure { s = p; } } void main() { auto foo1 = new immutable

Re: char[] == null

2015-11-19 Thread Chris Wright via Digitalmars-d-learn
On Thu, 19 Nov 2015 07:28:28 +0100, anonymous wrote: > On 19.11.2015 06:18, Chris Wright wrote: >> Just for fun, is an array ever not equal to itself? > > Yes, when it contains an element that's not equal to itself, e.g. NaN. Exactly. If NaN-like cases didn't exist, TypeInfo_Array could have

Re: static class vs. static struct

2015-11-19 Thread vyarthrot via Digitalmars-d-learn
On Monday, 26 January 2015 at 14:02:54 UTC, ref2401 wrote: What's the difference between static class and static struct? What should i use? In simple words, Singleton is a pattern and not a keyword. The Singleton pattern has several advantages over static classes. A singleton allows a class

Re: char[] == null

2015-11-19 Thread Kagamin via Digitalmars-d-learn
On Thursday, 19 November 2015 at 10:04:37 UTC, Spacen Jasset wrote: char[] == null vs char[] is null Is there any good use for char[] == null ? If not, a warning might be helpful. Actually char[] == null is a more usable one.

Re: char[] == null

2015-11-19 Thread Steven Schveighoffer via Digitalmars-d-learn
On 11/19/15 5:04 AM, Spacen Jasset wrote: On Thursday, 19 November 2015 at 08:30:54 UTC, Jonathan M Davis wrote: On Wednesday, November 18, 2015 22:15:19 anonymous via Digitalmars-d-learn wrote: [...] Exactly. T[] _is_ a dynamic array. Steven's otherwise wonderful article on arrays in D (

Re: char[] == null

2015-11-19 Thread Steven Schveighoffer via Digitalmars-d-learn
On 11/19/15 3:30 AM, Jonathan M Davis via Digitalmars-d-learn wrote: On Wednesday, November 18, 2015 22:15:19 anonymous via Digitalmars-d-learn wrote: On 18.11.2015 22:02, rsw0x wrote: slices aren't arrays http://dlang.org/d-array-article.html The language reference/specification [1] uses

Re: Thread in detached state?

2015-11-19 Thread Ish via Digitalmars-d-learn
On Friday, 13 November 2015 at 19:45:58 UTC, Ali Çehreli wrote: On 11/13/2015 07:35 AM, Ish wrote: [...] I think the following is the idea: import std.stdio; import core.thread; extern(C) void rt_moduleTlsDtor(); void threadFunc() { writeln("Worker thread started");

Re: char[] == null

2015-11-19 Thread Meta via Digitalmars-d-learn
On Thursday, 19 November 2015 at 13:49:18 UTC, Meta wrote: On Thursday, 19 November 2015 at 06:57:20 UTC, Jack Applegame wrote: Really? http://dpaste.dzfl.pl/b11346e8e341 Sorry, I said the exact opposite of what I meant to say. The `assert(a == null)` *is* triggered because the expression `a

Re: char[] == null

2015-11-19 Thread Meta via Digitalmars-d-learn
On Thursday, 19 November 2015 at 06:57:20 UTC, Jack Applegame wrote: Really? http://dpaste.dzfl.pl/b11346e8e341 Sorry, I said the exact opposite of what I meant to say. The `assert(a == null)` *is* triggered because the expression `a == null` fails, even though a.length == 0. You should not