Re: dmd asm output

2013-04-01 Thread js.mdnq
On Monday, 1 April 2013 at 01:54:10 UTC, John Colvin wrote: I've been learning assembler a bit and I decided to have a look at what dmd spits out. I tried a simple function with arrays to see what vectorization gets done void addto(int[] a, int[] b) { a[] += b[]; } dmd -O -release

__FUNCTION__?

2013-02-25 Thread js.mdnq
We have __FILE__ and __LINE__. Is there a __FUNCTION__ that gives the current function name? This helps with errors.

Re: static code generation

2012-12-20 Thread js.mdnq
On Thursday, 20 December 2012 at 04:17:48 UTC, r_m_r wrote: On 12/18/2012 04:42 AM, js.mdnq wrote: It looks like the approach 2 does what I'm looking for pretty nicely except that, If I'm not mistaken the user struct will error out when trying to access members from the master. Another

alias this/opGet and opCast conversion

2012-12-17 Thread js.mdnq
This i probably a rather dumb question but I've been up all night and therefor have a really good excuse ;) (I can barely see straight...) Is opGet the reverse opAssign? I can't find any docs on it but it does let me write converters from my type to another type. e.g., struct X { int

Re: static code generation

2012-12-17 Thread js.mdnq
On Monday, 17 December 2012 at 22:24:58 UTC, r_m_r wrote: On 12/17/2012 04:33 AM, js.mdnq wrote: Well, it a slightly another way and close. Let me see if I can come up with something that expresses better what I'm after. It will be a week or two though till I get around to it probably. OK

Re: alias this/opGet and opCast conversion

2012-12-17 Thread js.mdnq
On Monday, 17 December 2012 at 15:46:22 UTC, anonymous wrote: On Monday, 17 December 2012 at 15:10:24 UTC, js.mdnq wrote: This i probably a rather dumb question but I've been up all night and therefor have a really good excuse ;) (I can barely see straight...) Is opGet the reverse opAssign

Re: variable x cannot be read at compile time (ctfe)

2012-12-17 Thread js.mdnq
On Monday, 17 December 2012 at 22:47:33 UTC, bearophile wrote: maarten van damme: How do I make dmd output asm? You can't, unfortunately. They closed this enhancement request of mine because they say DMD is not designed for this. On Linux there are several disassemblers, I use objdump. On

Re: static code generation

2012-12-16 Thread js.mdnq
On Sunday, 16 December 2012 at 01:32:44 UTC, r_m_r wrote: On 12/16/2012 06:36 AM, r_m_r wrote: this is the closest I can get: http://dpaste.dzfl.pl/9d11d060 Cleaned up a bit: http://dpaste.dzfl.pl/d9f001db regards, r_m_r That looks like it might be pretty close. I was also thinking that

Re: static code generation

2012-12-16 Thread js.mdnq
On Sunday, 16 December 2012 at 06:38:13 UTC, anonymous wrote: On Saturday, 15 December 2012 at 16:32:27 UTC, r_m_r wrote: On 12/15/2012 08:57 PM, anonymous wrote: Note that here s1alpha and s2alpha are distinct types. what about this: http://dpaste.dzfl.pl/95f7a74d Consider struct Foo

Re: std.math.approxEqual, 'maxRelDiff' parameter?

2012-12-16 Thread js.mdnq
On Saturday, 15 December 2012 at 19:01:23 UTC, ref2401 wrote: What does means 'maxRelDiff' parameter? I looked at the source code of this method and I still didn't get it. return fabs((lhs - rhs) / rhs) = maxRelDiff || maxAbsDiff != 0 fabs(lhs - rhs) = maxAbsDiff; In what cases can I use

Re: static code generation

2012-12-16 Thread js.mdnq
On Sunday, 16 December 2012 at 15:34:34 UTC, Philippe Sigaud wrote: One could also think of it as an algebra of structs. It would be nice to be able to do stuff like A + B, A - B(possibly useless), A*B(possibly useless), etc... A + B would just combine the members, A - B could remove the

Re: static code generation

2012-12-16 Thread js.mdnq
On Sunday, 16 December 2012 at 20:29:19 UTC, r_m_r wrote: On 12/16/2012 02:03 PM, js.mdnq wrote: That looks like it might be pretty close. I was also thinking that one could just use mixin templates of trying to do it with structs directly. i dunno if this is what u want, but have a look

Re: alias type reduction

2012-12-16 Thread js.mdnq
On Sunday, 16 December 2012 at 15:21:17 UTC, Philippe Sigaud wrote: The real issue I'm having now is not having to mangle the names and hide the `_NestLevel` and `_Offset` dependencies. alias works for the case of one template argument to _A. Simply `alias _A!(true) A`. But when I have

Re: Get class type parameters at compile time

2012-12-16 Thread js.mdnq
On Saturday, 15 December 2012 at 21:49:51 UTC, Philippe Sigaud wrote: Oops ;/ How do I get the number of type arguments if I don't know them yet? I know this sort of seems wrong but somehow, to know how to alias the class I need to know it's number of arguments. (I don't think it makes too

Re: Get class type parameters at compile time

2012-12-16 Thread js.mdnq
I see now why it was returning a bool as that is the type of the template argument passed. class A(bool x = true) then your TemplateArgs returns `tuple(bool)`. What I'm looking for is something that returns `(x)`. For class A(T1, T2, bool x = true) I would like `(T1, T2, x)`. To see why

Compile time string manipulation

2012-12-15 Thread js.mdnq
How do we manipulate strings at compile time when using static ifs? static if (std.string.indexOf(S, )) -1) ... else ... This always returns false regardless if S contains a 7 or not. from http://dpaste.dzfl.pl/64025e0a mixin(StructNestType!(B, b1)); but I would like to modify so

Re: Compile time string manipulation

2012-12-15 Thread js.mdnq
On Saturday, 15 December 2012 at 12:33:13 UTC, bearophile wrote: js.mdnq: static if (std.string.indexOf(S, )) -1) ... else ... This always returns false regardless if S contains a 7 or not. If it doesn't find the substring it returns -1, so that's always false. So use: S.indexOf

