Re: How do you use templates in D?

2011-10-18 Thread Andrew Pennebaker
Novak: Very cool. Can qcheck automatically figure out a way to generate the arbitrary data types needed as input for the property/testee? Or did I read that wrong? Cheers, Andrew Pennebaker www.yellosoft.us On Tue, Oct 18, 2011 at 11:14 PM, Martin Nowak wrote: > On Tue, 18 Oct 2011 21:17:56 +0

Re: To share or not to share, this is the question.

2011-10-18 Thread Gor Gyolchanyan
I meant, i have a member of type HWND. On Wed, Oct 19, 2011 at 6:47 AM, Robert Jacques wrote: > On Mon, 17 Oct 2011 08:28:08 -0400, Gor Gyolchanyan > wrote: >> >> I don't get it. HWND is an alias for void*. void* is data. what do you >> mean, "alias is not data"? > > void* is a type, not a membe

Re: Just starting out

2011-10-18 Thread Daniel Murphy
getch (or one of the variants) does do this, but you may need to disable buffering in the console first. "Nick Sabalausky" wrote in message news:j7iip8$23qb$1...@digitalmars.com... > "Sean Kelly" wrote in message > news:mailman.151.1318889150.24802.digitalmar...@puremagic.com... >> There's a

Re: How do you use templates in D?

2011-10-18 Thread Jonathan M Davis
On Tuesday, October 18, 2011 15:37 Ali Çehreli wrote: > On Tue, 18 Oct 2011 17:56:33 -0400, Jonathan M Davis wrote: > > On Tuesday, October 18, 2011 12:32 Ali Çehreli wrote: > >> On Tue, 18 Oct 2011 13:56:09 -0400, Andrew Pennebaker wrote: > >> > I'm writing a function called genArray that accepts

Re: Introspection/Reflection/etc on Linux

2011-10-18 Thread Robert Jacques
On Tue, 18 Oct 2011 12:48:47 -0400, J Arrizza wrote: I'm trying to write some sample code to: 1 create an object via it's name 2 search an object for it's functions 3 call a static function in a class 4 call a non-static function in an object #1, #2 and #3 were straightforward. But #4

Re: How do you use templates in D?

2011-10-18 Thread Martin Nowak
On Tue, 18 Oct 2011 21:17:56 +0200, bearophile wrote: Andrew Pennebaker: The D version will be called dashcheck QuickCheck is one of the good things of Haskell. I have raised the topic few times: http://www.digitalmars.com/d/archives/digitalmars/D/Q

Re: To share or not to share, this is the question.

2011-10-18 Thread Robert Jacques
On Mon, 17 Oct 2011 08:28:08 -0400, Gor Gyolchanyan wrote: I don't get it. HWND is an alias for void*. void* is data. what do you mean, "alias is not data"? void* is a type, not a member field of the class (data)

Re: [std.database] at compile time

2011-10-18 Thread foobar
Don Wrote: > On 17.10.2011 01:43, foobar wrote: > > foobar Wrote: > > > >> Don Wrote: > >> > >> You're assuming that the compiler can run the code it's generating. > >> This > >> isn't true in general. Suppose you're on x86, compiling for ARM. You > >> can't run the ARM code f

Re: How do you use templates in D?

2011-10-18 Thread Ali Çehreli
On Tue, 18 Oct 2011 17:56:33 -0400, Jonathan M Davis wrote: > On Tuesday, October 18, 2011 12:32 Ali Çehreli wrote: >> On Tue, 18 Oct 2011 13:56:09 -0400, Andrew Pennebaker wrote: >> > I'm writing a function called genArray that accepts a function gen >> > and returns a random array populated by c

Re: How do you use templates in D?

2011-10-18 Thread Jonathan M Davis
On Tuesday, October 18, 2011 12:32 Ali Çehreli wrote: > On Tue, 18 Oct 2011 13:56:09 -0400, Andrew Pennebaker wrote: > > I'm writing a function called genArray that accepts a function gen and > > returns a random array populated by calling gen(). genString builds on > > this by returning genArray(&

Re: new DIP14: Package import path association

2011-10-18 Thread Jonathan M Davis
On Tuesday, October 18, 2011 00:38 Martin Nowak wrote: > http://prowiki.org/wiki4d/wiki.cgi?LanguageDevel/DIPs/DIP14 I really think that you lose something when you add file paths to imports rather than letting the module system deal with it as it does now. The result is messier, and I really do

