Re: Create object from a library's Class returns Null

2019-05-28 Thread Nick Treleaven via Digitalmars-d-learn
On Tuesday, 28 May 2019 at 09:25:51 UTC, dangbinghoo wrote: writeln(Object.factory("gwlib.entity.nsconf.NSConf")); Typo, should be NSconf.

Create object from a library's Class returns Null

2019-05-28 Thread dangbinghoo via Digitalmars-d-learn
hi there, I have a set of DB entity class in a library and creating Object from another project which linked with the library returns Null. I don't know what's wrong there. the source is like this: a. I have a library with such a structure: gwlib/source/gwlib/entity/nsconf.d

Re: compiler does not detect accessing on null class object.

2019-05-27 Thread dangbinghoo via Digitalmars-d-learn
On Monday, 27 May 2019 at 15:29:32 UTC, Daniel Kozak wrote: On Monday, 27 May 2019 at 15:13:00 UTC, dangbinghoo wrote: hello, 1.) Yes this is by design. It is not easy to detect this at compile time. It does not break safety 2.) https://dlang.org/spec/function.html#function-safety

Re: compiler does not detect accessing on null class object.

2019-05-27 Thread Daniel Kozak via Digitalmars-d-learn
etect for accessing a null object and refused to compile? And, 2nd question: where can I find the Subset spec of SafeD? Thanks! -- binghoo dang 1.) Yes this is by design. It is not easy to detect this at compile time. It does not break safety 2.) https://dlang.org/spec/fu

compiler does not detect accessing on null class object.

2019-05-27 Thread dangbinghoo via Digitalmars-d-learn
hello, code below: - class a { string a1; } a a1; writeln(a1.a1); - compiles and produce "core dump" or "segfault", does this fit the original D design? why the compiler does not detect for accessing a null object and refused to compile?

Re: Instantiating an Object with the Same Object as an Argument?

2019-04-17 Thread Adam D. Ruppe via Digitalmars-d-learn
btw if you haven't seen my version of the gtk-d docs, check it out: http://gtk-d.dpldocs.info/gtk.Adjustment.Adjustment.html It does various cross-referencing the official versions don't, among other things. You can see the GtkAdjustment there is not linked, because it is the C version,

Re: Instantiating an Object with the Same Object as an Argument?

2019-04-17 Thread Ron Tarrant via Digitalmars-d-learn
! One is Adjustment, the D wrapper class, and the other is GtkAdjustment*, the C structure pointer. This constructor is for cases when you have an existing object made via the C api and you want the D wrapper to adopt it. Ah! Thanks for clearing that up, Adam. I shall go blush now

Re: Instantiating an Object with the Same Object as an Argument?

2019-04-17 Thread Adam D. Ruppe via Digitalmars-d-learn
is GtkAdjustment*, the C structure pointer. This constructor is for cases when you have an existing object made via the C api and you want the D wrapper to adopt it.

Instantiating an Object with the Same Object as an Argument?

2019-04-17 Thread Ron Tarrant via Digitalmars-d-learn
I've come across this a few times in the wrapper code for GtkD where one of the constructors for an object takes an argument of the same type the constructor produces. For instance, one of the Adjustment constructors looks like this: public this(GtkAdjustment* gtkAdjustment, bool

design question, gtkd object interdependence

2019-03-25 Thread number via Digitalmars-d-learn
I have a design question about (i guess) object interdependence using gtkd. There is an application class which sets its property mAppWin. The app is passed as an argument to the window constructor. During the window constructor a scale (trackbar) is created which also receives and stores

Re: Why can't or shouldn't I just hash the address of an object? And how.

2018-12-30 Thread Enjoys Math via Digitalmars-d-learn
On Sunday, 30 December 2018 at 05:54:05 UTC, Neia Neutuladh wrote: On Sun, 30 Dec 2018 05:36:41 +, Enjoys Math wrote: Is it: typeof(T).getHash()? This gets the hashcode for the object by calling toHash() on it. Or does that do something other than just get the address? It XORs

Re: Why can't or shouldn't I just hash the address of an object? And how.

2018-12-29 Thread Neia Neutuladh via Digitalmars-d-learn
On Sun, 30 Dec 2018 05:36:41 +, Enjoys Math wrote: > Is it: > > typeof(T).getHash()? This gets the hashcode for the object by calling toHash() on it. > Or does that do something other than just get the address? It XORs the address with a bitwise rotation of the address.

Why can't or shouldn't I just hash the address of an object? And how.

