Re: Finding UDAs with Templates

2013-07-23 Thread Jacob Carlborg
On 2013-07-23 06:27, Paul O'Neil wrote: I'm trying to write some code that finds all the members of a class that have a particular user defined attribute. My current attempt is at https://github.com/todayman/d_template_experiments/tree/8fccd27d7d5557ec6e2f0614374cf5f79fe80b4c I would like to

Re: Floating point minimum values are positive?

2013-07-23 Thread David
There are some floats that can go even smaller than this, but they are denormal and may incur a large runtime overhead (they are intended to prevent underflow / minimize loss of precision in certain computations involving very small quantities, and aren't supposed to be used in normal

Re: Finding UDAs with Templates

2013-07-23 Thread Artur Skawina
On 07/23/13 08:38, Jacob Carlborg wrote: static bool doesFieldSync (string field) () { alias attrs = TypeTuple!(__traits(getAttributes, mixin(FileData. ~ field))); return staticIndexOf!(Sync, attrs) != -1; } The important things here are that __traits(getAttributes) returns a

Re: Finding UDAs with Templates

2013-07-23 Thread Jacob Carlborg
On 2013-07-23 12:59, Artur Skawina wrote: We can. :) enum attrs = __traits... // `auto` would work too. I can't remember that working for me, but perhaps it does. Just be careful and remember the `typeof(attrs)` part if/when using staticIndexOf with types - it might otherwise return

Dpaste vs dmd 2.063.2 errors

2013-07-23 Thread JS
http://dpaste.dzfl.pl/27ca3fbd The code compiles fine on my computer. On DPaste there is all kinds of errors(when fixing one other errors pop up. I am compiling to 32-bit binary and that is the only real difference I can see, but surely it wouldn't result in such errors? The first error:

Re: Dpaste vs dmd 2.063.2 errors

2013-07-23 Thread JS
On Tuesday, 23 July 2013 at 12:59:11 UTC, monarch_dodra wrote: On Tuesday, 23 July 2013 at 12:26:31 UTC, JS wrote: http://dpaste.dzfl.pl/27ca3fbd The code compiles fine on my computer. On DPaste there is all kinds of errors(when fixing one other errors pop up. I am compiling to 32-bit

Re: Can't use variadic arguments to functions that use templates

2013-07-23 Thread JS
On Monday, 22 July 2013 at 16:48:56 UTC, Jesse Phillips wrote: On Sunday, 21 July 2013 at 07:22:08 UTC, JS wrote: void foo(T...)(T t) { pragma(msg, B(t)); } void main() { foo(x, a, b); din.getc(); } does work. I need to have B generate compile time code so it is efficient.

Re: Floating point minimum values are positive?

2013-07-23 Thread Dicebot
On Tuesday, 23 July 2013 at 03:14:17 UTC, Ali Çehreli wrote: 1) There shouldn't be warnings at all; what we call warnings should be errors. I agree with that completely. Not really. At least my (and, as far as I understand, Jonathan) point of view is that warnings should be either error or

Re: Floating point minimum values are positive?

2013-07-23 Thread Ali Çehreli
On 07/23/2013 08:05 AM, Dicebot wrote: On Tuesday, 23 July 2013 at 03:14:17 UTC, Ali Çehreli wrote: 1) There shouldn't be warnings at all; what we call warnings should be errors. I agree with that completely. Not really. At least my (and, as far as I understand, Jonathan) point of view

Is this documented behaviour?

2013-07-23 Thread John Colvin
void foo(ref int a) { a = 5; } void main() { int a = 0; int* aptr = a; foo(*aptr); assert(a == 5); a = 0; int b = *aptr; foo(b); assert(b == 5); assert(a == 0); } The fact that adding an

recursive alias declaration

2013-07-23 Thread Namespace
Did I miss something or is this a bug? import std.stdio; struct Rect(T) { public: bool intersects(ref const Rect!T rhs, ShortRect* overlap = null) { return false; } } alias FloatRect = Rect!float; alias ShortRect = Rect!short; void main() { } print:

Re: Is this documented behaviour?

2013-07-23 Thread Dicebot
On Tuesday, 23 July 2013 at 17:03:52 UTC, John Colvin wrote: Sorry, I should have been more clear. It's the first case that seems weird to me. Why? '*aptr' is 'a' pretty much by definition of pointer dereferencing.

Re: Is this documented behaviour?

2013-07-23 Thread Jonathan M Davis
On Tuesday, July 23, 2013 18:34:51 John Colvin wrote: void foo(ref int a) { a = 5; } void main() { int a = 0; int* aptr = a; foo(*aptr); assert(a == 5); a = 0; int b = *aptr; foo(b); assert(b == 5); assert(a == 0); } The fact that adding an explicit temporary changes the

Re: Can't use variadic arguments to functions that use templates

2013-07-23 Thread Ali Çehreli
On 07/23/2013 09:22 AM, JS wrote: On Tuesday, 23 July 2013 at 16:15:03 UTC, Jesse Phillips wrote: On Tuesday, 23 July 2013 at 14:03:01 UTC, JS wrote: I don't think you understand(or I've already got confused)... I'm trying to use B has a mixin(I don't think I made this clear). I can't use

Re: Code generation tricks

2013-07-23 Thread anonymous
On Sunday, 21 July 2013 at 17:24:11 UTC, JS wrote: This seems to be a somewhat efficient string splitter http://dpaste.dzfl.pl/4307aa5f I probably shouldn't have done this, but I wanted to know what that abomination actually does, so I reduced it (code below). In the end, all it does is

Re: recursive alias declaration

2013-07-23 Thread Ali Çehreli
On 07/23/2013 10:00 AM, Namespace wrote: Did I miss something or is this a bug? import std.stdio; struct Rect(T) { public: bool intersects(ref const Rect!T rhs, ShortRect* overlap = null) { return false; } } alias FloatRect = Rect!float; alias ShortRect = Rect!short;

Re: GktD: exceptions in handlers cause segfaults.

2013-07-23 Thread Johannes Pfau
Am Mon, 22 Jul 2013 19:28:10 +0200 schrieb Marco Leise marco.le...@gmx.de: Am Fri, 19 Jul 2013 21:43:38 +0200 schrieb Johannes Pfau nos...@example.com: Am Fri, 19 Jul 2013 12:38:45 +0200 schrieb Marco Leise marco.le...@gmx.de: Would be nice to know if this is working with gdc or ldc.

Re: Can't use variadic arguments to functions that use templates

2013-07-23 Thread Jesse Phillips
On Tuesday, 23 July 2013 at 16:22:38 UTC, JS wrote: On Tuesday, 23 July 2013 at 16:15:03 UTC, Jesse Phillips wrote: On Tuesday, 23 July 2013 at 14:03:01 UTC, JS wrote: I don't think you understand(or I've already got confused)... I'm trying to use B has a mixin(I don't think I made this

Re: Can't use variadic arguments to functions that use templates

2013-07-23 Thread H. S. Teoh
On Tue, Jul 23, 2013 at 08:54:12PM +0200, Jesse Phillips wrote: On Tuesday, 23 July 2013 at 16:22:38 UTC, JS wrote: On Tuesday, 23 July 2013 at 16:15:03 UTC, Jesse Phillips wrote: On Tuesday, 23 July 2013 at 14:03:01 UTC, JS wrote: I don't think you understand(or I've already got confused)...

Re: Can't use variadic arguments to functions that use templates

2013-07-23 Thread JS
On Tuesday, 23 July 2013 at 19:14:26 UTC, H. S. Teoh wrote: On Tue, Jul 23, 2013 at 08:54:12PM +0200, Jesse Phillips wrote: On Tuesday, 23 July 2013 at 16:22:38 UTC, JS wrote: On Tuesday, 23 July 2013 at 16:15:03 UTC, Jesse Phillips wrote: On Tuesday, 23 July 2013 at 14:03:01 UTC, JS wrote: I

