Re: DMDScript

2014-07-13 Thread Ali Çehreli via Digitalmars-d-learn
On 07/11/2014 08:45 AM, Chris wrote: Tried to compile on linux, got this error message (I guess I can fix it): dmd -c textgen.d textgen.d(36): Error: cannot implicitly convert expression (DMDScript fatal runtime error: ) of type string to char[] Here is the relevant parts: struct Msgtable

Re: DMDScript

2014-07-13 Thread Jason King via Digitalmars-d-learn
On Friday, 11 July 2014 at 15:45:42 UTC, Chris wrote: Tried to compile on linux, got this error message (I guess I can fix it): dmd -c textgen.d textgen.d(36): Error: cannot implicitly convert expression (DMDScript fatal runtime error: ) of type string to char[] .. bunch more errors. You

Re: OSX, Need help with Compiling and linking errors

2014-07-13 Thread Mike Parker via Digitalmars-d-learn
On 7/13/2014 2:28 PM, Israel Rodriguez wrote: What about the dub libraries, what kind of errors do you get if you try to use a library not compatible for your system, say OSX or Linux? Im assuming the same linking errors but im not sure. dub doesn't download library binaries, but the source.

Re: Something like Python's psutils for D?

2014-07-13 Thread Thomas Mader via Digitalmars-d-learn
On Sunday, 13 July 2014 at 01:01:16 UTC, Ellery Newcomer wrote: would psutils itself be acceptable? https://bitbucket.org/ariovistus/pyd I haven't thought about this possibility, thanks.

Re: DStyle: Braces on same line

2014-07-13 Thread Joseph Rushton Wakeling via Digitalmars-d-learn
On 12/07/14 21:01, Danyal Zia via Digitalmars-d-learn wrote: I noticed that in Andrei's talks and his book, he used braces on the same line of delcaration, however Phobos and other D libraries I know use braces on their own line. Now I'm in a position where I need to take decision on coding

std.algorithm.among

2014-07-13 Thread bearophile via Digitalmars-d-learn
The idea of not making std.algorithm.among!() a predicate was not so good: void main() { import std.stdio, std.algorithm; auto s = hello how\nare you; s.until!(c = c.among!('\n', '\r')).writeln; } (A normal workaround is to use !!c.among!). Bye, bearophile

Re: std.algorithm.among