2018-12-29 Thread Enjoys Math via Digitalmars-d-learn
I am creating a custom graph database for our app. It holds not one huge graph but a collection of independent graphs. I would like to be able to delete them without looping through a range of billions of Graph class references. How can I accomplish this with an AA and hasing? Is it:

Re: anyway to set a const object after the fact?

2018-10-30 Thread Jonathan M Davis via Digitalmars-d-learn
> } > > // "others" is a list of args before the valid arg is > > > > encountered > > > > // "restArgs" is a list that is the args after the valid arg > > > > } > > > > } > > > > Is there anyway to set a

Re: anyway to set a const object after the fact?

2018-10-30 Thread Laurent Tréguier via Digitalmars-d-learn
On Tuesday, 30 October 2018 at 11:23:48 UTC, aliak wrote: Guess I could do that. But would there be a difference if I just declared the restArgs as non const then? Given the objective is "set this var to point to this thing and not allow it to be set to point to anything else". The

Re: anyway to set a const object after the fact?

2018-10-30 Thread aliak via Digitalmars-d-learn
On Monday, 29 October 2018 at 22:05:16 UTC, H. S. Teoh wrote: What exactly are you trying to accomplish? I.e., what semantics do you want from modifying restArgs? Trying to set restArgs to point to some data but only set it once. Would require some sort of control flow analysis on the

Re: anyway to set a const object after the fact?

2018-10-30 Thread aliak via Digitalmars-d-learn
)) { restArgs = args[i + 1 .. $]; break; } others ~= arg; } // "others" is a list of args before the valid arg is encountered // "restArgs" is a list that is the args after the valid arg } } Is there anyway to set a const ob

Re: anyway to set a const object after the fact?

2018-10-30 Thread aliak via Digitalmars-d-learn
On Monday, 29 October 2018 at 22:12:24 UTC, Paul Backus wrote: Use a lambda: const string[] restArgs = () { foreach(i, arg; args) { if (isValidArg(arg)) { return args[i+1 .. $]; } others ~= arg; } }(); That works.

Re: anyway to set a const object after the fact?

2018-10-30 Thread Laurent Tréguier via Digitalmars-d-learn
; } others ~= arg; } // "others" is a list of args before the valid arg is encountered // "restArgs" is a list that is the args after the valid arg } } Is there anyway to set a const object after declaring it in the above context? Cheers, - Ali It looks like t

Re: anyway to set a const object after the fact?

2018-10-29 Thread Paul Backus via Digitalmars-d-learn
; } others ~= arg; } // "others" is a list of args before the valid arg is encountered // "restArgs" is a list that is the args after the valid arg } } Is there anyway to set a const object after declaring it in the above context? Cheers, - Ali Use a l

Re: anyway to set a const object after the fact?

2018-10-29 Thread H. S. Teoh via Digitalmars-d-learn
> restArgs = args[i + 1 .. $]; > break; > } > others ~= arg; > } > // "others" is a list of args before the valid arg is encountered > // "restArgs" is a list that is the args after the valid arg > } > }

anyway to set a const object after the fact?

2018-10-29 Thread aliak via Digitalmars-d-learn
st of args before the valid arg is encountered // "restArgs" is a list that is the args after the valid arg } } Is there anyway to set a const object after declaring it in the above context? Cheers, - Ali

Re: assigment to null class object member compiled? is this a bug?

2018-10-22 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 19 October 2018 at 06:53:32 UTC, dangbinghoo wrote: why the code bellow compiles? D compilers are allowed to make that an error, but it might not. With the current implementation, dmd that.d will compile, but dmd -O that.d will fail with an error. Yes, turning on optimizations

Re: assigment to null class object member compiled? is this a bug?

