I noticed just making many threads cause an error.
Are there any limit for the number of threads?
import std.concurrency;
import core.thread;
void fun() { Thread.sleep(5000.msecs); }
void testThread() {
foreach(i; 0..2000) {
spawn(&fun);
}
}
core.thread.ThreadErro
Hi, do you think it's possible to implemented something like Lua Tables
(a hashed heterogeneous associative array) in D?
I know that Lua is dynamic and interpreted, hence it's a lot simpler to
do than with a compiled language but I'm wondering if we could express
such a generic data-structure
On 2015-07-15 23:57, badlink wrote:
Hello, I can't figure how to write a template function that accept
either strings or array of strings.
This is my current code:
bool hasItemParent(T)(const(char)[] itemId, const(T)[] parentId)
if (is(typeof(T) == char) || (isArray!T && is(typeof(T[]) == char)
On Thu, 16 Jul 2015 00:18:30 +
seashell86 via Digitalmars-d-learn
wrote:
> So I've been mostly just toying around with D as it seems like it
> will end up being a strong language for game development both now
> and even moreso in the future. That being said, I'm perplexed by
> using this
On Tuesday, 14 July 2015 at 13:35:40 UTC, Mike Parker wrote:
--
4000 _Dmain
_D4main6selectFZk 40002736471
4000 _D3std6random27__T7uniformVAyaa2_5b29TkTkZ7uniformFNfkkZk
--
Got it now. The 2736 and 471 are the call tree time
This member function of my struct uses a function pointer btx.
When the line declaring the function pointer is present I get a
LNK2019 error: unresolved external symbol.
bool opIndexAssign(bool value, size_t[2] inds)
{
int function(size_t*, size_t) btx = (value) ? &bts : &btr; //
error is her
On Thursday, 16 July 2015 at 00:39:29 UTC, H. S. Teoh wrote:
On Thu, Jul 16, 2015 at 12:18:30AM +, seashell86 via
Digitalmars-d-learn wrote:
[...]
The reason is that class variables cannot be overridden, only
class methods can.
If you want to simulate overriding of class variables, you
On Thursday, 16 July 2015 at 00:39:29 UTC, H. S. Teoh wrote:
If you want to simulate overriding of class variables, you can
use a @property method instead:
class Animal {
@property string voice() { return "Wah!"; }
void speak() { writeln(voice); }
On Wednesday, 15 July 2015 at 18:02:11 UTC, jmh530 wrote:
I've been confused by this too. The only thing I can find is
this
http://www.digitalmars.com/ctg/trace.html
I think it would be cool to write something that takes the
output and puts it in a prettier format.
Yeah, I eventually stumb
On Thu, Jul 16, 2015 at 12:18:30AM +, seashell86 via Digitalmars-d-learn
wrote:
> So I've been mostly just toying around with D as it seems like it will
> end up being a strong language for game development both now and even
> moreso in the future. That being said, I'm perplexed by using this
So I've been mostly just toying around with D as it seems like it
will end up being a strong language for game development both now
and even moreso in the future. That being said, I'm perplexed by
using this code and not receiving the result I would imagine.
Here is the source code of a basic
On Wednesday, 15 July 2015 at 21:57:50 UTC, badlink wrote:
Hello, I can't figure how to write a template function that
accept either strings or array of strings.
This is my current code:
bool hasItemParent(T)(const(char)[] itemId, const(T)[] parentId)
if (is(typeof(T) == char) || (isArray!T &&
On Wednesday, 15 July 2015 at 21:57:50 UTC, badlink wrote:
Hello, I can't figure how to write a template function that
accept either strings or array of strings.
This is my current code:
bool hasItemParent(T)(const(char)[] itemId, const(T)[] parentId)
if (is(typeof(T) == char) || (isArray!T &&
Hello, I can't figure how to write a template function that
accept either strings or array of strings.
This is my current code:
bool hasItemParent(T)(const(char)[] itemId, const(T)[] parentId)
if (is(typeof(T) == char) || (isArray!T && is(typeof(T[]) ==
char)))
{...}
I used const(T)[] becaus
On Wednesday, 15 July 2015 at 11:45:00 UTC, Laeeth Isharc wrote:
Now - is there a way to rewrite my code without mixins?
Not sure that is possible. It would be interesting if someone
could figure it out though.
I'm more focused on making the "givemeabettername" a bit more
general. Someone a
On Wednesday, 15 July 2015 at 11:47:53 UTC, Mike Parker wrote:
On Tuesday, 14 July 2015 at 13:35:40 UTC, Mike Parker wrote:
--
4000 _Dmain
_D4main6selectFZk 40002736471
4000 _D3std6random27__T7uniformVAyaa2_5b29TkTkZ7uniformFNfkkZk
--
I want to make sure about the semantics of unshared variables.
import std.concurrency;
import core.thread;
ubyte[1024 * 1024] buf1MB;
void fun() { Thread.sleep(5000.msecs); }
void testThread() {
foreach(i; 0..2000) {
spawn(&fun);
}
}
Are instances of buf1MB create
On Wed, 15 Jul 2015 15:45:43 +
"rumbu" wrote:
> struct S { int a, b; }
> auto s = cast(S)10;
> //compiles and sets s.a to 10.
>
> It works also for any other type, if the structure contains a
> member of that type in the first position.
>
> Is this normal behaviour?
Yes, this is OK
If y
On 7/15/15 11:45 AM, rumbu wrote:
struct S { int a, b; }
auto s = cast(S)10;
//compiles and sets s.a to 10.
It works also for any other type, if the structure contains a member of
that type in the first position.
Is this normal behaviour?
I would say this is a bug. As far as I know, it's not
On Wed, 15 Jul 2015 11:57:01 -0400
Steven Schveighoffer wrote:
> On 7/15/15 11:45 AM, rumbu wrote:
> > struct S { int a, b; }
> > auto s = cast(S)10;
> > //compiles and sets s.a to 10.
> >
> > It works also for any other type, if the structure contains a
> > member of that type in the first posi
struct S { int a, b; }
auto s = cast(S)10;
//compiles and sets s.a to 10.
It works also for any other type, if the structure contains a
member of that type in the first position.
Is this normal behaviour?
On 2015-07-14 17:53, Rene Zwanenburg wrote:
Sure, but that would make Base!Derived and Base!AnotherSubClass
different types.
What I'd like to end up with is a Base[], being able to call foo() on
the array members. Other parts of the code will add instances of derived
types to this array, and ha
On 07/14/2015 08:28 AM, Rene Zwanenburg wrote:
> But the CallbackType should be able to prevent such unsafe assignments.
The following struct applies what others have recommended only if an
actual derived type is provided. However, it is still unsafe as the
direct assignment to 'callback' cann
On Tuesday, 14 July 2015 at 13:35:40 UTC, Mike Parker wrote:
--
4000 _Dmain
_D4main6selectFZk 40002736471
4000 _D3std6random27__T7uniformVAyaa2_5b29TkTkZ7uniformFNfkkZk
--
OK, I've finally realized that the top part of trace.
On Tuesday, 14 July 2015 at 17:24:41 UTC, anonymous wrote:
This fails with "Error: None of the overloads of 'cos' are
callable using argument types (int[])".
The problem is that template mixins cannot add to existing
overload sets. The spec says: "If the name of a declaration in
a mixin is th
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 for which there is just one, persistent
instance across the lifetime of an application. That means, it
created a single instance and that insta
26 matches
Mail list logo