2014-07-13 Thread sigod via Digitalmars-d-learn
On Sunday, 13 July 2014 at 11:18:05 UTC, bearophile wrote: The idea of not making std.algorithm.among!() a predicate was not so good: void main() { import std.stdio, std.algorithm; auto s = hello how\nare you; s.until!(c = c.among!('\n', '\r')).writeln; } (A normal workaround is

Re: DStyle: Braces on same line

2014-07-13 Thread Danyal Zia via Digitalmars-d-learn
On Sunday, 13 July 2014 at 10:18:23 UTC, Joseph Rushton Wakeling via Digitalmars-d-learn wrote: However, I do think there's value in deliberately matching the code style of the standard library, as it extends the volume of public D code with a common style. So unless you have a strong personal

Re: std.algorithm.among

2014-07-13 Thread Timon Gehr via Digitalmars-d-learn
On 07/13/2014 01:18 PM, bearophile wrote: The idea of not making std.algorithm.among!() a predicate was not so good: ... Agreed. void main() { import std.stdio, std.algorithm; auto s = hello how\nare you; s.until!(c = c.among!('\n', '\r')).writeln; } (A normal workaround is

Re: std.algorithm.among

2014-07-13 Thread bearophile via Digitalmars-d-learn
Timon Gehr: It works with filter, so I think it should just work with until as well. So do you suggest me to open a bug report where I ask among to return a bool, or do you suggest to ask for an enhancement of until, or what? Bye, bearophile

Re: linux n00b

2014-07-13 Thread Dicebot via Digitalmars-d-learn
On Sunday, 13 July 2014 at 13:38:34 UTC, Xiaoxi wrote: If I want to build a d program which works on all dists, can i build that from any linux machine since dmd links statically by default or should I chose the oldest, i.e rhel5 to build on? because of possible glibc issues? Using machine

Re: DStyle: Braces on same line

2014-07-13 Thread H. S. Teoh via Digitalmars-d-learn
On Sun, Jul 13, 2014 at 11:32:23AM +0200, Joseph Rushton Wakeling via Digitalmars-d-learn wrote: On 12/07/14 21:01, Danyal Zia via Digitalmars-d-learn wrote: I noticed that in Andrei's talks and his book, he used braces on the same line of delcaration, however Phobos and other D libraries I

Re: Help to find crash in simple stack type?

2014-07-13 Thread Gary Willoughby via Digitalmars-d-learn
On Saturday, 12 July 2014 at 17:11:00 UTC, Rainer Schuetze wrote: On 12.07.2014 19:05, Rainer Schuetze wrote: Thanks for the reduction. GC.realloc seems broken for reallocations to sizes larger than the current GC pool. Please file a bug report. Actually done that myself:

Re: DStyle: Braces on same line

2014-07-13 Thread Gary Willoughby via Digitalmars-d-learn
On Saturday, 12 July 2014 at 19:01:56 UTC, Danyal Zia wrote: Hi, I noticed that in Andrei's talks and his book, he used braces on the same line of delcaration, however Phobos and other D libraries I know use braces on their own line. Now I'm in a position where I need to take decision on

Re: DStyle: Braces on same line

2014-07-13 Thread Joseph Rushton Wakeling via Digitalmars-d-learn
On 13/07/14 16:52, H. S. Teoh via Digitalmars-d-learn wrote: I had my own style before, but after I started contributing to Phobos, I found it a pain to keep switching back and forth between styles (and to convert styles before submitting PR's), so eventually I decided to just adopt Phobos style

Re: DStyle: Braces on same line

2014-07-13 Thread Joseph Rushton Wakeling via Digitalmars-d-learn
On 13/07/14 14:23, Danyal Zia via Digitalmars-d-learn wrote: I'm going with Andrei's style of preference on his talks ;) Andrei can no doubt speak for himself about his preferences, but I'd be wary of assuming that the style he uses in his talks necessarily reflects his actual stylistic

Re: DStyle: Braces on same line

2014-07-13 Thread Dicebot via Digitalmars-d-learn
On Sunday, 13 July 2014 at 16:47:00 UTC, Joseph Rushton Wakeling via Digitalmars-d-learn wrote: On 13/07/14 14:23, Danyal Zia via Digitalmars-d-learn wrote: I'm going with Andrei's style of preference on his talks ;) Andrei can no doubt speak for himself about his preferences, but I'd be

Re: DStyle: Braces on same line

2014-07-13 Thread bearophile via Digitalmars-d-learn
Danyal Zia: I noticed that in Andrei's talks and his book, he used braces on the same line of delcaration, however Phobos and other D libraries I know use braces on their own line. Rosettacode D examples always use the Egyptian style. For my code I use the same style, but Phobos

Re: DStyle: Braces on same line

2014-07-13 Thread Timon Gehr via Digitalmars-d-learn
On 07/13/2014 06:45 PM, Joseph Rushton Wakeling via Digitalmars-d-learn wrote: Two consequences of adapting myself to Phobos style were that I realized (i)how little most of these things really matter, and (ii) pretty much any stylistic choice carries both benefits and drawbacks. ... Wrong.

Re: DStyle: Braces on same line

2014-07-13 Thread Brian Rogoff via Digitalmars-d-learn
On Sunday, 13 July 2014 at 17:24:40 UTC, Timon Gehr wrote: On 07/13/2014 06:45 PM, Joseph Rushton Wakeling via Digitalmars-d-learn wrote: Wrong. There are things which are simply bad ideas. E.g. in this case, Egyptian-style braces definitely make your code more compact, I.e. you see where

Re: DStyle: Braces on same line

2014-07-13 Thread Joseph Rushton Wakeling via Digitalmars-d-learn
On 13/07/14 19:24, Timon Gehr via Digitalmars-d-learn wrote: Wrong. There are things which are simply bad ideas. I think that we can take it as read that I meant, Any reasonable stylistic choice. Of course, YMMV about what counts as reasonable, but most of the things that people fuss over

Re: std.algorithm.among

2014-07-13 Thread bearophile via Digitalmars-d-learn
Timon Gehr: I am saying the following code implementing 'until' in std.algorithm is at fault: private bool predSatisfied() // -- don't say bool here { static if (is(Sentinel == void)) return unaryFun!pred(_input.front); // or cast here else

Re: DStyle: Braces on same line

2014-07-13 Thread Timon Gehr via Digitalmars-d-learn
On 07/13/2014 07:51 PM, Brian Rogoff wrote: On Sunday, 13 July 2014 at 17:24:40 UTC, Timon Gehr wrote: On 07/13/2014 06:45 PM, Joseph Rushton Wakeling via Digitalmars-d-learn wrote: Wrong. There are things which are simply bad ideas. E.g. in this case, Egyptian-style braces definitely make

Re: DStyle: Braces on same line

2014-07-13 Thread Joseph Rushton Wakeling via Digitalmars-d-learn
On 13/07/14 19:51, Brian Rogoff via Digitalmars-d-learn wrote: Yes, the same argument for books and slides is also applicable to all other media. Not really. In a book or a slide you have an unavoidable constraint on how much vertical space you can take up. On a screen, you are unavoidably

SImple C++ code to D

2014-07-13 Thread Alexandre via Digitalmars-d-learn
I have this code in C++ //... char image[0x800]; //... auto dosh = reinterpret_castIMAGE_DOS_HEADER*(image[0]); dosh-e_magic = *(WORD*)MZ; dosh-e_cblp = 0x90; dosh-e_cp = 3; dosh-e_cparhdr = 4; dosh-e_maxalloc = 0x; dosh-e_sp = 0xb8; dosh-e_lfarlc = 0x40;

Re: std.algorithm.among

2014-07-13 Thread Meta via Digitalmars-d-learn
On Sunday, 13 July 2014 at 11:18:05 UTC, bearophile wrote: The idea of not making std.algorithm.among!() a predicate was not so good: void main() { import std.stdio, std.algorithm; auto s = hello how\nare you; s.until!(c = c.among!('\n', '\r')).writeln; } (A normal workaround is

Re: std.algorithm.among

2014-07-13 Thread Timon Gehr via Digitalmars-d-learn
On 07/13/2014 08:51 PM, Meta wrote: That's weird, I always assumed this worked. Was it always the case that numeric types can't be implicitly casted to bool? Yes, unless their range fits into [0,2).

Re: std.algorithm.among

2014-07-13 Thread Meta via Digitalmars-d-learn
On Sunday, 13 July 2014 at 19:06:29 UTC, Timon Gehr wrote: On 07/13/2014 08:51 PM, Meta wrote: That's weird, I always assumed this worked. Was it always the case that numeric types can't be implicitly casted to bool? Yes, unless their range fits into [0,2). It seems that not even that is

Re: SImple C++ code to D

2014-07-13 Thread John Colvin via Digitalmars-d-learn
On Sunday, 13 July 2014 at 18:48:01 UTC, Alexandre wrote: dosh.e_magic = cast(WORD*)(MZ); should be: dosh.e_magic = cast(WORD*)(MZ.ptr);

Re: SImple C++ code to D

2014-07-13 Thread bearophile via Digitalmars-d-learn
Alexandre: WORD e_res[4]; In D it's better to write: WORD[4] e_res; char image[0x800]; Note this is a thread-local variable. If you need a module-local variable you have to write: __gshared char[0x800] image; void main(string[] args) If you don't need the args, then

Re: SImple C++ code to D

2014-07-13 Thread via Digitalmars-d-learn
On Sunday, 13 July 2014 at 18:48:01 UTC, Alexandre wrote: char image[0x800]; Better use `ubyte[0x800] image` here. `char[]` is only for UTF-8 strings.

Re: SImple C++ code to D

2014-07-13 Thread bearophile via Digitalmars-d-learn
Marc Schütz: Better use `ubyte[0x800] image` here. `char[]` is only for UTF-8 strings. Right, sorry. Bye, bearophile

Re: std.algorithm.among

2014-07-13 Thread bearophile via Digitalmars-d-learn
Meta: It seems that not even that is the case. void main() { uint n = 0; //Error bool b = n; } D doesn't carry the range of mutable variables across different expressions. So write (with the 2.066beta3): void main() { const uint x1 = 0; const uint x2 = 1;

Re: Passing Templated Function Arguments Solely by Reference

2014-07-13 Thread Nordlöw
On Friday, 11 July 2014 at 17:43:53 UTC, Ali Çehreli wrote: Ali Thx

Re: SImple C++ code to D

2014-07-13 Thread Alexandre via Digitalmars-d-learn
Ok, thanks thanks!!! Have a lot of thinks I need to learn When I generate the exe file, something is wrong with this: dosh.e_magic = cast(WORD)*MZ.ptr; When the PE file is generate in EXE have just the M of MZ...

Re: SImple C++ code to D

2014-07-13 Thread Ali Çehreli via Digitalmars-d-learn
On 07/13/2014 05:21 PM, Alexandre wrote: Ok, thanks thanks!!! Have a lot of thinks I need to learn When I generate the exe file, something is wrong with this: dosh.e_magic = cast(WORD)*MZ.ptr; When the PE file is generate in EXE have just the M of MZ... You put the * outside the cast.

Compile time regex matching

2014-07-13 Thread Jason den Dulk via Digitalmars-d-learn
Hi I am trying to write some code that uses and matches to regular expressions at compile time, but the compiler won't let me because matchFirst and matchAll make use of malloc(). Is there an alternative that I can use that can be run at compile time? Thanks in advance. Jason

Re: SImple C++ code to D

2014-07-13 Thread bearophile via Digitalmars-d-learn
Alexandre: When the PE file is generate in EXE have just the M of MZ... Let's try again, is this better? import std.c.windows.windows: WORD, LONG; struct IMAGE_DOS_HEADER { WORD e_magic = ('M' 8) + 'Z', e_cblp, e_cp, e_crlc, e_cparhdr,

Re: SImple C++ code to D

2014-07-13 Thread Alexandre via Digitalmars-d-learn
Oh, thanks a lot!! With a little change all work! look: struct IMAGE_DOS_HEADER { WORD e_magic, e_cblp, //... void main() { import std.stdio; import std.file; import core.stdc.string; auto dosh = cast(PIMAGE_DOS_HEADER)image.ptr;

Re: std.algorithm.among

2014-07-13 Thread via Digitalmars-d-learn
On Sunday, 13 July 2014 at 20:55:25 UTC, bearophile wrote: D doesn't carry the range of mutable variables across different expressions. What is the reasoning behind this kind of special-casing?

Re: Setting dates

2014-07-13 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, July 11, 2014 04:01:24 Joel via Digitalmars-d-learn wrote: I've been trying to set a date for my program (a small struct): import std.datetime; auto date = cast(DateTime)Clock.currTime(); setDate(date.day, date.month, date.year); Problem is that day month are not integers. And