Re: Pure not acting pure.

2011-06-16 Thread Michel Fortin
On 2011-06-15 23:29:46 -0400, Charles McAnany mcana...@rose-hulman.edu said: Ah, so does the compiler figure out which ones are strongly and weakly pure and then optimize as appropriate? Is there a way to indicate that a function is strongly pure? Because it would seem odd to call a function

Re: Pure not acting pure.

2011-06-16 Thread bearophile
Michel Fortin: Just make sure all the parameters are either const or immutable or passed by copy and do not contain any pointer or reference. That'll make the function strongly pure, and the compiler will be able optimize. I have just done a little test on this, currently DMD calls sqr one

D documentation

2011-06-16 Thread Lloyd Dupont
I'm working a small but reasonably interesting D project which I'd like to, ultimately, open source. To make it attractive I need to document my class. Is there anything remotely like Javadoc which works with D?

Re: D documentation

2011-06-16 Thread bearophile
Lloyd Dupont: I'm working a small but reasonably interesting D project which I'd like to, ultimately, open source. To make it attractive I need to document my class. Is there anything remotely like Javadoc which works with D? http://www.digitalmars.com/d/2.0/ddoc.html I suggest you to

Anybody want to help this Haskell programmer out about type classes?

2011-06-16 Thread Jimmy Cao
http://stackoverflow.com/questions/6328444/type-classes-in-d This guy seems to be very optimistic about D's functional possibilities. Unfortunately, the only answer there right now is a generic ramble concerning D.

Re: D documentation

2011-06-16 Thread Lloyd Dupont
Thanks bearophile! bearophile wrote in message news:itcs1k$1l8t$1...@digitalmars.com... Lloyd Dupont: I'm working a small but reasonably interesting D project which I'd like to, ultimately, open source. To make it attractive I need to document my class. Is there anything remotely like

__traits, compile time member type info

2011-06-16 Thread Lloyd Dupont
I'm trying to build an introspection system for a project I have. I already have a working template to get members value === working members getter === Variant GETTER(T, string member)(Object target) { T tt = cast(T)target; if (!tt) throw new ReflectionException(target is null or not

Solved!