Re: Just starting out

2011-10-18 Thread mta`chrono
Feel free to help us porting tango to D2. We've already done a lot and some parts are quite usable. But don't expect to much. https://github.com/SiegeLord/Tango-D2

Re: [std.database] at compile time

2011-10-18 Thread Don
On 17.10.2011 01:43, foobar wrote: foobar Wrote: Don Wrote: You're assuming that the compiler can run the code it's generating. This isn't true in general. Suppose you're on x86, compiling for ARM. You can't run the ARM code from the compiler. This is quite possible in Nemerle's model of c

Re: How do you use templates in D?

2011-10-18 Thread Andrew Pennebaker
bearophile: Aw shucks, every single link to the old D ports is broken. Even Fawzi took down his RTest project. I'll message him to ask that he reupload it. Cheers, Andrew Pennebaker www.yellosoft.us On Tue, Oct 18, 2011 at 4:06 PM, Andrew Pennebaker < andrew.penneba...@gmail.com> wrote: > bearo

Re: How do you use templates in D?

2011-10-18 Thread Andrew Pennebaker
bearophile, Awesome! I'll take a look at the old D ports to see how they did it. Çehreli, thanks much! Another D user suggested the same fixes at StackOverflow, so my project is making progress. Fawcett, you've got the right idea :) The difference between your example code and QuickCheck is that

Re: Simple features that I've always missed from C...

2011-10-18 Thread Don
On 18.10.2011 11:43, Manu wrote: On 18 October 2011 12:12, Don mailto:nos...@nospam.com>> wrote: You mean bsr and bsf. Unfortunately, there are some big problems with them. What is bsr(0) ? True ;) .. but that's why the API needs to be defined and standardised. On PowerPC it returns 32

Re: How do you use templates in D?

2011-10-18 Thread Graham Fawcett
On Tue, 18 Oct 2011 15:06:21 -0400, Andrew Pennebaker wrote: > Recap: > > forAll() accepts a property of type bool function(void), and a > collection of generator functions, of types *arbitrary_type* > function(void). forAll calls the generator functions, storing the values > in another collectio

Re: How do you use templates in D?

2011-10-18 Thread Ali Çehreli
On Tue, 18 Oct 2011 13:56:09 -0400, Andrew Pennebaker wrote: > I'm writing a function called genArray that accepts a function gen and > returns a random array populated by calling gen(). genString builds on > this by returning genArray(&genChar). But my type signatures are wrong. > > In dashcheck

Re: How do you use templates in D?

2011-10-18 Thread Trass3r
T[] genArray(T function() gen) { T[] genArray(T)(T function() gen) {

Re: How do you use templates in D?

2011-10-18 Thread bearophile
Andrew Pennebaker: > The D version will be called dashcheck QuickCheck is one of the good things of Haskell. I have raised the topic few times: http://www.digitalmars.com/d/archives/digitalmars/D/QuickCheck-like_in_Phobos_131256.html http://www.digitalmars.c

Re: How do you use templates in D?

2011-10-18 Thread Andrew Pennebaker
I'm writing a D port of QuickCheck, a unit test framework that works by testing properties. A property is a function that accepts input values and returns a boolean, e.g. isEven(int i). The QuickCheck API's most important functi

Re: How do you use templates in D?

2011-10-18 Thread Andrej Mitrovic
You could pass arbitrary functions like so: auto genArray(T...)(T dgs) if (allSatisfy!(isSomeFunction, T)) { } and call it: genArray({ return cast(char) uniform(0, 128); }, { return cast(int) uniform(0, 128); }); I'm not sure what you would want to do with lambdas with arbitra

Re: How do you use templates in D?

2011-10-18 Thread Graham Fawcett
On Tue, 18 Oct 2011 14:28:59 -0400, Andrew Pennebaker wrote: > Now I'm curious: How can I pass and accept a collection of lambdas? The > lambdas will each have different, arbitrary returns types. And how do I > call a function using a collection of values, something like Lisp's > (apply f args) ?

Re: Introspection/Reflection/etc on Linux

2011-10-18 Thread Gor Gyolchanyan
You need to compile an associative array which maps the method names to method delegates and call those delegates, replacing the context pointer with the specified object. On Tue, Oct 18, 2011 at 8:48 PM, J Arrizza wrote: > I'm trying to write some sample code to: >   1 create an object via it's

Re: How do you use templates in D?

2011-10-18 Thread Andrew Pennebaker
ntrel2has the answer: char genChar() { return cast(char) uniform(0, 128); } T[] genArray(T)(T function() gen) { int len = uniform(0, 100); T[] arr = []; for(int i = 0; i < len; i++) { arr ~= gen(); } return arr

How do you use templates in D?

2011-10-18 Thread Andrew Pennebaker
I'm writing a function called genArray that accepts a function gen and returns a random array populated by calling gen(). genString builds on this by returning genArray(&genChar). But my type signatures are wrong. In dashcheck.d: char genChar() { return cast(char) uniform(0, 128); } T[] genA

Re: Just starting out

2011-10-18 Thread Kai Meyer
On 10/13/2011 01:37 AM, J Arrizza wrote: Thanks for all the replies. Seems straightforward enough: 1) Phobos is it. 2) DMD is the clear winner 3) Eclipse is a hog - knew that. I really only like a couple of things in it. A big one for me is the source formatting. For some reason, having to hit t

Re: Selective and renamed imports

2011-10-18 Thread Christian Kamm
Kagamin wrote: > afaik currently all imports include symbols into the importing module. > > --- a.d --- > int z; > > --- b.d --- > import a; > a.z is available as b.z now. No, this import does not introduce a new symbol b.z. It just adds a note to b's root scope saying "if a symbol isn't found

Introspection/Reflection/etc on Linux

2011-10-18 Thread J Arrizza
I'm trying to write some sample code to: 1 create an object via it's name 2 search an object for it's functions 3 call a static function in a class 4 call a non-static function in an object #1, #2 and #3 were straightforward. But #4 looks like it's not possible in DMD 2.0. I found this:

Re: is it shared? is it const? is it immutable?

2011-10-18 Thread Gor Gyolchanyan
is(FunctionTypeOf!(Overload) == shared(FunctionTypeOf!(Overload))) the same goes for const and immutable On Tue, Oct 18, 2011 at 8:27 PM, Matt Soucy wrote: > It would probably be useful to others who may have the same problem if you > posted your solution - this definitely sounds like something t

Re: is it shared? is it const? is it immutable?

2011-10-18 Thread Matt Soucy
It would probably be useful to others who may have the same problem if you posted your solution - this definitely sounds like something that can help other people. -msoucy On 10/18/2011 12:10 PM, Gor Gyolchanyan wrote: never mind. figured it out :-) On Tue, Oct 18, 2011 at 7:57 PM, Gor Gyolch

Re: is it shared? is it const? is it immutable?

2011-10-18 Thread Gor Gyolchanyan
never mind. figured it out :-) On Tue, Oct 18, 2011 at 7:57 PM, Gor Gyolchanyan wrote: > I can't find any info about how to test whether a method is shared, > const or immutable. > Can anyone help me out with this? >

is it shared? is it const? is it immutable?

2011-10-18 Thread Gor Gyolchanyan
I can't find any info about how to test whether a method is shared, const or immutable. Can anyone help me out with this?

Re: Just starting out

2011-10-18 Thread Sean Kelly
Games too. If all else fails, maybe look at ncurses? Sent from my iPhone On Oct 18, 2011, at 8:41 AM, Sean Kelly wrote: > It should block until a key is pressed. I used to use it for "press any key > to continue" functionality in console apps. > > Sent from my iPhone > > On Oct 17, 2011, at

Re: Just starting out

2011-10-18 Thread Sean Kelly
It should block until a key is pressed. I used to use it for "press any key to continue" functionality in console apps. Sent from my iPhone On Oct 17, 2011, at 5:54 PM, "Nick Sabalausky" wrote: > "Sean Kelly" wrote in message > news:mailman.151.1318889150.24802.digitalmar...@puremagic.com..

Re: Selective and renamed imports

2011-10-18 Thread Kagamin
Christian Kamm Wrote: > Timon Gehr wrote: > > Does > > > > public import foo : bar; > > > > work as expected with your pull request? > > Yes. But it doesn't merge the symbol either, so if foo.bar is a function > > a.d -- > public import foo : bar; > void bar() {} > > b.d -- > import a; > // w

Re: new DIP15: Import of packages

2011-10-18 Thread Jacob Carlborg
On 2011-10-18 16:50, Gor Gyolchanyan wrote: How do you imagine the process of importing a package without having a dedicated "default" module for it? I have no idea. What about how it works in other languages that support this, i.e. Java and Scala. At least it would be nice to have. -- /Jac

Re: new DIP15: Import of packages

2011-10-18 Thread Gor Gyolchanyan
How do you imagine the process of importing a package without having a dedicated "default" module for it? On Tue, Oct 18, 2011 at 4:29 PM, Jacob Carlborg wrote: > On 2011-10-18 13:40, Gor Gyolchanyan wrote: >> >> 1. Standardized and guaranteed to work in a similar manner every time. >> 2. Less ey

Re: new DIP14: Package import path association

2011-10-18 Thread Don
On 18.10.2011 09:38, Martin Nowak wrote: http://prowiki.org/wiki4d/wiki.cgi?LanguageDevel/DIPs/DIP14 Your proposal seems to have an implicit "Posix file path syntax is used", but that opens a can of worms. Up until now, there has been a policy of ensuring that OS-specific paths are kept out o

Re: new DIP15: Import of packages

2011-10-18 Thread Jacob Carlborg
On 2011-10-18 13:40, Gor Gyolchanyan wrote: 1. Standardized and guaranteed to work in a similar manner every time. 2. Less eye-trash in the code. 3. Opportunity to improve semantics of importing a package without needing to refactor lots of code. Ok, makes sense. Although, I would prefer if thi

Re: new DIP14: Package import path association

2011-10-18 Thread Jacob Carlborg
On 2011-10-18 13:48, Martin Nowak wrote: On Tue, 18 Oct 2011 13:23:02 +0200, Jacob Carlborg wrote: On 2011-10-18 09:38, Martin Nowak wrote: http://prowiki.org/wiki4d/wiki.cgi?LanguageDevel/DIPs/DIP14 What happens if you import a the same file twice using different paths, i.e. relative and a

Re: new DIP15: Import of packages

2011-10-18 Thread Martin Nowak
On Tue, 18 Oct 2011 13:27:18 +0200, Jacob Carlborg wrote: On 2011-10-18 09:38, Martin Nowak wrote: http://prowiki.org/wiki4d/wiki.cgi?LanguageDevel/DIPs/DIP15 What's the advantage of this compared to importing the "_.d" file explicitly, i.e. "import pkg._;" ? It is a paradigm shift to

Re: new DIP14: Package import path association

2011-10-18 Thread Martin Nowak
On Tue, 18 Oct 2011 13:23:02 +0200, Jacob Carlborg wrote: On 2011-10-18 09:38, Martin Nowak wrote: http://prowiki.org/wiki4d/wiki.cgi?LanguageDevel/DIPs/DIP14 What happens if you import a the same file twice using different paths, i.e. relative and absolute path? Will the imported files

Re: new DIP15: Import of packages

2011-10-18 Thread Gor Gyolchanyan
1. Standardized and guaranteed to work in a similar manner every time. 2. Less eye-trash in the code. 3. Opportunity to improve semantics of importing a package without needing to refactor lots of code. On Tue, Oct 18, 2011 at 3:27 PM, Jacob Carlborg wrote: > On 2011-10-18 09:38, Martin Nowak wro

Re: new DIP15: Import of packages

2011-10-18 Thread Jacob Carlborg
On 2011-10-18 09:38, Martin Nowak wrote: http://prowiki.org/wiki4d/wiki.cgi?LanguageDevel/DIPs/DIP15 What's the advantage of this compared to importing the "_.d" file explicitly, i.e. "import pkg._;" ? -- /Jacob Carlborg

Re: new DIP14: Package import path association

2011-10-18 Thread Gor Gyolchanyan
I think the best thing to do would be to maintain a module[path] mapping, where more then one path can map to a single module. The by-path import declarations would add items to the mapping and the compiler would extract the list of modules from it. On Tue, Oct 18, 2011 at 3:23 PM, Jacob Carlborg

Re: new DIP14: Package import path association

2011-10-18 Thread Jacob Carlborg
On 2011-10-18 09:38, Martin Nowak wrote: http://prowiki.org/wiki4d/wiki.cgi?LanguageDevel/DIPs/DIP14 What happens if you import a the same file twice using different paths, i.e. relative and absolute path? Will the imported files need a module declaration or will the compiler just care abou

Re: Just starting out

2011-10-18 Thread Dmitry Olshansky
On 14.10.2011 4:49, Nick Sabalausky wrote: That would be neat. One thing I'd been thinking of adding to mine was an alternate function that just waited for a single keystroke (rather than a line of text + Enter). I think I once had it working on Tango, IIRC, but then I switched to D2/Phobos a

Re: Simple features that I've always missed from C...

2011-10-18 Thread Manu
On 18 October 2011 02:45, bearophile wrote: > I have asked for a rotate intrinsic in Phobos, but Walter has added a > rewrite rule instead, that turns D code to a rot. > Personal experience has shown me that it's easy to write the operation in a > slightly different way (like with signed instead

Re: Simple features that I've always missed from C...

2011-10-18 Thread Manu
On 18 October 2011 05:11, kennytm wrote: > FYI, g++ has deprecated these operators long time ago (since 4.0). > > http://gcc.gnu.org/onlinedocs/gcc-4.0.4/gcc/Deprecated-Features.html > Nooo! .. Removed in favour of the STL instead... well I for one thought they were a great idea, but apparently

Re: Simple features that I've always missed from C...

2011-10-18 Thread Manu
On 18 October 2011 12:12, Don wrote: > You mean bsr and bsf. > Unfortunately, there are some big problems with them. What is bsr(0) ? > True ;) .. but that's why the API needs to be defined and standardised. On PowerPC it returns 32 (or 64), and the x86 version returns 2 values, the position, an

Re: new DIP13: Import path binding

2011-10-18 Thread Gor Gyolchanyan
great idea! +1 On Tue, Oct 18, 2011 at 10:37 AM, Jacob Carlborg wrote: > On 2011-10-18 06:04, Martin Nowak wrote: >> >> http://prowiki.org/wiki4d/wiki.cgi?LanguageDevel/DIPs/DIP13 >> >> This is part of splitting DIP11 into several smaller DIPs. >> The prototype implementation of DIP11 has shown t

Re: Catching a hot potato

2011-10-18 Thread Gor Gyolchanyan
Yeah, that's what i thought. If a segfault occurs, I am going to catch it, but ONLY to restart the app right away. And I'm gonna save the data constantly, so i'll have nothing to lose. On Mon, Oct 17, 2011 at 10:03 PM, Marco Leise wrote: > Am 17.10.2011, 19:35 Uhr, schrieb Steven Schveighoffer >

Re: Simple features that I've always missed from C...

2011-10-18 Thread Don
On 18.10.2011 06:25, Robert Jacques wrote: On Mon, 17 Oct 2011 16:53:42 -0400, Manu wrote: [snip] *Count leading/trailing zeroes:* I don't know of any even slightly recent architecture that doesn't have opcodes to count loading/trailing zeroes, although they do exist, so perhaps this is a littl

Re: Simple features that I've always missed from C...

2011-10-18 Thread bearophile
Walter Bright: > There's no need for a compiler intrinsic. Just write a function that does do > the > optimization, and call it. Right. Two functions like this are worth putting somewhere in Phobos. > The signed versions "don't work" because a signed right shift is not the same > thing as an

new DIP15: Import of packages

2011-10-18 Thread Martin Nowak
http://prowiki.org/wiki4d/wiki.cgi?LanguageDevel/DIPs/DIP15

new DIP14: Package import path association

2011-10-18 Thread Martin Nowak
http://prowiki.org/wiki4d/wiki.cgi?LanguageDevel/DIPs/DIP14

Re: The CAPI Manifesto

2011-10-18 Thread Walter Bright
On 10/17/2011 11:40 PM, Jacob Carlborg wrote: On 2011-10-18 07:26, Walter Bright wrote: Is it possible (and worthwhile) to layer a package manager over a github repository? I'm planning to support github repositories as packages. Have a look at "Source Code Management": https://github.com/jac

Re: Shared Delegates

2011-10-18 Thread Andrew Wiley
On Tue, Oct 18, 2011 at 1:48 AM, Andrew Wiley wrote: > On Tue, Oct 18, 2011 at 1:11 AM, Benjamin Thaut wrote: > >> Am 18.10.2011 08:03, schrieb Andrew Wiley: >> >>> On Tue, Oct 18, 2011 at 12:53 AM, Benjamin Thaut >> > wrote: >>> >>>Am 17.10.2011 22:43, schrieb