Re: Defining a static array with values in a range

2015-01-21 Thread anony via Digitalmars-d-learn
On Thursday, 22 January 2015 at 05:56:40 UTC, tcak wrote: I want to define alphanumeric characters in an easy way. Something like that: char[] arr = ['a'..'z', 'A'..'Z', '0'..'9']; Though above example doesn't work. Is there any easy way to do this? I am trying to do something like EBNF def

Re: Defining a static array with values in a range

2015-01-21 Thread Vlad Levenfeld via Digitalmars-d-learn
On Thursday, 22 January 2015 at 05:56:40 UTC, tcak wrote: I want to define alphanumeric characters in an easy way. Something like that: char[] arr = ['a'..'z', 'A'..'Z', '0'..'9']; Though above example doesn't work. Is there any easy way to do this? I am trying to do something like EBNF def

Defining a static array with values in a range

2015-01-21 Thread tcak via Digitalmars-d-learn
I want to define alphanumeric characters in an easy way. Something like that: char[] arr = ['a'..'z', 'A'..'Z', '0'..'9']; Though above example doesn't work. Is there any easy way to do this? I am trying to do something like EBNF definitions. So, I do not want to use loops, or define every

Re: Extracting Structure from HTML using Adam's dom.d

2015-01-21 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 21 January 2015 at 23:31:26 UTC, Nordlöw wrote: This means that I need some kind of interface to extract all the contents of each paragraph that is preceeded by a heading with a specific id (say "H2_A") or content (say "More important"). How do I accomplish that? You can do th

Re: druntime build failing because of masm386 problems

2015-01-21 Thread Andrei Alexandrescu via Digitalmars-d-learn
On 1/18/15 11:22 PM, Jonathan M Davis via Digitalmars-d-learn wrote: It suggests creating an empty masm386.bat file in a directory which is in your path (e.g. C:\dm\bin), and then it'll just work, since masm386 will do nothing. Still, I'm inclined to think that the makefile should be fixed so tha

Re: druntime build failing because of masm386 problems

2015-01-21 Thread Andrei Alexandrescu via Digitalmars-d-learn
On 1/18/15 10:19 PM, Jonathan M Davis via Digitalmars-d-learn wrote: On Sunday, January 18, 2015 23:21:43 jollie via Digitalmars-d-learn wrote: Jonathan M Davis via Digitalmars-d-learn Wrote in message: It's been a while since I did anything in Windows with D, and unfortunately, I need to agai

Re: How can I convert the following C to D.

2015-01-21 Thread bearophile via Digitalmars-d-learn
anon: It looks like what I need. But what's the purpose of the last two empty arrays? Bye, bearophile

Re: How can I convert the following C to D.

2015-01-21 Thread anon via Digitalmars-d-learn
On Thursday, 22 January 2015 at 00:16:23 UTC, bearophile wrote: anon: I have the following C code, how can I do the same in D. Info **info; info = new Info*[hl + 2]; int r; for(r = 0; r < hl; r++) { info[r] = new Info[vl + 2]; } info[r] = NULL; I suggest you to ignore ketmar, he's n

Re: How can I convert the following C to D.

2015-01-21 Thread bearophile via Digitalmars-d-learn
anon: I have the following C code, how can I do the same in D. Info **info; info = new Info*[hl + 2]; int r; for(r = 0; r < hl; r++) { info[r] = new Info[vl + 2]; } info[r] = NULL; I suggest you to ignore ketmar, he's not helping :-) Is your code initializing info[r+1]? This is rou

Re: How can I convert the following C to D.

2015-01-21 Thread anonymous via Digitalmars-d-learn
On Wednesday, 21 January 2015 at 23:44:52 UTC, anon wrote: I have the following C code, how can I do the same in D. Info **info; info = new Info*[hl + 2]; int r; for(r = 0; r < hl; r++) { info[r] = new Info[vl + 2]; } info[r] = NULL; anon The super-literal translation: Info** inf

Re: How can I convert the following C to D.

2015-01-21 Thread bearophile via Digitalmars-d-learn
anon: I got it working with. auto info = new Info[][](hl, vl); and changing the logic so as not check for the NULL. That's probably a better and simpler translation. I have tried to translate your original code too much literally. Bye, bearophile

Re: How can I convert the following C to D.

2015-01-21 Thread anon via Digitalmars-d-learn
On Wednesday, 21 January 2015 at 23:59:34 UTC, ketmar via Digitalmars-d-learn wrote: On Wed, 21 Jan 2015 23:50:59 + anon via Digitalmars-d-learn wrote: On Wednesday, 21 January 2015 at 23:47:46 UTC, ketmar via Digitalmars-d-learn wrote: > On Wed, 21 Jan 2015 23:44:49 + > anon via Di

Re: How can I convert the following C to D.

2015-01-21 Thread ketmar via Digitalmars-d-learn
On Wed, 21 Jan 2015 23:50:59 + anon via Digitalmars-d-learn wrote: > On Wednesday, 21 January 2015 at 23:47:46 UTC, ketmar via > Digitalmars-d-learn wrote: > > On Wed, 21 Jan 2015 23:44:49 + > > anon via Digitalmars-d-learn > > wrote: > > > >> I have the following C code, how can I do