2011-06-16 Thread Lloyd Dupont
work with typeinfo!! :) = void SETTER(T, string member)(Object target, Variant value) { T tt = cast(T)target; if (!tt) throw new ReflectionException(target is null or not ~T.stringof ~ value: ~target.toString()); if(!value.convertsTo!( typeof(__traits(getMember, T,

Re: __traits, compile time member type info

2011-06-16 Thread Lloyd Dupont
works with typeinfo! void SETTER(T, string member)(Object target, Variant value) { T tt = cast(T)target; if (!tt) throw new ReflectionException(target is null or not ~T.stringof ~ value: ~target.toString()); if(!value.convertsTo!( typeof(__traits(getMember, T, member)) ))

templated overloaded operator problem.. :~

2011-06-16 Thread Lloyd Dupont
I have 2 overload of the opCall() in one of my class. They cause a compile time error / conflict... any idea on how to solve it? = class MemberDesc { Variant opCall(Object target) { return getter(target); } void opCall(T)(Object target, T value) { setter(target,

Re: templated overloaded operator problem.. :~

2011-06-16 Thread David Nadlinger
Add a pair of parentheses to the first overload to add an empty template argument list – currently, template and non-template functions can't be overloaded. David On 6/16/11 2:59 PM, Lloyd Dupont wrote: I have 2 overload of the opCall() in one of my class. They cause a compile time error /

Re: templated overloaded operator problem.. :~

2011-06-16 Thread Lloyd Dupont
Ho thanks, even better than the work around I just found! :) David Nadlinger wrote in message news:itcvbj$1td2$1...@digitalmars.com... Add a pair of parentheses to the first overload to add an empty template argument list – currently, template and non-template functions can't be overloaded.

Re: Advice on threading/fibers/?

2011-06-16 Thread Lars T. Kyllingstad
On Wed, 15 Jun 2011 23:57:25 +, Justin Whear wrote: Consider the following: You have 10 million data points and you need to apply a multipass algorithm to them. Each pass is like a cellular automata: it can read from the previous pass but it doesn't know the current values. This makes

smarter reflection issue

2011-06-16 Thread Lloyd Dupont
I have a MemberDesc class which describe a class's members. I fill it with a template method like that (with GETTER and SETTER some other templated method I wrote) = MemberDesc MEMBER(T, string memberName)() { TypeInfo ti = typeid( typeof(__traits(getMember, T, memberName)) );

Re: Advice on threading/fibers/?

2011-06-16 Thread Jeremy Wright
On 06/16/2011 06:22 AM, Lars T. Kyllingstad wrote: On Wed, 15 Jun 2011 23:57:25 +, Justin Whear wrote: Consider the following: You have 10 million data points and you need to apply a multipass algorithm to them. Each pass is like a cellular automata: it can read from the previous pass but

Re: Pure not acting pure.

2011-06-16 Thread Lars T. Kyllingstad
On Thu, 16 Jun 2011 06:52:45 -0400, Michel Fortin wrote: On 2011-06-15 23:29:46 -0400, Charles McAnany mcana...@rose-hulman.edu said: Ah, so does the compiler figure out which ones are strongly and weakly pure and then optimize as appropriate? Is there a way to indicate that a function is

Re: Is it reasonable to learn D

2011-06-16 Thread Jacob Carlborg
On 2011-06-07 22:45, Timon Gehr wrote: Fabian wrote: - There are no maintained GUI libraries I don't know about this but I think QtD and DWT are still being maintained? DWT is still maintained, although very slowly. -- /Jacob Carlborg

Re: Is it reasonable to learn D

2011-06-16 Thread Jacob Carlborg
On 2011-06-07 23:02, Fabian wrote: The community does not grow if people stay away because it is small. Thank you for your answer. - You've got a big point! I don't know about this but I think QtD and DWT are still being maintained? I can't see any changes on this web page:

Re: Is it reasonable to learn D

2011-06-16 Thread Jacob Carlborg
On 2011-06-07 23:33, Jonathan M Davis wrote: On 2011-06-07 14:02, Fabian wrote: The community does not grow if people stay away because it is small. Thank you for your answer. - You've got a big point! I don't know about this but I think QtD and DWT are still being maintained? I can't see

Re: Install DWT2 using DMD and Tango

2011-06-16 Thread Jacob Carlborg
On 2011-06-08 22:59, Andrew Wiley wrote: On Wed, Jun 8, 2011 at 11:54 AM, Fabian contact-...@freenet.de mailto:contact-...@freenet.de wrote: Hi I'm trying to install DWT2 to create GUI applications with D. I have downloaded DWT2 with TortoiseHg already and I've installed Ruby

Re: Install DWT2 using DMD and Tango

2011-06-16 Thread Jacob Carlborg
On 2011-06-08 20:54, Fabian wrote: Hi I'm trying to install DWT2 to create GUI applications with D. I have downloaded DWT2 with TortoiseHg already and I've installed Ruby and Rake. But when I try to build the packages I get the following error message:

Re: Serialization libs?

2011-06-16 Thread Jacob Carlborg
On 2011-06-10 14:07, Robert Clipsham wrote: On 10/06/2011 08:30, Nick Sabalausky wrote: Are there any good D2 serialization libs out there that utilize introspecition (ie, don't have to manually specify all the member of each type), handle cyclic graphs and have flexible output? I've never

Re: Pure not acting pure.

2011-06-16 Thread Charles McAnany
Ok, I think I get it. That cleared it up. =). So, if you have a functioned labelled pure, it's your job to not pass it mutable arguments, but the compiler's job to make sure it doesn't mutate anything not in the arguments. And that's why a strongly pure function can call a weakly pure one - only

Re: Pure not acting pure.

2011-06-16 Thread Lars T. Kyllingstad
On Thu, 16 Jun 2011 17:38:27 +, Charles McAnany wrote: Ok, I think I get it. That cleared it up. =). So, if you have a functioned labelled pure, it's your job to not pass it mutable arguments, but the compiler's job to make sure it doesn't mutate anything not in the arguments. And that's

Re: Pure not acting pure.

2011-06-16 Thread Jonathan M Davis
On 2011-06-16 10:38, Charles McAnany wrote: Ok, I think I get it. That cleared it up. =). So, if you have a functioned labelled pure, it's your job to not pass it mutable arguments, but the compiler's job to make sure it doesn't mutate anything not in the arguments. And that's why a strongly

Re: Pure not acting pure.

2011-06-16 Thread Steven Schveighoffer
On Thu, 16 Jun 2011 14:33:17 -0400, Jonathan M Davis jmdavisp...@gmx.com wrote: On 2011-06-16 10:38, Charles McAnany wrote: Ok, I think I get it. That cleared it up. =). So, if you have a functioned labelled pure, it's your job to not pass it mutable arguments, but the compiler's job to make

sorting a BigInt[] with algorithm.sort()

2011-06-16 Thread Charles McAnany
Hi, all. This is a strange one. import std.bigint; import std.algorithm; void main(){ BigInt[] ar = [BigInt(2), BigInt(1), BigInt(3)]; sort(ar); } object.Exception@src\rt\arraycat.d(40): overlapping array copy Is this a library bug? Or is sort() not supposed to work on this data? Oh,

Re: Pure not acting pure.

2011-06-16 Thread Jonathan M Davis
On 2011-06-16 11:59, Steven Schveighoffer wrote: On Thu, 16 Jun 2011 14:33:17 -0400, Jonathan M Davis jmdavisp...@gmx.com wrote: On 2011-06-16 10:38, Charles McAnany wrote: Ok, I think I get it. That cleared it up. =). So, if you have a functioned labelled pure, it's your job to not pass

Re: sorting a BigInt[] with algorithm.sort()

2011-06-16 Thread bearophile
Charles McAnany: object.Exception@src\rt\arraycat.d(40): overlapping array copy Is this a library bug? Or is sort() not supposed to work on this data? It's a known bug: http://d.puremagic.com/issues/show_bug.cgi?id=5705 (Is Bugzilla down?) Bye, bearophile

Re: Pure not acting pure.

2011-06-16 Thread Steven Schveighoffer
On Thu, 16 Jun 2011 16:36:01 -0400, Jonathan M Davis jmdavisp...@gmx.com wrote: On 2011-06-16 11:59, Steven Schveighoffer wrote: On Thu, 16 Jun 2011 14:33:17 -0400, Jonathan M Davis jmdavisp...@gmx.com wrote: On 2011-06-16 10:38, Charles McAnany wrote: Ok, I think I get it. That cleared

Re: smarter reflection issue

2011-06-16 Thread Jesse Phillips
MemberDesc MEMBER(T, string memberName)() if(std.traits.hasMember!(T, memberName)) { ... } Lloyd Dupont Wrote: I have a MemberDesc class which describe a class's members. I fill it with a template method like that (with GETTER and SETTER some other templated method I wrote) =

Re: Pure not acting pure.

2011-06-16 Thread Jonathan M Davis
On 2011-06-16 13:47, Steven Schveighoffer wrote: On Thu, 16 Jun 2011 16:36:01 -0400, Jonathan M Davis jmdavisp...@gmx.com wrote: On 2011-06-16 11:59, Steven Schveighoffer wrote: On Thu, 16 Jun 2011 14:33:17 -0400, Jonathan M Davis jmdavisp...@gmx.com wrote: On 2011-06-16 10:38,

Re: smarter reflection issue

2011-06-16 Thread Lloyd Dupont
Hi Jesse, this won't work! It's my fault in not explaining my problem well though... I forget to mention something... I'm using property syntax and try to call the method Say I have = private int _foo; @property public int Foo() { return _foo; } @property public void Foo(int value) { _foo =

allocating gobs of memory to my program

2011-06-16 Thread Charles McAnany
Hi, all. I'm back! I've got an enormous array that I need to store, preferably in RAM. (It's iterated a bunch.) I have 16 Gb on my machine, and at any time, about 12 Gb is free. I'd like to be able to use about 10 Gb for this program. But when I try to use more than about 800 Mb, I get Memory

Re: allocating gobs of memory to my program

2011-06-16 Thread David Nadlinger
On 6/17/11 12:32 AM, Charles McAnany wrote: Win7 x64, Intel I7 @4.4 GHz, compiling with dmd -O -release -inline. Regardless whether you are running on x86 or x86_64, DMD is only able to create 32 bit binaries on Windows. David

Type qualifiers - inout error

2011-06-16 Thread Claudiu Verdes
Hi, I'm new to D and trying to follow Alexandrescu's TDPL code examples I came across an error on the code below: class A { inout(int) val() inout { return _val; // error - see below } private int _val; }; The compiler (dmd v2.052) complains on the marked line with the message Error: inout on

Instantiating a Tuple with immutable fields.

2011-06-16 Thread Jose Armando Garcia
Hi, I am trying to instantiate a Tuple that contains an immutable field. Is there a way to do this with the current implementation? The compiler gives me this error: std/typecons.d(383): Error: can only initialize const member _field_field_0 inside constructor tuple_test.d(5): Error: template

Re: allocating gobs of memory to my program

2011-06-16 Thread Charles McAnany
Hm. I'm not too good on architecture - does that mean it's impossible for an x32 program to have access to more memory? Is there, maybe, an x64 C library that I could use to abstract the memory out (Just a huge array wrapper, basically)? Or, that failing, does GCC automatically generate x64

Re: allocating gobs of memory to my program

2011-06-16 Thread Jose Armando Garcia
On Thu, Jun 16, 2011 at 10:20 PM, Charles McAnany mcana...@rose-hulman.edu wrote: Hm. I'm not too good on architecture - does that mean it's impossible for an x32 program to have access to more memory? Is there, maybe, an x64 C library that I could use to abstract the memory out (Just a huge

Re: Type qualifiers - inout error

2011-06-16 Thread bearophile
Claudiu Verdes: What am I doing wrong? TDPL has a very similar example... I think this TDPL example is not good. And generally inout is not fully implemented in D yet. P.S. Is there a netiquette (a la C++ FAQ lite) about posting on this forum that I should be aware of? I think there isn't

Re: Instantiating a Tuple with immutable fields.

2011-06-16 Thread bearophile
Jose Armando Garcia: I am trying to instantiate a Tuple that contains an immutable field. Is there a way to do this with the current implementation? I think this is not yet possible. I am not sure, but maybe even small changes to conts are needed to fix this problem. Bye, bearophile

Re: Pure not acting pure.

2011-06-16 Thread bearophile
Jonathan M Davis: I'm _very_ glad that Don came up with the weakly pure idea, or pure would have been almost unusable. I think Don has said this wasn't fully his idea. The D community is good at creating ideas in group :-) Bye, bearophile

Strange behavior when concatenating array

2011-06-16 Thread Jose Armando Garcia
It looks like the rt is not calling the postblit constructor when concatenating arrays. For example, the following code: import std.stdio; struct Test { this(this) { writeln(copy done); } void opAssign(Test rhs) { writeln(assignment done); } ~this() { writeln(destructor called); } }

Re: Strange behavior when concatenating array

2011-06-16 Thread Jose Armando Garcia
On Fri, Jun 17, 2011 at 1:05 AM, Jose Armando Garcia jsan...@gmail.com wrote:      tests ~= test; Btw, if you replace this with 'test[0] = test;' it works as expected. The postblit ctor and the assignment operator get called and the dtor is called twice.