Greetings
I have a question on class destructor method. D documentation for
destructors says:
"The garbage collector is not guaranteed to run the destructor for
all unreferenced objects. Furthermore, the order in which the garbage
collector calls destructors for unreference ob
Thanks Jonathan
Do you think this could make a good enhancement request?
Regards
- Puneet
On Sat, Jun 1, 2013 at 9:34 PM, Jonathan M Davis wrote:
> On Saturday, June 01, 2013 20:21:42 d coder wrote:
> > Greetings
> >
> > Is there a way to initialize an associative arr
Greetings
Is there a way to initialize an associative array to a non-null (but still
empty) state? The only way I know is by adding an element and then removing
it. Did I miss something obvious? Basically I want to write lines 7-8 in
the following code in a cleaner fashion. Any ideas?
Regards
- P
>
>
> I've copy and pasted my reply to Benjamin below, you should be able to
> adapt it to your needs:
>
Stupid me. Should have checked the list before posting.
>
> The only way I've found to do this that works is using an alias - this is
> probably worth a bug report if there isn't one already.
Greetings
I am facing problem passing a shared class method as an argument to a
function. Look at the following minimized code snippet.
class Foo {
shared // compiles when commented out
void bar() {}
}
void frop(void delegate() dg) {
}
void main() {
shared Foo foo = new shared(Foo);
f
Greetings All
It has been 2 months since we had release 2.052. Just wondering when is the
2.053 release planned?
Also, is there an automated way to create a snapshot release from the git
repositories?
Regards
- Puneet
Greetings
Please look at the code down here. When compiled and run, I get the message
"Call to postblit" printed. I think it is because of the foreach block,
because the variable "i" is not declared as ref there. Is there a way to
make it a ref?
Regards
- Puneet
import std.stdio;
struct Foo {
Greetings
Do I need to declare instances of Semaphores, Mutexes and Barriers shared?
In most situations these objects would be naturally accessed by many
threads.
Regards
- Puneet
>
>
> It's probably complaining because using shared without synchronizing is
> generally very foolish. Now, I would have _thought_ that it would still
> work
> without, but I apparently not. Regardless, I'm not sure why you'd want to
> use
> shared anything without synchronizing your access of it.
Greetings
Why is it necessary to use synchronized functions when passing shared
variables? I get error even when I am not modifying the shared variable in
the function.
Kindly look at the following code. I get a compile error unless I declare
the functions parent and root synchronized.
The compil
> I'm afraid that I have no idea what would be "stale" about a shared
variable.
> sychronized uses a mutex, and if you want to avoid race conditions, you
need to
> use mutexes or something similar when dealing with shared variables. But I
don't
> know what would be "stale" about a variable.
>
One
Greetings
I have a doubt about synchronized code blocks.
I learnt that in Java the synchronized keyword has two fold effect.
Firstly it locks the code to make sure that only a single thread gets
access to the code block at a given time. Secondly, it makes sure that
the data elements accessed insi
Thanks Simon.
Greetings
I tried to initialize a struct member with a function pointer, and
found that DMD2 did not like it. Are not function pointers compile
time constants? And why they should not be?
Regards
- Cherry
Greetings
I am getting this error when I am instantiating a struct array with a
single element inside another class and only if there is the
destructor for the struct is explicitly defined. Is it a known error?
Here is a minimized snippet that gives error:
$ rdmd --main -unittest test.d
Error: t
> However, it's not generally an issue, because you shouldn't normally be
> keeping
> references around for stuff that isn't used anymore. The garbage collector is
> smart enough to deal with circular references and the like, so the biggest
> cases
> where you'd normally need weak references aren
> If you know roughly what to do and want to take a stab at producing a viable
> patch to fix the problem, then feel free. If it's solid, it may get in. I
> don't
> know. It doesn't hurt to try though (as long as you're prepared for the fact
> that it may not be accepted).
Thanks for letting me k
> Also tango (for D 1.0) implements it.
> Link:
> http://www.dsource.org/projects/tango/docs/current/tango.core.WeakRef.html
>
> Might be worth a look if you are going to implement it for D 2.0.
>
I looked at the D1 implementation. It depends on GC methods
weakPointerCreate and weakPointerDestroy.
> I believe what you're referring to is generally called a Weak
> Reference, which is a reference that the GC doesn't consider when
> deciding to keep an object alive, but that the GC will update if an
> object dies.
> There's a feature request at
> http://d.puremagic.com/issues/show_bug.cgi?id=41
Greetings
I am in a situation where I need to know the number of references to a
class' object. To explain, I have an array of class objects and I
occasionally process this array. But if a particular object in this
array is not being garbage collected just because it is part of this
array, I would
Thanks Lars and Bearophile, I will give it a try.
I understand that static downcasting is dangerous. But there are
places where efficiency is paramount and you are sure that the casting
is safe. So I wholeheartedly second your proposal to have the stuff in
phobos.
Regards
- Cherry
Greetings All
I have learnt that D has only one casting operator and that is 'cast'.
The same operator assumes different functionality depending on the
context in which it he being used.
Now I have a situation where I have to downcast an object and I am
sure of the objects type and thereby I am s
Greetings
Is there a limit on the maximum number of threads that can be
spawned? Or does it just depend on the value in
/proc/sys/kernel/threads-max on a linux system?
Regards
- Cherry
> A struct nested in a class does not have a hidden "outer" pointer as a
> nested class does. It's because a struct is generally more bare-bones than
> a class (which has loads of hidden pieces: vtable, interfaces, classinfo,
> etc.). Also, instantiating such a struct does not tie it to a class
>
Greetings All
I have a situation where I have a struct nested inside a class. I
would like to make the enclosing class' members visible inside the
nested struct's constructor. I see that such preposition is feasible
for nested classes, but not for nested structs. Why so?
Are there some alternativ
> I do know the template. I will try out your solution. Will let you
> know if I face issues.
>
Simen
It works perfect, And this is exactly what I was looking for. If you
see my original post, I also thought this form of "is" expression
should work. Just could not get around to the right syntax.
> S!int foo;
> static if ( is( typeof(foo) f == S!T, T ) ) {
> // Here, T == int, f == typeof(foo)
> }
>
> Note that the syntax "is ( Type Identifier : TypeSpecialization ,
> TemplateParameterList )" is only usable inside static if.
>
Thanks Simen
I do know the template. I will try out your so
> For instance, given your definiton of S, you could use
> _traits/std.traits to check that the type that you're testing has a member
> variable t. You could then check that S!(typeof(t)) was the same as the type
> that you were testing. So, if you get particularly cunning about it, I believe
> tha
Greetings
I want to find if a given struct type is instantiated from a
particular template struct type. For example:
struct S (T) {
alias T Type;
T t;
}
And later I want to find out if a given type is of type S(*)
(basically any type instantiated from template struct S). In fact I do
not kn
> I'm curious, why do you need that?
>
It is a long story.
But basically I am creating a platform wherein the users would be
deriving classes from some base classes that I write as part of the
platform. And the users would often be deriving many such classes.
The end-users would often not be pro
Greetings
I need a way to know (using traits or other compile time constructs)
all the types derived from a given type.
Is it possible in D?
Is it possible to get a list of all the user-defined classes? I could
use that to filter out the classes that I need.
Regards
Cherry
> Ah.. Now I think I understand.
>
> This new code I have written will all be run at compile time. So in
> this case, the foreach statement inside the constructor would be
> reduced to a bunch of writeln statements at compile time and those
> writeln would be executed at the run time. This will not
> Another thing, is(T : U) simply means T is implicitly castable to U. Due to
> a compiler bug, Bar[] is implicitly castable to BaseClass[].
>
Steve
I realize that I am using this compiler bug as a feature. It would be
kind of you to suggest me a code that would not exploit this bug. I
was think
> What you are saying makes sense to me. The problem is that the
> following code works perfectly. I have just commented out some part
> and replaced it with some debug statements.
Ah.. Now I think I understand.
This new code I have written will all be run at compile time. So in
this case, the fo
> Is there a reason you can't directly reference the members? After all, you
> are writing the class.
>
Thanks Steve for your inputs.
Actually this is part of a bigger code that I am trying to create.
Though I am pretty new to D.
What I have posted is a reduced code that illustrated the issue I
> if(false) {
> for (size_t j = 0; j < f.length...)
> ...
> }
>
> Semantically this code is wrong as you can't take the length of f which is
> class Bar. The static if forces the compiler to not generate this code as it
> is known to be false.
>
Thanks Jesse
What you are saying makes sens
Greetings All
I am trying to compile the following D2 code. The code giving compilation
issues is the "this()" function of the class Foo. The constructor basically
tries to initialize all the data members of the class, of type BaseClass and
of type BaseClass array.
I am using class property tuple
37 matches
Mail list logo