2018-10-22 Thread Alex via Digitalmars-d-learn
On Monday, 22 October 2018 at 01:39:48 UTC, dangbinghoo wrote: On Friday, 19 October 2018 at 09:08:32 UTC, Vijay Nayar wrote: Technically the code you have is syntactically correct. You are permitted to create a class variable without assigning it to a class object. (Assigning it to a class

Re: assigment to null class object member compiled? is this a bug?

2018-10-21 Thread dangbinghoo via Digitalmars-d-learn
On Friday, 19 October 2018 at 09:08:32 UTC, Vijay Nayar wrote: Technically the code you have is syntactically correct. You are permitted to create a class variable without assigning it to a class object. (Assigning it to a class object would look like "A a = new A();") Whi

Re: assigment to null class object member compiled? is this a bug?

2018-10-19 Thread Vijay Nayar via Digitalmars-d-learn
according to book Programming Language>. The latest dmd (2.082) and LDC2 behaves the same. Technically the code you have is syntactically correct. You are permitted to create a class variable without assigning it to a class object. (Assigning it to a class object would look like "A

assigment to null class object member compiled? is this a bug?

2018-10-19 Thread dangbinghoo via Digitalmars-d-learn
hi, why the code bellow compiles? --- import std.stdio; class A { int m; } void main() { A a; a.m = 1; } --- and running this code get: `segmentation fault (core dumped) ./test` I consider this couldn't be compiled according to book Programming Language>. The latest dmd

Re: Error: non-shared method core.sync.condition.Condition.notify is not callable using a shared object

2018-10-18 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, October 18, 2018 4:50:18 AM MDT Paolo Invernizzi via Digitalmars-d-learn wrote: > There's a rational behind the fact that there's not a 'shared' > version of notify/wait method in Condition? > > Thanks, > Paolo The original author of the stuff in core.sync didn't want to update it

Re: Error: non-shared method core.sync.condition.Condition.notify is not callable using a shared object

2018-10-18 Thread Kagamin via Digitalmars-d-learn
On Thursday, 18 October 2018 at 10:50:18 UTC, Paolo Invernizzi wrote: There's a rational behind the fact that there's not a 'shared' version of notify/wait method in Condition? core.sync is pretty old, it was written in 2009 before default storage class for global variables became TLS.

Re: Error: non-shared method core.sync.condition.Condition.notify is not callable using a shared object

2018-10-18 Thread Stanislav Blinov via Digitalmars-d-learn
On Thursday, 18 October 2018 at 10:50:18 UTC, Paolo Invernizzi wrote: There's a rational behind the fact that there's not a 'shared' version of notify/wait method in Condition? They were implemented before complete `shared` spec existed, which is any time between it's conception and now.

Error: non-shared method core.sync.condition.Condition.notify is not callable using a shared object

2018-10-18 Thread Paolo Invernizzi via Digitalmars-d-learn
There's a rational behind the fact that there's not a 'shared' version of notify/wait method in Condition? Thanks, Paolo

Re: New With Struct and Getting Class Object Pointers

2018-10-03 Thread Vijay Nayar via Digitalmars-d-learn
On Sunday, 30 September 2018 at 11:11:09 UTC, Nicholas Wilson wrote: On Sunday, 30 September 2018 at 09:30:38 UTC, Vijay Nayar wrote: Is there a way to either have a constant reference to a class that can be set to a new value, or is there a way to convert the class variable to a class

Re: New With Struct and Getting Class Object Pointers

2018-09-30 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 30 September 2018 at 09:30:38 UTC, Vijay Nayar wrote: Is there a way to either have a constant reference to a class that can be set to a new value, or is there a way to convert the class variable to a class pointer? Alex has mentioned Rebindable, which is the answer to your first

Re: New With Struct and Getting Class Object Pointers

2018-09-30 Thread Vijay Nayar via Digitalmars-d-learn
On Sunday, 30 September 2018 at 10:28:25 UTC, Alex wrote: On Sunday, 30 September 2018 at 09:30:38 UTC, Vijay Nayar wrote: Is there a way to either have a constant reference to a class that can be set to a new value, or is there a way to convert the class variable to a class pointer? I

Re: New With Struct and Getting Class Object Pointers

2018-09-30 Thread Alex via Digitalmars-d-learn
On Sunday, 30 September 2018 at 09:30:38 UTC, Vijay Nayar wrote: Is there a way to either have a constant reference to a class that can be set to a new value, or is there a way to convert the class variable to a class pointer? For example: void main() { class Thing {} class

Re: New With Struct and Getting Class Object Pointers

2018-09-30 Thread Vijay Nayar via Digitalmars-d-learn
On Sunday, 30 September 2018 at 09:16:42 UTC, Nicholas Wilson wrote: On Sunday, 30 September 2018 at 07:29:00 UTC, Vijay Nayar wrote: Second question. const class variables may not be re-assigned, so if you need a variable that may be reassigned, but may never modify the underlying object

Re: New With Struct and Getting Class Object Pointers

2018-09-30 Thread Nicholas Wilson via Digitalmars-d-learn
underlying object, a const pointer can be useful. However, it seems that when gets the address of a class variable, you do not get the underlying address of the class object. How do you get a pointer to the underlying class object? Example of the problem: void main() { import

Re: New With Struct and Getting Class Object Pointers

2018-09-30 Thread rikki cattermole via Digitalmars-d-learn
On 30/09/2018 8:29 PM, Vijay Nayar wrote: I have two brief questions. Code that uses "new" to create struct objects appears to compile and run. Is this an actual language feature, to get structs on the heap? void main() { struct S {int data = 1;} S* s1 = new S(); S* s2 = s1;  

New With Struct and Getting Class Object Pointers

2018-09-30 Thread Vijay Nayar via Digitalmars-d-learn
// Still copies on assignment. s3.data = 2; assert(s1.data != s3.data); } Second question. const class variables may not be re-assigned, so if you need a variable that may be reassigned, but may never modify the underlying object, a const pointer can be useful. However, it seems

Re: Mutable ForwardRange save() method not callable using const object

2018-09-04 Thread Jonathan M Davis via Digitalmars-d-learn
ribute > would become a "promise" rather than an enforcement (or too hard > for the compiler to enforce). That's simply not how const or immutable work in D though. They're actual compiler guarantees, and it's undefined behavior to ever cast away const or immutable and mutate the object.

Re: Mutable ForwardRange save() method not callable using const object

2018-09-04 Thread Timoses via Digitalmars-d-learn
On Tuesday, 4 September 2018 at 14:26:44 UTC, Steven Schveighoffer wrote: [...] As general advice, I wouldn't expect const to work well with Ranges anyway -- const ranges are useless (you can't iterate them). So not much code is expecting to handle const, including the wrappers that Phobos

Re: Mutable ForwardRange save() method not callable using const object

2018-09-04 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/4/18 9:53 AM, Timoses wrote: Hey, I'm fiddling around with ranges a bit and am wondering why save is not callable on a const object: ... I could imagine that save is not marked as const because it is uncertain whether any indirections are part of the content..? But couldn't

Mutable ForwardRange save() method not callable using const object

2018-09-04 Thread Timoses via Digitalmars-d-learn
Hey, I'm fiddling around with ranges a bit and am wondering why save is not callable on a const object: class Range { ForwardRange!(const uint) offsets; this(const S s) { this.offsets = s.s.map!(e => e.i).inputRangeObj

Re: Can passing an address of this to a non-copyable object be made trusted? - i.e. can I disable moving?

2018-08-27 Thread aliak via Digitalmars-d-learn
not possible. So, if you have a type where it won't work properly if it's ever moved, then either you need to rethink what you're doing, or you must be _very_ careful with how you use any object of that type so that you don't ever use it in a way that even might result in it being moved

Re: Can passing an address of this to a non-copyable object be made trusted? - i.e. can I disable moving?

2018-08-26 Thread Jonathan M Davis via Digitalmars-d-learn
> Not sure abut the current language but DIP1014 > https://github.com/dlang/DIPs/blob/master/DIPs/DIP1014.md#final-review > > "The point was made that allowing opPostMove to be overidden > raises the question of what to do when it is annotated with > @disable. The concensus was that, in suc

Re: Can passing an address of this to a non-copyable object be made trusted? - i.e. can I disable moving?

2018-08-26 Thread Nicholas Wilson via Digitalmars-d-learn
it is annotated with @disable. The concensus was that, in such a case, an actual attempt to move the object would result in a compilation error." So, soon™?

Can passing an address of this to a non-copyable object be made trusted? - i.e. can I disable moving?

2018-08-26 Thread aliak via Digitalmars-d-learn
So if we had this: struct A(T) { auto proxy() @trusted { return B!T(); } } struct B(T) { private A!T* source; private this(A!T* s) { source = s; } @disable this(); @disable this(this) {} @disable void opAssign(B!T); } In order for f to be "safe" I need to ensure that B!T()

Re: Memory corruption with COM object

2018-07-09 Thread Kagamin via Digitalmars-d-learn
You can enable logging in GC and see what's allocated and collected.

Memory corruption with COM object

2018-07-06 Thread Rene Zwanenburg via Digitalmars-d-learn
was the GC was collecting things still in use, and disabling the GC does indeed 'fix' the problem. Looking through comhelpers, the code doesn't add a GC root for a created object before handing it off to the C side. I've added root adding and removing, expecting that to fix the problem. However

Re: Call different member functions on object sequence with a generic handler function?

2018-07-01 Thread Timoses via Digitalmars-d-learn
On Sunday, 1 July 2018 at 06:55:35 UTC, Robert M. Münch wrote: The looping needs to be done in the handler because there are two loops running one after the other and the range to loop over is detected in the handler too. Otherwise a lot of code duplication would happen. Maybe an

Re: Call different member functions on object sequence with a generic handler function?

2018-07-01 Thread Basile B. via Digitalmars-d-learn
On Sunday, 1 July 2018 at 06:55:35 UTC, Robert M. Münch wrote: On 2018-06-30 22:53:47 +, Jerry said: Btw this is pretty much std.algorithm.each import std.algorithm; void main() { auto cs = [ new C(), new C() ]; cs.each!(o => o.A()); }

Re: Call different member functions on object sequence with a generic handler function?

2018-07-01 Thread Robert M. Münch via Digitalmars-d-learn
On 2018-06-30 22:53:47 +, Jerry said: Btw this is pretty much std.algorithm.each import std.algorithm; void main() { auto cs = [ new C(), new C() ]; cs.each!(o => o.A()); } https://dlang.org/phobos/std_algorithm_iteration.html#.each The looping needs to be done in the handler

Re: Call different member functions on object sequence with a generic handler function?

2018-06-30 Thread Jerry via Digitalmars-d-learn
On Friday, 29 June 2018 at 20:23:47 UTC, Timoses wrote: void handler(alias func, T)(T[] ts) { } Btw this is pretty much std.algorithm.each import std.algorithm; void main() { auto cs = [ new C(), new C() ]; cs.each!(o => o.A()); }

Re: Call different member functions on object sequence with a generic handler function?

2018-06-30 Thread Basile B. via Digitalmars-d-learn
On Saturday, 30 June 2018 at 00:16:49 UTC, Basile B. wrote: On Friday, 29 June 2018 at 16:44:36 UTC, Robert M. Münch wrote: I hope this is understandable... I have: class C { void A(); void B(); void C(); } I'm iterating over a set of objects of class C like:

Re: Call different member functions on object sequence with a generic handler function?

2018-06-29 Thread Ali Çehreli via Digitalmars-d-learn
On 06/29/2018 02:11 PM, Timoses wrote: > How would one print the address of the object then though? > Since is the address of the reference' types stack location. Casting the reference to void* produces the address of the object: import std.stdio; class C { int i; } voi

Re: Call different member functions on object sequence with a generic handler function?

2018-06-29 Thread Ali Çehreli via Digitalmars-d-learn
On 06/29/2018 02:40 PM, Robert M. Münch wrote: > How does it work if one of the members takes an argument that is deduced > inside the handler function? > > > On 2018-06-29 18:05:00 +, Ali ‡ehreli said: > >> Passing a lambda or a string mixin: >> >> import std.stdio; >> >> class C { >>

Re: Call different member functions on object sequence with a generic handler function?

2018-06-29 Thread Basile B. via Digitalmars-d-learn
On Friday, 29 June 2018 at 16:44:36 UTC, Robert M. Münch wrote: I hope this is understandable... I have: class C { void A(); void B(); void C(); } I'm iterating over a set of objects of class C like: foreach(obj; my_selected_objs){ ... } The iteration and code

Re: Call different member functions on object sequence with a generic handler function?

2018-06-29 Thread Robert M. Münch via Digitalmars-d-learn
How does it work if one of the members takes an argument that is deduced inside the handler function? On 2018-06-29 18:05:00 +, Ali ‡ehreli said: Passing a lambda or a string mixin: import std.stdio; class C { void A() { writeln(__FUNCTION__); } void B() {

Re: Call different member functions on object sequence with a generic handler function?

2018-06-29 Thread Timoses via Digitalmars-d-learn
delegate() del; A a = new A(); del.ptr = a; // NOT its address, as that would be the address of the reference on the stack B b = B(); del.ptr =// value type => address of object in stack ... How would one print the address of the object then though? Since is the address of the refere

Re: Call different member functions on object sequence with a generic handler function?

2018-06-29 Thread Timoses via Digitalmars-d-learn
On Friday, 29 June 2018 at 16:44:36 UTC, Robert M. Münch wrote: I hope this is understandable... I have: class C { void A(); void B(); void C(); } I'm iterating over a set of objects of class C like: foreach(obj; my_selected_objs){ ... } The iteration and code

Re: Call different member functions on object sequence with a generic handler function?

2018-06-29 Thread Timoses via Digitalmars-d-learn
On Friday, 29 June 2018 at 20:08:56 UTC, Robert M. Münch wrote: On 2018-06-29 18:05:00 +, Ali ‡ehreli said: On 06/29/2018 09:44 AM, Robert M. Münch wrote: void handler(alias func)(C[] cs) { foreach (c; cs) { func(c); } } Is it possible to make C[] a template type so

Re: Call different member functions on object sequence with a generic handler function?

2018-06-29 Thread Robert M. Münch via Digitalmars-d-learn
On 2018-06-29 18:05:00 +, Ali ‡ehreli said: On 06/29/2018 09:44 AM, Robert M. Münch wrote: So, how can I write a generic handler that does the iteration, where I can specify which member function to call? Passing a lambda or a string mixin: Hi, that was somehow in my mind but didn't

Re: Call different member functions on object sequence with a generic handler function?

2018-06-29 Thread Ali Çehreli via Digitalmars-d-learn
On 06/29/2018 09:44 AM, Robert M. Münch wrote: So, how can I write a generic handler that does the iteration, where I can specify which member function to call? Passing a lambda or a string mixin: import std.stdio; class C { void A() { writeln(__FUNCTION__); } void B()

Call different member functions on object sequence with a generic handler function?

2018-06-29 Thread Robert M. Münch via Digitalmars-d-learn
I hope this is understandable... I have: class C { void A(); void B(); void C(); } I'm iterating over a set of objects of class C like: foreach(obj; my_selected_objs){ ... } The iteration and code before/afterwards always looks the same, I need this iteration

Re: OT: Parsing object files for fun and profit

2018-05-31 Thread Patrick Schluter via Digitalmars-d-learn
;resource" file was just an object file compiled from a simple C source code which had just an array of strings in it: char * texts[] = { "yes", "no", // ... }; I parsed the object file to generate C source code, translated the C source code, and finally compil

OT: Parsing object files for fun and profit

2018-05-31 Thread Ali Çehreli via Digitalmars-d-learn
Research and Wordperfect products (around 1989-1992). Localizing by patching compiled code was fun. :) My happiest accomplishment was localizing Ventura Publisher "cleanly" after realizing that their language-related "resource" file was just an object file compiled from a simple

Re: Assigning a method name to a variable and then calling it with an object

2018-05-24 Thread aliak via Digitalmars-d-learn
On Thursday, 24 May 2018 at 23:08:29 UTC, Basile B. wrote: On Thursday, 24 May 2018 at 23:03:21 UTC, aliak wrote: Hi, I was essentially trying to do this: struct S { void f() {} } auto f = S.f; // f becomes void function(S) ?? S s; f(s); Is something like that possible? Cheers, - Ali

Re: Assigning a method name to a variable and then calling it with an object

2018-05-24 Thread Basile B. via Digitalmars-d-learn
On Thursday, 24 May 2018 at 23:03:21 UTC, aliak wrote: Hi, I was essentially trying to do this: struct S { void f() {} } auto f = S.f; // f becomes void function(S) ?? S s; f(s); Is something like that possible? Cheers, - Ali Sure: ``` import std.stdio; void main(string[] args) {

Assigning a method name to a variable and then calling it with an object

2018-05-24 Thread aliak via Digitalmars-d-learn
Hi, I was essentially trying to do this: struct S { void f() {} } auto f = S.f; // f becomes void function(S) ?? S s; f(s); Is something like that possible? Cheers, - Ali

Re: pointer to object resolution

2018-05-11 Thread Alex via Digitalmars-d-learn
On Friday, 11 May 2018 at 15:24:08 UTC, Steven Schveighoffer wrote: On 5/11/18 8:53 AM, Alex wrote: This behaves differently, w.r.t. to an arbitrary method, like "operator". Why? Is there any workaround? operators don't follow pointers. Imagine if you had a struct that overloads "+" and

Re: pointer to object resolution

2018-05-11 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/11/18 8:53 AM, Alex wrote: This behaves differently, w.r.t. to an arbitrary method, like "operator". Why? Is there any workaround? operators don't follow pointers. Imagine if you had a struct that overloads "+" and then you wanted to use pointer arithmetic, but instead it called

pointer to object resolution

2018-05-11 Thread Alex via Digitalmars-d-learn
Hi all, I'm sure, I didn't find something obvious, but: Given this: ´´´ void main() { auto s = S(); s.operator; assert(s.myOp(42)); assert(42 in s); auto sptr = new S(); sptr.operator; assert(sptr.myOp(42)); //assert(42 in sptr);

Re: Interfacing with C++ Class named Object

2018-05-01 Thread Robert M. Münch via Digitalmars-d-learn
On 2018-05-01 17:14:53 +, Robert M. Münch said: Yes, great! Thanks. I could extend the code now. But I get a next problem: extern (C++, b2d) { class AnyBase { bool isShared(); } pragma(mangle, "Object"); class b2dObject : AnyBase { } class Image : b2dObject {

Re: Interfacing with C++ Class named Object

2018-05-01 Thread Robert M. Münch via Digitalmars-d-learn
in namespace N: class Image : public Object { Error create(int w, int h, uint32_t p) noexcept; } And I have the following D code: extern (C++, N) { class Object { } class Image : public Object { uint create(int w, int h, uint pixelFormat); } } So frist problem I see is, that a C++ class names

Re: Interfacing with C++ Class named Object

2018-05-01 Thread Timoses via Digitalmars-d-learn
On Tuesday, 1 May 2018 at 15:24:09 UTC, Robert M. Münch wrote: Hi, I'm mostly doing simple C-API wrappers around C++ code to access thigns from D. However, I wanted to try how far I can come using C++ directly. I have the following C++ code in namespace N: class Image : public Object

Interfacing with C++ Class named Object

2018-05-01 Thread Robert M. Münch via Digitalmars-d-learn
Hi, I'm mostly doing simple C-API wrappers around C++ code to access thigns from D. However, I wanted to try how far I can come using C++ directly. I have the following C++ code in namespace N: class Image : public Object { Error create(int w, int h, uint32_t p) noexcept; } And I have

Re: Initializing a class member that is an object

2018-03-30 Thread Laurent Tréguier via Digitalmars-d-learn
On Friday, 30 March 2018 at 11:14:32 UTC, ketmar wrote: please, make an ER in bugzilla then. 'cause it will be lost here, and with ER we have a chance to eventually do that. Will do.

Re: Initializing a class member that is an object

2018-03-30 Thread ketmar via Digitalmars-d-learn
Laurent Tréguier wrote: On Friday, 30 March 2018 at 11:04:59 UTC, ketmar wrote: p.s.: still, it may be nice to warn user about that. 'cause such runtime initializations are really belong to static ctor. dunno, i'm ok both with warning and without it. I simply think a word about it in the

Re: Initializing a class member that is an object

2018-03-30 Thread Laurent Tréguier via Digitalmars-d-learn
On Friday, 30 March 2018 at 11:04:59 UTC, ketmar wrote: p.s.: still, it may be nice to warn user about that. 'cause such runtime initializations are really belong to static ctor. dunno, i'm ok both with warning and without it. I simply think a word about it in the docs would be nice, since

Re: Initializing a class member that is an object

2018-03-30 Thread ketmar via Digitalmars-d-learn
p.s.: still, it may be nice to warn user about that. 'cause such runtime initializations are really belong to static ctor. dunno, i'm ok both with warning and without it.

Re: Initializing a class member that is an object

2018-03-30 Thread ketmar via Digitalmars-d-learn
Laurent Tréguier wrote: Is this behavior really intentional ? yes. default values should be the same for all objects. it is predictable, and allows to initialize objects to the known state simply by blitting `.init`. that is, default values aren't a syntax sugar for defining implicit ctor

Initializing a class member that is an object

2018-03-30 Thread Laurent Tréguier via Digitalmars-d-learn
Coming from a more Java-esque background, I'm used to sometimes initializing class members outside of the constructor : class MyClass { Object member = new Object(); } I've tried using this in D, but I've come to realize it acts very differently. In Java, the `new Object

Re: docs/definition: !object

2018-03-08 Thread Nick Sabalausky (Abscissa) via Digitalmars-d-learn
On 03/08/2018 05:31 AM, Steven Schveighoffer wrote: On 3/8/18 1:00 AM, Nick Sabalausky (Abscissa) wrote: But are we CERTAIN that's all there is to it? I have a non-reduced situation right now where outputting the address of a class reveals a non-null address, and yet

Re: docs/definition: !object

2018-03-08 Thread Steven Schveighoffer via Digitalmars-d-learn
On 3/8/18 1:00 AM, Nick Sabalausky (Abscissa) wrote: On 03/08/2018 12:05 AM, ketmar wrote: Nick Sabalausky (Abscissa) wrote: I'm having trouble finding the documentation for what exactly the unary "not" operator does when applied to a class/interface object. Does this documenta

Re: docs/definition: !object

2018-03-07 Thread ketmar via Digitalmars-d-learn
Nick Sabalausky (Abscissa) wrote: (Or does return the address of the *reference* to the object rather than the address of the object?...You can see just how often I do OO in D ;) ) exactly. if you want to convert object to a pointer safely, do this: MyObject o; void* p

Re: docs/definition: !object

2018-03-07 Thread Nick Sabalausky (Abscissa) via Digitalmars-d-learn
On 03/08/2018 12:05 AM, ketmar wrote: Nick Sabalausky (Abscissa) wrote: I'm having trouble finding the documentation for what exactly the unary "not" operator does when applied to a class/interface object. Does this documentation exist somewhere? I know at least part of it involve

Re: docs/definition: !object

2018-03-07 Thread ketmar via Digitalmars-d-learn
Nick Sabalausky (Abscissa) wrote: I'm having trouble finding the documentation for what exactly the unary "not" operator does when applied to a class/interface object. Does this documentation exist somewhere? I know at least part of it involves "is null", but I seem

docs/definition: !object

2018-03-07 Thread Nick Sabalausky (Abscissa) via Digitalmars-d-learn
I'm having trouble finding the documentation for what exactly the unary "not" operator does when applied to a class/interface object. Does this documentation exist somewhere? I know at least part of it involves "is null", but I seem to remember hearing there was more to it than just that.

Re: string object won't compile

2018-03-05 Thread askjfbd via Digitalmars-d-learn
On Monday, 5 March 2018 at 23:42:59 UTC, Adam D. Ruppe wrote: On Monday, 5 March 2018 at 23:34:50 UTC, askjfbd wrote: string.d The problem is you named the file string.d and didn't give a `module x;` statement in the code, so the compiler assumed the module is named after the file

Re: string object won't compile

2018-03-05 Thread askjfbd via Digitalmars-d-learn
On Tuesday, 6 March 2018 at 00:18:14 UTC, psychoticRabbit wrote: On Monday, 5 March 2018 at 23:34:50 UTC, askjfbd wrote: Someone please tell me how, for I am a newbie and don't know any solutions even to this very simple problem. As I learned dlang using the Dlang tour page, I stuck at the

Re: string object won't compile

2018-03-05 Thread psychoticRabbit via Digitalmars-d-learn
On Monday, 5 March 2018 at 23:34:50 UTC, askjfbd wrote: Someone please tell me how, for I am a newbie and don't know any solutions even to this very simple problem. As I learned dlang using the Dlang tour page, I stuck at the alias & Strings page. I have tried to compile the following simple

Re: string object won't compile

2018-03-05 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 5 March 2018 at 23:34:50 UTC, askjfbd wrote: string.d The problem is you named the file string.d and didn't give a `module x;` statement in the code, so the compiler assumed the module is named after the file and thus introduced a local name `string` referring to the

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: 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: 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

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: Get largest heap object at runtime? ...tracking the leak

2018-01-22 Thread thedeemon via Digitalmars-d-learn
On Monday, 22 January 2018 at 16:37:19 UTC, Andres Clari wrote: All threads withing a process share the same heap, so whatever one thread allocated in that heap is not freed or reclaimed automatically when thread dies, it stays in the heap. Well the destructor of some Json objects and strings

Re: Get largest heap object at runtime? ...tracking the leak

2018-01-22 Thread Andres Clari via Digitalmars-d-learn
On Monday, 22 January 2018 at 15:56:53 UTC, thedeemon wrote: On Monday, 22 January 2018 at 06:48:00 UTC, Andres Clari wrote: Not sure why "spawn" would leak like that tho. I would assume that once the thread exits, it would get destroyed and it's resources reclaimed, specially when I have

Re: Get largest heap object at runtime? ...tracking the leak

2018-01-22 Thread thedeemon via Digitalmars-d-learn
On Monday, 22 January 2018 at 06:48:00 UTC, Andres Clari wrote: Not sure why "spawn" would leak like that tho. I would assume that once the thread exits, it would get destroyed and it's resources reclaimed, specially when I have calls to "GC.collect and GC.minimize". All threads withing a

Re: Get largest heap object at runtime? ...tracking the leak

2018-01-21 Thread Andres Clari via Digitalmars-d-learn
On Monday, 22 January 2018 at 06:15:24 UTC, Dmitry Olshansky wrote: On Sunday, 21 January 2018 at 17:28:13 UTC, Andres Clari wrote: Hi, is there any way to get from the GC all allocated objects, so I can see their size and find where I'm leaking memory? Or perhaps a good tool to help with this

<    1   2   3   4   5   6   7   8   9   10   >