Re: Why are const strings used in templates for compile time found in exe

2012-12-15 Thread js.mdnq
On Saturday, 15 December 2012 at 13:16:17 UTC, anonymous wrote: On Saturday, 15 December 2012 at 13:08:01 UTC, js.mdnq wrote: The following code http://dpaste.dzfl.pl/64025e0a when compiled, has all the static and const char[] strings used only for compile time inside the executable. How

Re: static code generation

2012-12-15 Thread js.mdnq
On Saturday, 15 December 2012 at 19:09:25 UTC, r_m_r wrote: On 12/10/2012 01:24 AM, js.mdnq wrote: which will fail or not be what I want, since I want to generate the structs s1 and s1. how about this: http://dpaste.dzfl.pl/c0325def regards, r_m_r Cool, That looks like a step

Re: alias type reduction

2012-12-15 Thread js.mdnq
On Saturday, 15 December 2012 at 22:21:21 UTC, Philippe Sigaud wrote: If you don't mind, could you see if your solutions work on the following code: http://dpaste.dzfl.pl/64025e0a What you're doing here is a bit different (AFAICT). _A is a template, not a 'real' class. So, it has no

Re: static code generation

2012-12-15 Thread js.mdnq
On Saturday, 15 December 2012 at 23:04:37 UTC, r_m_r wrote: On 12/16/2012 04:00 AM, js.mdnq wrote: Now, the next step is to be able to insert code into the struct! ;) how about this: http://dpaste.dzfl.pl/8161d00a regards, r_m_r No, it's backwards! ;) Or, sort of what one wants to do

Re: alias type reduction