Re: How can I convert the following C to D.

2015-01-21 Thread anon via Digitalmars-d-learn
On Wednesday, 21 January 2015 at 23:47:46 UTC, ketmar via Digitalmars-d-learn wrote: On Wed, 21 Jan 2015 23:44:49 + anon via Digitalmars-d-learn wrote: I have the following C code, how can I do the same in D. Info **info; info = new Info*[hl + 2]; int r; for(r = 0; r < hl; r++) {

Re: How can I convert the following C to D.

2015-01-21 Thread ketmar via Digitalmars-d-learn
On Wed, 21 Jan 2015 23:44:49 + anon via Digitalmars-d-learn wrote: > I have the following C code, how can I do the same in D. > > Info **info; > info = new Info*[hl + 2]; > > int r; > for(r = 0; r < hl; r++) > { > info[r] = new Info[vl + 2]; > } > info[r] = NULL; > > anon this is not

How can I convert the following C to D.

2015-01-21 Thread anon via Digitalmars-d-learn
I have the following C code, how can I do the same in D. Info **info; info = new Info*[hl + 2]; int r; for(r = 0; r < hl; r++) { info[r] = new Info[vl + 2]; } info[r] = NULL; anon

Extracting Structure from HTML using Adam's dom.d

2015-01-21 Thread Nordlöw
I'm trying to figure out how to most easily extract structured information using Adam D Ruppe's dom.d. Typically I want the following HTML example ... More important This is important. Less important This is not important. ... to be reduced to This is important. This means that I nee

Re: On Variable References

2015-01-21 Thread weaselcat via Digitalmars-d-learn
On Wednesday, 21 January 2015 at 17:14:29 UTC, Meta wrote: On Wednesday, 21 January 2015 at 08:23:44 UTC, Per Nordlöw wrote: On Wednesday, 21 January 2015 at 08:22:44 UTC, Per Nordlöw wrote: int x; auto ref xr; Correction: I, of course mean, int x = 42; auto ref xr = x; Walter is

Re: On Variable References

2015-01-21 Thread Nordlöw
On Wednesday, 21 January 2015 at 17:14:29 UTC, Meta wrote: Walter is strongly against adding references a la C++ to D, as he believes they are too complicated and bug prone. He's made several posts on this, but I can't find them now. It would be interesting to read about how Walter thinks here

Re: What to do with InvalidMemoryOperationError

2015-01-21 Thread anonymous via Digitalmars-d-learn
On Wednesday, 21 January 2015 at 13:07:11 UTC, Nordlöw wrote: On Wednesday, 21 January 2015 at 12:10:20 UTC, Nordlöw wrote: On Wednesday, 21 January 2015 at 12:00:47 UTC, Nordlöw wrote: My executable throws as core.exception.InvalidMemoryOperationError@(0) I've tracked it down to being cau

Re: Some array casts

2015-01-21 Thread Douglas Peterson via Digitalmars-d-learn
On Wednesday, 21 January 2015 at 18:08:44 UTC, bearophile wrote: The sizeof values aren't relevant for D array casts. What matters are the array "contents". See: void main() { int[5] m = cast(int[5])[1, 2, 3, 4, 5]; assert(m == [1, 2, 3, 4, 5]); pragma(msg, m.sizeof); // 20u pr

Re: Some array casts

2015-01-21 Thread bearophile via Digitalmars-d-learn
The sizeof values aren't relevant for D array casts. What matters are the array "contents". See: void main() { int[5] m = cast(int[5])[1, 2, 3, 4, 5]; assert(m == [1, 2, 3, 4, 5]); pragma(msg, m.sizeof); // 20u pragma(msg, [1, 2, 3, 4, 5].sizeof); // 8u } Bye, bearophile

Re: On Variable References

2015-01-21 Thread Meta via Digitalmars-d-learn
On Wednesday, 21 January 2015 at 08:23:44 UTC, Per Nordlöw wrote: On Wednesday, 21 January 2015 at 08:22:44 UTC, Per Nordlöw wrote: int x; auto ref xr; Correction: I, of course mean, int x = 42; auto ref xr = x; Walter is strongly against adding references a la C++ to D, as he

Re: What to do with InvalidMemoryOperationError

2015-01-21 Thread anonymous via Digitalmars-d-learn
On Wednesday, 21 January 2015 at 15:34:35 UTC, Per Nordlöw wrote: On Wednesday, 21 January 2015 at 14:50:06 UTC, Ali Çehreli wrote: Known bug with a pull request: https://issues.dlang.org/show_bug.cgi?id=13856 Here is the duplicate of it, which I've opened recently: https://issues.dlang.org

Re: Nested C++ namespace library linking

2015-01-21 Thread Guillaume Chatelet via Digitalmars-d-learn
On Wednesday, 21 January 2015 at 14:59:15 UTC, John Colvin wrote: Looks like a bug to me, for sure. In the mean-time you may be able to use some pragma(mangle, ...) hacks to force the compiler to emit the right symbols. Thx John, extern(C++, A.B) { struct Type {} pragma(mangle,"_ZN1A1B3f

Re: What to do with InvalidMemoryOperationError

2015-01-21 Thread via Digitalmars-d-learn
On Wednesday, 21 January 2015 at 14:50:06 UTC, Ali Çehreli wrote: Known bug with a pull request: https://issues.dlang.org/show_bug.cgi?id=13856 Here is the duplicate of it, which I've opened recently: https://issues.dlang.org/show_bug.cgi?id=14005 Ali How can this affect Mmfile plus spl

Re: Some array casts

2015-01-21 Thread Baz via Digitalmars-d-learn
On Wednesday, 21 January 2015 at 14:31:15 UTC, bearophile wrote: Currently this is accepted: int[2] m = cast(int[2])[1, 2]; But Kenji suggests that the cast from int[] to int[2][1] should not be accepted. Do you know why? Reference: https://issues.dlang.org/show_bug.cgi?id=7514 Bye and than

Re: Some array casts

2015-01-21 Thread bearophile via Digitalmars-d-learn
Baz: int[3] m = cast(int[3])[1, 2, 3]; writeln(m.sizeof); writeln([1, 2, 3].sizeof); The sizeof values aren't relevant for D array casts. What matters are the array "contents". Bye, bearophile

Re: Nested C++ namespace library linking

2015-01-21 Thread John Colvin via Digitalmars-d-learn
On Tuesday, 20 January 2015 at 21:10:59 UTC, Guillaume Chatelet wrote: Consider the following foo.cpp namespace A { namespace B { struct Type {}; int foo(Type unused){ return 42; } } } Compile it : g++ foo.cpp -c -o foo.o Then the following main.d extern(C++, A.B) { struct Type {} int

Re: What to do with InvalidMemoryOperationError

2015-01-21 Thread Ali Çehreli via Digitalmars-d-learn
On 01/21/2015 04:10 AM, "Nordlöw" wrote: On Wednesday, 21 January 2015 at 12:00:47 UTC, Nordlöw wrote: My executable throws as core.exception.InvalidMemoryOperationError@(0) I've tracked it down to being caused by foreach (line; File(path).byLine) {} when path contains a very large

Re: Some array casts

2015-01-21 Thread Baz via Digitalmars-d-learn
On Wednesday, 21 January 2015 at 14:41:48 UTC, Baz wrote: On Wednesday, 21 January 2015 at 14:31:15 UTC, bearophile wrote: Currently this is accepted: int[2] m = cast(int[2])[1, 2]; But Kenji suggests that the cast from int[] to int[2][1] should not be accepted. Do you know why? Reference:

Some array casts

2015-01-21 Thread bearophile via Digitalmars-d-learn
Currently this is accepted: int[2] m = cast(int[2])[1, 2]; But Kenji suggests that the cast from int[] to int[2][1] should not be accepted. Do you know why? Reference: https://issues.dlang.org/show_bug.cgi?id=7514 Bye and thank you, bearophile

Re: What to do with InvalidMemoryOperationError

2015-01-21 Thread Nordlöw
On Wednesday, 21 January 2015 at 12:10:20 UTC, Nordlöw wrote: On Wednesday, 21 January 2015 at 12:00:47 UTC, Nordlöw wrote: My executable throws as core.exception.InvalidMemoryOperationError@(0) I've tracked it down to being caused by foreach (line; File(path).byLine) {} when path co

Re: What to do with InvalidMemoryOperationError

2015-01-21 Thread Nordlöw
On Wednesday, 21 January 2015 at 12:00:47 UTC, Nordlöw wrote: My executable throws as core.exception.InvalidMemoryOperationError@(0) I've tracked it down to being caused by foreach (line; File(path).byLine) {} when path contains a very large text file (392 MB, 1658080 lines). Do I h

What to do with InvalidMemoryOperationError

2015-01-21 Thread Nordlöw
My executable throws as core.exception.InvalidMemoryOperationError@(0) when compiled with DMD git master. I get no stack trace in GDB. What to do?

Re: Nested C++ namespace library linking

2015-01-21 Thread Kagamin via Digitalmars-d-learn
You can ask to add a keyword to bugzilla for C++ issues, this can help to improve their visibility and searchability.

On Variable References

2015-01-21 Thread via Digitalmars-d-learn
Why doesn't D allow declarations such as int x; auto ref xr; ? What is so fundamentally bad about this compared to foreach variables and function arguments passed by reference? Will Walters latest commits regarding http://wiki.dlang.org/DIP25 change this matter?

Re: On Variable References

2015-01-21 Thread via Digitalmars-d-learn
On Wednesday, 21 January 2015 at 08:22:44 UTC, Per Nordlöw wrote: int x; auto ref xr; Correction: I, of course mean, int x = 42; auto ref xr = x;