Re: Is this documented behaviour?

2013-07-23 Thread John Colvin
On Tuesday, 23 July 2013 at 17:06:37 UTC, Dicebot wrote: On Tuesday, 23 July 2013 at 17:03:52 UTC, John Colvin wrote: Sorry, I should have been more clear. It's the first case that seems weird to me. Why? '*aptr' is 'a' pretty much by definition of pointer dereferencing. To be honest, I

Using alias parameters with class members in CTFE (related to UDAs)

2013-07-23 Thread Johannes Pfau
Does anyone know why this code is not working? http://dpaste.dzfl.pl/b89e7b3f It seems calling enum a = __traits(getAttributes, Class.member); is OK without an instance. But if I wrap the __traits call into another template with alias parameter like this: --- auto getAttribute(alias

Re: Unwanted conflict

2013-07-23 Thread Carl Sturtivant
On Saturday, 20 July 2013 at 22:33:00 UTC, bearophile wrote: Carl Sturtivant: What is the conflict exactly? Perhaps it's a bug fixed in GIT head. As workaround try: this()(string s) OK, but now I don't know how to call a templated constructor. void main() { A x = A!3(99); }

How to call a function in main()?

2013-07-23 Thread Jaehunt
I am new to programming. my function is look like T[] sort(T)(T[] A) {}. What is main() look like to use the function? If you know sites about dealing with syntax, please leave the links. Thanks.

Re: How to call a function in main()?

2013-07-23 Thread bearophile
Jaehunt: I am new to programming. D is a large language, it will take lot of work and time to learn it. my function is look like T[] sort(T)(T[] A) {}. What is main() look like to use the function? Take a look at the RosettaCode site, it contains hundreds of small D programs of many

Re: How to call a function in main()?

2013-07-23 Thread Jaehunt
On Tuesday, 23 July 2013 at 22:27:40 UTC, bearophile wrote: Jaehunt: I am new to programming. D is a large language, it will take lot of work and time to learn it. my function is look like T[] sort(T)(T[] A) {}. What is main() look like to use the function? Take a look at the

Re: How to call a function in main()?

2013-07-23 Thread Jaehunt
On Tuesday, 23 July 2013 at 22:39:20 UTC, Jaehunt wrote: On Tuesday, 23 July 2013 at 22:27:40 UTC, bearophile wrote: Jaehunt: I am new to programming. D is a large language, it will take lot of work and time to learn it. my function is look like T[] sort(T)(T[] A) {}. What is main()

Re: How to call a function in main()?

2013-07-23 Thread bearophile
Jaehunt: I mean when function has T[] in the front, how am I calling it? If it's a sorting routine, then it probably sorts data in-place, so it's more clear to not return data. If the function copies inside the input data before sorting it, then it's right to return the result. That's why

Re: Using alias parameters with class members in CTFE (related to UDAs)

2013-07-23 Thread Andrej Mitrovic
On 7/23/13, Johannes Pfau nos...@example.com wrote: Does anyone know why this code is not working? http://dpaste.dzfl.pl/b89e7b3f Add 'static' to getAttribute and it will work. I know, it's weird, and I've seen this sort of workaround used before. I think it's a compiler bug.

Re: Finding UDAs with Templates

2013-07-23 Thread Paul O'Neil
I basically ended up doing what Jacob suggested. To deal with the extra members from mixin Signal by using the compiles trait to avoid the normal case for them. Thanks for the help. Paul

Re: Dpaste vs dmd 2.063.2 errors

2013-07-23 Thread Raphaël Jakse
Le 23/07/2013 14:26, JS a écrit : http://dpaste.dzfl.pl/27ca3fbd The code compiles fine on my computer. On DPaste there is all kinds of errors(when fixing one other errors pop up. I am compiling to 32-bit binary and that is the only real difference I can see, but surely it wouldn't result in