2012-12-14 Thread js.mdnq
On Friday, 14 December 2012 at 05:54:33 UTC, Philippe Sigaud wrote: Ok, I'll try again. when I was doing it I would get circular referencing but maybe I did something wrong... Another possibility is to use `.A`: the (.) prefix means the symbol is looked in the external scope, not inside

Re: Get class type parameters at compile time

2012-12-14 Thread js.mdnq
On Friday, 14 December 2012 at 20:14:29 UTC, Philippe Sigaud wrote: On Fri, Dec 14, 2012 at 1:18 AM, bearophile bearophileh...@lycos.comwrote: Fit to be added to Phobos? Maybe, I don't know. People seem to ask for this quite regularly. Here is a slightly improved version, what do you

Get class type parameters at compile time

2012-12-13 Thread js.mdnq
I need to get the number of type parameters of a class at compile time: class a(T1, T2, ...) { static if (a.TypeInfo.NumParameters == 1) else } Is this possible?

Re: alias type reduction

2012-12-13 Thread js.mdnq
On Thursday, 13 December 2012 at 10:03:34 UTC, anonymous wrote: On Thursday, 13 December 2012 at 09:29:46 UTC, js.mdnq wrote: class _A(T, _NestLevel) { } alias _A!(T, true) A!(T) // - does not work but essentially what I want template A(T) { alias _A!(T, true) A; } (or even better

Re: static code generation

2012-12-13 Thread js.mdnq
On Thursday, 13 December 2012 at 06:26:15 UTC, dennis luehring wrote: Am 13.12.2012 04:32, schrieb js.mdnq: I think the issue I have with all this is that when you put code inside a string you lose a lot of compile time features AFAICT. your right - but...try to come up with an similar (easy

Re: alias type reduction

2012-12-13 Thread js.mdnq
On Thursday, 13 December 2012 at 22:16:00 UTC, Philippe Sigaud wrote: yeah, I tried that and got errors, I guess it works now. I still can't use the same class name as the alias though because I get a recursion error. It's not a huge deal but would be nicer to not have to mangle the class

Re: Get class type parameters at compile time

2012-12-13 Thread js.mdnq
On Thursday, 13 December 2012 at 22:10:40 UTC, Philippe Sigaud wrote: On Thu, Dec 13, 2012 at 11:56 AM, js.mdnq js_adddot+m...@gmail.com wrote: I need to get the number of type parameters of a class at compile time: class a(T1, T2, ...) { static if (a.TypeInfo.NumParameters == 1

Re: static code generation p2

2012-12-12 Thread js.mdnq
On Thursday, 13 December 2012 at 01:09:28 UTC, js.mdnq wrote: Take the example here: http://forum.dlang.org/thread/vrupqijwqmccdpabm...@forum.dlang.org note how he provides the body of the method in the mixin. I would like to something similar to what he has done but provide the body

Re: static code generation

2012-12-12 Thread js.mdnq
On Monday, 10 December 2012 at 22:01:37 UTC, Ali Çehreli wrote: On 12/10/2012 01:52 PM, js.mdnq wrote: I want to avoid having to wrap the code with as it disables highlighting and possibly other features(intellisense, etc...)) The q{} syntax is supposed to help with that issue. Emacs

Re: static code generation

2012-12-10 Thread js.mdnq
On Monday, 10 December 2012 at 20:17:41 UTC, Philippe Sigaud wrote: If I'm not mistaken isn't the code I'm trying to generate still in a string? Well, yes, but not when you mix it in. It's a string mixin in this case, not a template mixin. My whole point is not to use strings to insert

Re: alias this private?

2012-12-10 Thread js.mdnq
On Monday, 10 December 2012 at 07:48:37 UTC, Ali Çehreli wrote: On 12/09/2012 10:43 PM, js.mdnq wrote: I thought `alias this` essentially treats the object as the alias. struct A { alias value this; int value; void func(); } A a; then a is essentially the same as a.value? No. 'alias

overlapping structs

2012-12-10 Thread js.mdnq
This gets back to my question about nested structs(since I'm trying to find a way to make it work). Take the following working example: class A { struct B { A* a; } B b1; B b2; } Wastes a lot of space as we store a ptr to A for each field we use. If there were 100 B

Re: Type value

2012-12-10 Thread js.mdnq
On Monday, 10 December 2012 at 19:54:51 UTC, Zhenya wrote: Hi! In some previous post I asked about possibility of declar opIndex,that return type. I thoght about it,and I understood that code like this is legal: struct Type(T) { alias T m_type; alias m_type this; } void

Re: static code generation

2012-12-10 Thread js.mdnq
On Monday, 10 December 2012 at 22:01:37 UTC, Ali Çehreli wrote: On 12/10/2012 01:52 PM, js.mdnq wrote: I want to avoid having to wrap the code with as it disables highlighting and possibly other features(intellisense, etc...)) The q{} syntax is supposed to help with that issue. Emacs

Re: Type value

2012-12-10 Thread js.mdnq
On Tuesday, 11 December 2012 at 07:15:38 UTC, Zhenya wrote: I'm sorry for my english. I know that D != Python and my example don't need any RTTI. D has alias this feature.My example shows that we can use alias this with types. And I just want use this: struct Type(T) { alias T m_type;

Re: alias this private?

2012-12-09 Thread js.mdnq
On Sunday, 9 December 2012 at 08:27:45 UTC, Ali Çehreli wrote: On 12/08/2012 11:05 PM, js.mdnq wrote: Can it not be possible to use alias this on a private field? I've just tested it. It is possible with dmd 2.060: struct Q { private: int _x; public: alias _x this; } void main

Re: struct in class access

2012-12-09 Thread js.mdnq
On Sunday, 9 December 2012 at 08:56:00 UTC, Maxim Fomin wrote: On Sunday, 9 December 2012 at 07:39:29 UTC, js.mdnq wrote: On Sunday, 9 December 2012 at 07:24:57 UTC, Jonathan M Davis wrote: On Sunday, December 09, 2012 07:54:25 js.mdnq wrote: Why can't a struct inside a class access

Re: struct in class access

2012-12-09 Thread js.mdnq
On Sunday, 9 December 2012 at 09:06:28 UTC, Maxim Fomin wrote: On Sunday, 9 December 2012 at 06:54:33 UTC, js.mdnq wrote: Why can't a struct inside a class access the members of that class without a this pointer? It would seem natural to me that a nested struct should probably be special

Re: alias this private?

2012-12-09 Thread js.mdnq
Actually, it doesn't seem to work ;/ Your code worked but mine does unless I make it public. It is a public/private issue and I get a ton of errors: module main; import std.stdio; class A { public: string Name; struct B(T) {

Re: static code generation

2012-12-09 Thread js.mdnq
On Sunday, 9 December 2012 at 10:42:40 UTC, js.mdnq wrote: How can I create mixes of stringified code and code itself? http://dlang.org/mixin.html explains how to create structs using strings. But what if I do not want to have to encode the whole struct as a string but only parts

Re: static code generation

2012-12-09 Thread js.mdnq
On Sunday, 9 December 2012 at 11:25:25 UTC, Philippe Sigaud wrote: You can use a templated string-returning function and mix it in: string codeGenerator(compileTimeArguments, Other...)(Other others) { string result = ... (...) // build your code here return result; } (...)

Re: alias this private?

2012-12-09 Thread js.mdnq
On Sunday, 9 December 2012 at 16:50:55 UTC, Ali Çehreli wrote: On 12/09/2012 01:42 AM, js.mdnq wrote: Actually, it doesn't seem to work ;/ Your code worked but mine does unless I make it public. It is a public/private issue and I get a ton of errors: This is not adding to the discussion

Re: static code generation

2012-12-09 Thread js.mdnq
On Sunday, 9 December 2012 at 19:09:49 UTC, anonymous wrote: On Sunday, 9 December 2012 at 10:42:40 UTC, js.mdnq wrote: How can I create mixes of stringified code and code itself? [...] mixin template GenStruct(stringname) { struct stringname ~ alpha { } } mixin

Re: static code generation

2012-12-09 Thread js.mdnq
On Sunday, 9 December 2012 at 19:34:05 UTC, anonymous wrote: On Sunday, 9 December 2012 at 19:24:24 UTC, js.mdnq wrote: In this particular case you can do this: mixin template GenStruct(string stringname) { struct S { } mixin(alias S ~ stringname ~ alpha;); } But what

Re: alias this private?

2012-12-09 Thread js.mdnq
On Sunday, 9 December 2012 at 19:38:28 UTC, Ali Çehreli wrote: On 12/09/2012 11:23 AM, js.mdnq wrote: but b is not private, only the internal representation of it. e.g., `alias Value_ this` is public. I do realize that it sort of makes Value_ and b one and the same but they are not quite

Re: alias this private?

2012-12-09 Thread js.mdnq
On Monday, 10 December 2012 at 04:50:17 UTC, Ali Çehreli wrote: On 12/09/2012 11:52 AM, js.mdnq wrote: Well, I would not say they are exactly the same. Do they have to be exactly the same? You are showing a method that fails to satisfy a requirement, I show another method which according

struct in class access

2012-12-08 Thread js.mdnq
Why can't a struct inside a class access the members of that class without a this pointer? It would seem natural to me that a nested struct should probably be special in that it is really just a special container to reduce clutter in the class. class a { string v; struct b { void fun()

alias this private?

2012-12-08 Thread js.mdnq
Can it not be possible to use alias this on a private field? struct Q private: int _x; public: alias _x this; ? Seems to me that one does not always want the user to access the internal value that is aliased ;/ Q q; q._x // error yet q, for all practical purposes is _x,

Re: struct in class access

2012-12-08 Thread js.mdnq
On Sunday, 9 December 2012 at 07:24:57 UTC, Jonathan M Davis wrote: On Sunday, December 09, 2012 07:54:25 js.mdnq wrote: Why can't a struct inside a class access the members of that class without a this pointer? It would seem natural to me that a nested struct should probably be special

Re: struct in class access

2012-12-08 Thread js.mdnq
... A a; What is the address of A? What is the address of x inside A? (i.e., the struct inside A?) I of course, mean a, which is why it's nice to have the ability to make an edit so I don't have to waste a post and/or someone else bloat the thread with A is a class, not an object, go

Re: Type polymorphism and type variance

2012-12-05 Thread js.mdnq
On Wednesday, 5 December 2012 at 03:59:29 UTC, Ali Çehreli wrote: On 12/04/2012 06:42 PM, js.mdnq wrote: One thing I've always struggled with in oop is how to deal with storing generic types. A very simple example is, suppose you had to design a way to store generic types. class myGtype(T

Re: Type polymorphism and type variance

2012-12-05 Thread js.mdnq
On Wednesday, 5 December 2012 at 22:53:11 UTC, Ali Çehreli wrote: On 12/05/2012 09:51 AM, js.mdnq wrote: (if your having trouble understanding the problem then just think of how you would efficiently store the nodes and edges of a directed acyclic graph. Each node is of a somewhat arbitrary

Type aliasing

2012-12-04 Thread js.mdnq
I have a static class that generates unique ID's. The id's are hardcoded as ints. I would like to make this extensible and allow for other integer numeric values to be(byte, ulong, etc...). I can simply make the static class generic without issues. The problem is the return type of the Get

Re: Type aliasing

2012-12-04 Thread js.mdnq
On Tuesday, 4 December 2012 at 16:42:21 UTC, Adam D. Ruppe wrote: On Tuesday, 4 December 2012 at 16:34:50 UTC, js.mdnq wrote: class myclass { int ID; } Try something like this: class myclass { typeof(uniqueID!T.Get()) ID; this() { ID = uniqueID!T.Get(); } } The typeof(expr

Default template type for class?

2012-12-04 Thread js.mdnq
I have a class static class myclass(T) { static void myfunc(); } which I have to call like myclass!Q.myfunc(); How can I create a default type so that I can call it like myclass.myfunc()? I've tried static class myclass(T = int) and (alias T = int), neither worked.

Re: How to import modules?

2012-12-04 Thread js.mdnq
On Tuesday, 4 December 2012 at 07:17:15 UTC, Mike Parker wrote: On Tuesday, 4 December 2012 at 04:31:40 UTC, js.mdnq wrote: I created a .d file having a class with the modules tag at the top and everything public. I put it in a dir and used the -I flag to include the path. When I import

Type polymorphism and type variance

2012-12-04 Thread js.mdnq
One thing I've always struggled with in oop is how to deal with storing generic types. A very simple example is, suppose you had to design a way to store generic types. class myGtype(T) { } ... myGType[] gcollection; // should store various types such as myGtype!int, myGtype!myobj,

Type polymorphism and type variance

2012-12-04 Thread js.mdnq
One thing I've always struggled with in oop is how to deal with storing generic types. A very simple example is, suppose you had to design a way to store generic types. class myGtype(T) { } ... myGType[] gcollection; // should store various types such as myGtype!int, myGtype!myobj, etc..,

Type polymorphism and type variance

2012-12-04 Thread js.mdnq
One thing I've always struggled with in oop is how to deal with storing generic types. A very simple example is, suppose you had to design a way to store generic types. class myGtype(T) { } ... myGType[] gcollection; // should store various types such as myGtype!int, myGtype!myobj, etc..,

Type polymorphism and type variance

2012-12-04 Thread js.mdnq
One thing I've always struggled with in oop is how to deal with storing generic types. A very simple example is, suppose you had to design a way to store generic types. class myGtype(T) { } ... myGType[] gcollection; // should store various types such as myGtype!int, myGtype!myobj, etc..,

Array indexing

2012-12-03 Thread js.mdnq
When accessing an element outside a dynamic array I get an exception. I thought in D arrays will automatically expand themselves? If not, how do I add an element to an array? int[] arr = new int[1]; arr[1] = 34; // exception If I change this to int[] arr = new int[2]; arr[1] = 34; Then it

How to import modules?

2012-12-03 Thread js.mdnq
I created a .d file having a class with the modules tag at the top and everything public. I put it in a dir and used the -I flag to include the path. When I import the file I get an undefined method. 1. Do I need to compile the .d file into a lib or can I just import the .d and have it included

Re: get address of object if opCast is overridden

2012-12-02 Thread js.mdnq
On Saturday, 1 December 2012 at 23:57:27 UTC, Artur Skawina wrote: On 12/01/12 20:26, Jonathan M Davis wrote: On Saturday, December 01, 2012 18:43:22 Timon Gehr wrote: On 12/01/2012 06:23 PM, Jonathan M Davis wrote: On Saturday, December 01, 2012 12:05:49 Artur Skawina wrote: So, unless

Initialize multi dimensional associative dynamic array

2012-12-02 Thread js.mdnq
How does one initialize an array defined as A[B][C] arr; dynamically? (A,B,C are types, for example, int[int][string]) I want to store an array, indexed by strings, of ints, indexed by ints. For example, What I want is a hash map that maps integers to integers so I can do something like

Re: DLL Injection

2012-12-01 Thread js.mdnq
On Saturday, 1 December 2012 at 11:24:51 UTC, s0beit wrote: Alright, at the end of my long search I have finally concluded that this is some sort of threading problem. Any D module loaded in a new thread, from a C/++ application will crash. The solution, I believe, in this case might be to

Re: get address of object if opCast is overridden

2012-12-01 Thread js.mdnq
On Saturday, 1 December 2012 at 11:06:02 UTC, Artur Skawina wrote: On 12/01/12 03:48, Jonathan M Davis wrote: On Saturday, December 01, 2012 03:05:00 js.mdnq wrote: Let O be an object with opCast overridden, then writeln(O); //prints string writeln(cast(void *)O)) // error, works fine if I

Re: alias this

2012-12-01 Thread js.mdnq
On Saturday, 1 December 2012 at 20:25:55 UTC, Rob T wrote: On Friday, 30 November 2012 at 23:11:28 UTC, js.mdnq wrote: I've seen that, how does it work? struct A{ Sometype val1; int val2; alias val1 this; alias val2 this; //??? } How can A act both as Sometype and int? (at least without

Re: Type converter from build in to user type

2012-11-30 Thread js.mdnq
On Friday, 30 November 2012 at 03:40:31 UTC, Ali Çehreli wrote: On 11/29/2012 07:24 PM, jerro wrote: On Friday, 30 November 2012 at 02:59:06 UTC, js.mdnq wrote: I have a struct I am trying convert from int's to the type. Since I can't add a opCast overload to an int I don't know how to do

Re: Templated Function pointers

2012-11-30 Thread js.mdnq
It seems one can accomplish this using delegates assigned by generic functions. The delegate will end hold holding the state of the function. It sort of acts like a binder. It seems to work but more testing needs to be done. I'm not sure how efficient it is or if there is a better way but

alias this

2012-11-30 Thread js.mdnq
I've seen this technique pop up in several things and I'm curious to what it is/how it's used? alias t this; does what? It seems like it's used as a way to trick the compiler into doing some cool/useful things?

Re: alias this

2012-11-30 Thread js.mdnq
On Friday, 30 November 2012 at 14:02:42 UTC, Andrej Mitrovic wrote: On 11/30/12, js.mdnq js_adddot+m...@gmail.com wrote: alias t this; This should explain: http://dlang.org/class.html#AliasThis Thanks, I'm sure I saw that at some point but I guess it just didn't sink in. This seems really

Re: alias this

2012-11-30 Thread js.mdnq
On Friday, 30 November 2012 at 21:46:47 UTC, Rob T wrote: On Friday, 30 November 2012 at 14:14:36 UTC, js.mdnq wrote: On Friday, 30 November 2012 at 14:02:42 UTC, Andrej Mitrovic wrote: On 11/30/12, js.mdnq js_adddot+m...@gmail.com wrote: alias t this; This should explain: http://dlang.org

Re: alias this

2012-11-30 Thread js.mdnq
I'm running into an issue of trying to get back the normal this pointer ;/ If I so `alias a this;` how do I get the pointer to the object back for other purposes?

get address of object if opCast is overridden

2012-11-30 Thread js.mdnq
Let O be an object with opCast overridden, then writeln(O); //prints string writeln(cast(void *)O)) // error, works fine if I comment out the opCast override writeln(O) // address of pointer to O, not what I want. I want to compare a few objects based on their location. (I know this is bad

Newb's questions constructor

2012-11-29 Thread js.mdnq
Reading 'the book' and it states that D does not allow one to nest construction calls that are not complete. e.g., this() { if (x 1) { this(x); } } will fail. First, I do not know why this is required. It seems to me it would be better to allow one optionally use another constructor if

Templated Function pointers

2012-11-29 Thread js.mdnq
I need to store a templated function in a function pointer, how can I do this? e.g., void function(double) myfuncptr; void myfunc(double d) { } myfuncptr = myfunc; Now I would like to use a template parameter instead of double. In C++ one can do this by using boosts binding's and

Type converter from build in to user type

2012-11-29 Thread js.mdnq
I have a struct I am trying convert from int's to the type. Since I can't add a opCast overload to an int I don't know how to do it. My opCast convertors in my class do not work for the assignment operator: class myType { opCast, opAssign } mytype = 3; Error that we can't convert an int