Re: Help optimizing UnCompress for gzipped files

2018-01-03 Thread Christian Köstlin via Digitalmars-d-learn
On 03.01.18 22:33, Steven Schveighoffer wrote: > On 1/3/18 3:28 PM, Steven Schveighoffer wrote: >> 1. The major differentiator between the C and D algorithms is the use >> of C realloc. This one thing saves the most time. I'm going to update >> iopipe so you can use it (stand by). I will also be

Re: Gc/D_runtime prevents dangling pointers?

2018-01-03 Thread thedeemon via Digitalmars-d-learn
On Wednesday, 3 January 2018 at 22:22:06 UTC, tipdbmp wrote: x doesn't seem to be a dangling pointer, how come? What is your definition of a dangling pointer? In the shown example we have a reference to a piece of memory containing 'x', so this memory is not freed, it's used by the program.

Re: Error trying to build dlang.org

2018-01-03 Thread Tony via Digitalmars-d-learn
On Thursday, 4 January 2018 at 02:20:32 UTC, Seb wrote: On Thursday, 4 January 2018 at 01:50:47 UTC, Tony wrote: Following the instructions here on Ubuntu 16.04: https://github.com/dlang/dlang.org/blob/master/CONTRIBUTING.md I did the command make -f posix.mak html but it failed to

Re: why @property cannot be pass as ref ?

2018-01-03 Thread ChangLong via Digitalmars-d-learn
On Wednesday, 3 January 2018 at 08:51:55 UTC, Simen Kjærås wrote: On Saturday, 30 December 2017 at 03:49:37 UTC, ChangLong wrote: What I am try to do is implement a unique data type. (the ownership auto moved into new handle) Have you considered std.typecons.Unique[0]? If yes, in what ways

Re: Using iopipe to stream a gzipped file

2018-01-03 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/3/18 12:03 PM, Andrew wrote: Thanks for looking into this. So it looks like the file you have is a concatenated gzip file. If I gunzip the file and recompress it, it works properly. Looking at the docs of zlib inflate [1]: " Unlike the gunzip utility and gzread() ..., inflate() will

Re: Putting function pointers / delegates into associative array.

2018-01-03 Thread visitor via Digitalmars-d-learn
On Thursday, 4 January 2018 at 01:40:21 UTC, Mark wrote: What I'm trying to do here is to be able to call a function based off of a key. class tester { private void delegate() [char] funcs; this() { funcs = ['a': , 'b': ]; } public void

Re: Error trying to build dlang.org

2018-01-03 Thread Seb via Digitalmars-d-learn
On Thursday, 4 January 2018 at 01:50:47 UTC, Tony wrote: Following the instructions here on Ubuntu 16.04: https://github.com/dlang/dlang.org/blob/master/CONTRIBUTING.md I did the command make -f posix.mak html but it failed to successfully complete:

Error trying to build dlang.org

2018-01-03 Thread Tony via Digitalmars-d-learn
Following the instructions here on Ubuntu 16.04: https://github.com/dlang/dlang.org/blob/master/CONTRIBUTING.md I did the command make -f posix.mak html but it failed to successfully complete: --- make[1]: Leaving directory

Putting function pointers / delegates into associative array.

2018-01-03 Thread Mark via Digitalmars-d-learn
What I'm trying to do here is to be able to call a function based off of a key. I'm not sure how to do this, I've been messing around a bit, but the compiler doesn't like what I'm doing. Im getting: test.d(20): Error: cannot implicitly convert expression of type void delegate() to void

Re: How to use the -I command line switch?

2018-01-03 Thread jmh530 via Digitalmars-d-learn
On Wednesday, 3 January 2018 at 22:52:10 UTC, Seb wrote: Which documentation are you referring to? If it's the specification, just click "edit". I know how to edit it. I just don't know how to word it so that it isn't so confusing.

Re: how do I get only static member of a class?

2018-01-03 Thread Ali Çehreli via Digitalmars-d-learn
On 01/03/2018 03:48 PM, Marc wrote: I found no way with __traits() on std.traits. I found isStaticFunction and isStaticArray but nothing about a member. Is this by desgin? Give a class like: class C { static int a, b, c; int d; } I'd like to get a, b and c. I'm using this:

Re: No modification of pointer values in safe functions?

2018-01-03 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Jan 03, 2018 at 03:42:07PM -0700, Jonathan M Davis via Digitalmars-d-learn wrote: > On Wednesday, January 03, 2018 22:25:16 Mark via Digitalmars-d-learn wrote: [...] > > https://dlang.org/spec/function.html#safe-functions > > > > "The following operations are not allowed in safe

how do I get only static member of a class?

2018-01-03 Thread Marc via Digitalmars-d-learn
I found no way with __traits() on std.traits. I found isStaticFunction and isStaticArray but nothing about a member. Is this by desgin? Give a class like: class C { static int a, b, c; int d; } I'd like to get a, b and c. I'm using this: __traits(allMembers, C)

Re: How to use the -I command line switch?

2018-01-03 Thread Seb via Digitalmars-d-learn
On Wednesday, 3 January 2018 at 21:51:07 UTC, jmh530 wrote: On Wednesday, 3 January 2018 at 18:35:21 UTC, Ali Çehreli wrote: -I is for import directives only. imports are needed to compile the importing module. All other modules still need to be compiled themselves and added to the program

Re: No modification of pointer values in safe functions?

2018-01-03 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, January 03, 2018 22:25:16 Mark via Digitalmars-d-learn wrote: > On Wednesday, 3 January 2018 at 22:12:01 UTC, Jonathan M Davis > > wrote: > > On Wednesday, January 03, 2018 22:02:22 Mark via > > > > Digitalmars-d-learn wrote: > >> The documentation says the modification of pointer

Re: No modification of pointer values in safe functions?

2018-01-03 Thread Mark via Digitalmars-d-learn
On Wednesday, 3 January 2018 at 22:12:01 UTC, Jonathan M Davis wrote: On Wednesday, January 03, 2018 22:02:22 Mark via Digitalmars-d-learn wrote: The documentation says the modification of pointer values is not allowed in safe functions. Yet the following compiles fine on dmd: void main()

Re: How to use the -I command line switch?

2018-01-03 Thread Tony via Digitalmars-d-learn
On Wednesday, 3 January 2018 at 12:21:28 UTC, tipdbmp wrote: // C:\libs\my_module.d module my_module; void foo() {} // main.d module main; import my_module; void main() { foo(); } Running dmd with: dmd -IC:\libs main.d my_module.d I get: Error: module my_module is in file

Re: No modification of pointer values in safe functions?

2018-01-03 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Jan 03, 2018 at 10:02:22PM +, Mark via Digitalmars-d-learn wrote: > The documentation says the modification of pointer values is not > allowed in safe functions. Yet the following compiles fine on dmd: > > void main() @safe > { > int* x = new int; > int* y = new int; >

Gc/D_runtime prevents dangling pointers?

2018-01-03 Thread tipdbmp via Digitalmars-d-learn
char * get_dangling_ptr() { char[] a; a.reserve(15); a ~= 'x'; char *x = [0]; auto a_initial_ptr = a.ptr; foreach (_; 0 .. 30) { a ~= 'y'; //a.assumeSafeAppend() ~= 'y'; } assert(a.ptr != a_initial_ptr, "a should've reallocated"); // trying

Re: No modification of pointer values in safe functions?

2018-01-03 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, January 03, 2018 22:02:22 Mark via Digitalmars-d-learn wrote: > The documentation says the modification of pointer values is not > allowed in safe functions. Yet the following compiles fine on dmd: > > void main() @safe > { > int* x = new int; > int* y = new int; > y=x; > } > >

Re: No modification of pointer values in safe functions?

2018-01-03 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 3 January 2018 at 22:02:22 UTC, Mark wrote: The documentation says the modification of pointer values is not allowed in safe functions. I think that refers to like x++ rather than x=y.

No modification of pointer values in safe functions?

2018-01-03 Thread Mark via Digitalmars-d-learn
The documentation says the modification of pointer values is not allowed in safe functions. Yet the following compiles fine on dmd: void main() @safe { int* x = new int; int* y = new int; y=x; } Is this simply a compiler bug?

Re: How do I use ncurses library with D? are there any wrapper?

2018-01-03 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Jan 03, 2018 at 09:04:00PM +, Adam D. Ruppe via Digitalmars-d-learn wrote: > On Wednesday, 3 January 2018 at 19:15:18 UTC, H. S. Teoh wrote: > > https://github.com/adamdruppe/arsd/blob/master/terminal.d [...] > > Depending on what you want, you could also tack on eventloop.d from

Re: How to use the -I command line switch?

2018-01-03 Thread Ali Çehreli via Digitalmars-d-learn
On 01/03/2018 01:42 PM, Tony wrote: > On Wednesday, 3 January 2018 at 18:35:21 UTC, Ali Çehreli wrote: >> Working as expected... :) >> > What about the error message? If -I is only for DMD finding "import ..." > files, and not files on the command line, why does DMD list what was in > the -I

Re: How to use the -I command line switch?

2018-01-03 Thread jmh530 via Digitalmars-d-learn
On Wednesday, 3 January 2018 at 18:35:21 UTC, Ali Çehreli wrote: -I is for import directives only. imports are needed to compile the importing module. All other modules still need to be compiled themselves and added to the program either as individual .o files or as libraries (e.g. .a, .lib,

Re: How to use the -I command line switch?

2018-01-03 Thread Tony via Digitalmars-d-learn
On Wednesday, 3 January 2018 at 18:35:21 UTC, Ali Çehreli wrote: On 01/03/2018 09:10 AM, tipdbmp wrote: dmd main.d C:\libs\my_module.d That does not use the -I switch. It compiles if I specify the full path to my_module.d:     dmd -IC:\libs main.d C:\libs\my_module.d I don't understand the

Re: Help optimizing UnCompress for gzipped files

2018-01-03 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/3/18 3:28 PM, Steven Schveighoffer wrote: 1. The major differentiator between the C and D algorithms is the use of C realloc. This one thing saves the most time. I'm going to update iopipe so you can use it (stand by). I will also be examining how to simulate using realloc when not using

Re: How do I use ncurses library with D? are there any wrapper?

2018-01-03 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 3 January 2018 at 19:15:18 UTC, H. S. Teoh wrote: https://github.com/adamdruppe/arsd/blob/master/terminal.d indeed. some dox here http://dpldocs.info/arsd.terminal Best of all: zero dependencies, just copy terminal.d into a subdirectory called arsd, and `import

Re: Efficient way to pass struct as parameter

2018-01-03 Thread Jacob Carlborg via Digitalmars-d-learn
On 2018-01-03 08:02, Tim Hsu wrote: It needs some experiment. This is the correct answer. Never assume anything about performance before having tested it. -- /Jacob Carlborg

Re: Can I use D with the Microsoft universal windows platform?

2018-01-03 Thread Jerry A. via Digitalmars-d-learn
On Wednesday, 3 January 2018 at 18:33:27 UTC, Ozan wrote: Hi Are there any use cases or libraries for using D in Microsoft's universal windows platform environment? It would be nice to have XBOX Apps build on D ;-) Regards Ozan Ethan Watson gave a talk about D and they launched their game

Re: Help optimizing UnCompress for gzipped files

2018-01-03 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/3/18 9:42 AM, Steven Schveighoffer wrote: On 1/3/18 2:47 AM, Christian Köstlin wrote: On 02.01.18 21:13, Steven Schveighoffer wrote: Well, you don't need to use appender for that (and doing so is copying a lot of the data an extra time). All you need is to extend the pipe until there

Re: How do I use ncurses library with D? are there any wrapper?

2018-01-03 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Jan 03, 2018 at 03:47:58PM +, Marc via Digitalmars-d-learn wrote: > Long time ago, IIRC, I read somewhere there was a ncurses for D but > now I can't find it are there any wrapper or am I mistaken? anyway, > I'm doing it from scratch and not porting anything so even a library > with

Re: what's the proper way to convert wchar[] to string?

2018-01-03 Thread Marc via Digitalmars-d-learn
On Wednesday, 3 January 2018 at 18:59:39 UTC, Ali Çehreli wrote: On 01/03/2018 10:50 AM, Marc wrote: when calling winapi functions, usually you to deal with the result in wchar[]. How do I convert it to string in D to be usable by the application? does D have a native for this? std.conv has

Re: Efficient way to pass struct as parameter

2018-01-03 Thread Ali Çehreli via Digitalmars-d-learn
On 01/03/2018 10:40 AM, Patrick Schluter wrote: > On Tuesday, 2 January 2018 at 23:27:22 UTC, H. S. Teoh wrote: >> >> When it comes to optimization, there are 3 rules: profile, profile, >> profile. I used to heavily hand-"optimize" my code a lot (I come from >> a strong C/C++ background --

Re: what's the proper way to convert wchar[] to string?

2018-01-03 Thread Ali Çehreli via Digitalmars-d-learn
On 01/03/2018 10:50 AM, Marc wrote: when calling winapi functions, usually you to deal with the result in wchar[]. How do I convert it to string in D to be usable by the application? does D have a native for this? std.conv has to and text: auto s0 = w.text; auto s1 = w.to!string;

what's the proper way to convert wchar[] to string?

2018-01-03 Thread Marc via Digitalmars-d-learn
when calling winapi functions, usually you to deal with the result in wchar[]. How do I convert it to string in D to be usable by the application? does D have a native for this?

Re: Efficient way to pass struct as parameter

2018-01-03 Thread Patrick Schluter via Digitalmars-d-learn
On Tuesday, 2 January 2018 at 23:27:22 UTC, H. S. Teoh wrote: When it comes to optimization, there are 3 rules: profile, profile, profile. I used to heavily hand-"optimize" my code a lot (I come from a strong C/C++ background -- premature optimization seems to be a common malady among us in

Re: How to use the -I command line switch?

2018-01-03 Thread Ali Çehreli via Digitalmars-d-learn
On 01/03/2018 09:10 AM, tipdbmp wrote: dmd main.d C:\libs\my_module.d That does not use the -I switch. It compiles if I specify the full path to my_module.d:     dmd -IC:\libs main.d C:\libs\my_module.d I don't understand the error message though. -I is for import directives only. imports

Can I use D with the Microsoft universal windows platform?

2018-01-03 Thread Ozan via Digitalmars-d-learn
Hi Are there any use cases or libraries for using D in Microsoft's universal windows platform environment? It would be nice to have XBOX Apps build on D ;-) Regards Ozan

Re: How to use the -I command line switch?

2018-01-03 Thread jmh530 via Digitalmars-d-learn
On Wednesday, 3 January 2018 at 17:10:22 UTC, tipdbmp wrote: dmd main.d C:\libs\my_module.d That does not use the -I switch. It compiles if I specify the full path to my_module.d: dmd -IC:\libs main.d C:\libs\my_module.d I don't understand the error message though. I tried a few other

Re: Is it bad form to put code in package.d other than imports?

2018-01-03 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Jan 03, 2018 at 12:43:52AM -0700, Jonathan M Davis via Digitalmars-d-learn wrote: > On Wednesday, January 03, 2018 06:10:10 Soulsbane via Digitalmars-d-learn > wrote: > > I've only understood that imports should go in package.d. I'm seeing > > more and more packages on code.dlang.org

Re: How do you do "const nazi" in D?

2018-01-03 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, January 03, 2018 17:27:38 Marc via Digitalmars-d-learn wrote: > for a safe programming, since C/C++ times I try to make thing > const as possible. locals, parameters etc anything which isn't > going to change. > How do you do that in D? immutable everywhere? > > for example: > >

How do you do "const nazi" in D?

2018-01-03 Thread Marc via Digitalmars-d-learn
for a safe programming, since C/C++ times I try to make thing const as possible. locals, parameters etc anything which isn't going to change. How do you do that in D? immutable everywhere? for example: foreach(Field field; fields) { immutable string htmlOutputfile =

Re: How to use the -I command line switch?

2018-01-03 Thread tipdbmp via Digitalmars-d-learn
dmd main.d C:\libs\my_module.d That does not use the -I switch. It compiles if I specify the full path to my_module.d: dmd -IC:\libs main.d C:\libs\my_module.d I don't understand the error message though.

Re: Using iopipe to stream a gzipped file

2018-01-03 Thread Andrew via Digitalmars-d-learn
On Wednesday, 3 January 2018 at 16:09:19 UTC, Steven Schveighoffer wrote: On 1/3/18 9:45 AM, Andrew wrote: Hi, I have a very large gziped text file (all ASCII characters and ~500GB) that I want to stream and process line-by-line, and I thought the iopipe library would be perfect for this,

Re: How do I use ncurses library with D? are there any wrapper?

2018-01-03 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, January 03, 2018 15:47:58 Marc via Digitalmars-d-learn wrote: > Long time ago, IIRC, I read somewhere there was a ncurses for D > but now I can't find it are there any wrapper or am I mistaken? > anyway, I'm doing it from scratch and not porting anything so > even a library with same

Re: Efficient way to pass struct as parameter

2018-01-03 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Jan 03, 2018 at 07:02:28AM +, Tim Hsu via Digitalmars-d-learn wrote: > On Tuesday, 2 January 2018 at 22:49:20 UTC, Adam D. Ruppe wrote: > > On Tuesday, 2 January 2018 at 22:17:14 UTC, Johan Engelen wrote: > > > Pass the Vector3f by value. > > > > This is very frequently the correct

Re: Using iopipe to stream a gzipped file

2018-01-03 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/3/18 9:45 AM, Andrew wrote: Hi, I have a very large gziped text file (all ASCII characters and ~500GB) that I want to stream and process line-by-line, and I thought the iopipe library would be perfect for this, but I can't seem to get it to work. So far, this is the closest I have to

Re: how to localize console and GUI apps in Windows

2018-01-03 Thread Andrei via Digitalmars-d-learn
On Wednesday, 3 January 2018 at 09:11:32 UTC, thedeemon wrote: Windows API contains two sets of functions: those whose names end with A (meaning ANSI), the other where names end with W (wide characters, meaning Unicode). The sample uses TextOutA, this function that expects 8-bit encoding.

How do I use ncurses library with D? are there any wrapper?

2018-01-03 Thread Marc via Digitalmars-d-learn
Long time ago, IIRC, I read somewhere there was a ncurses for D but now I can't find it are there any wrapper or am I mistaken? anyway, I'm doing it from scratch and not porting anything so even a library with same functionality as ncurses for D is welcome.

Re: How to use the -I command line switch?

2018-01-03 Thread jmh530 via Digitalmars-d-learn
On Wednesday, 3 January 2018 at 12:21:28 UTC, tipdbmp wrote: // C:\libs\my_module.d module my_module; void foo() {} // main.d module main; import my_module; void main() { foo(); } Running dmd with: dmd -IC:\libs main.d my_module.d I get: Error: module my_module is in file

Using iopipe to stream a gzipped file

2018-01-03 Thread Andrew via Digitalmars-d-learn
Hi, I have a very large gziped text file (all ASCII characters and ~500GB) that I want to stream and process line-by-line, and I thought the iopipe library would be perfect for this, but I can't seem to get it to work. So far, this is the closest I have to getting it to work: import

Re: Help optimizing UnCompress for gzipped files

2018-01-03 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/3/18 2:47 AM, Christian Köstlin wrote: On 02.01.18 21:13, Steven Schveighoffer wrote: Well, you don't need to use appender for that (and doing so is copying a lot of the data an extra time). All you need is to extend the pipe until there isn't any more new data, and it will all be in the

How to use the -I command line switch?

2018-01-03 Thread tipdbmp via Digitalmars-d-learn
// C:\libs\my_module.d module my_module; void foo() {} // main.d module main; import my_module; void main() { foo(); } Running dmd with: dmd -IC:\libs main.d my_module.d I get: Error: module my_module is in file 'my_module.d' which cannot be read import path[0] = C:\libs

Re: how to localize console and GUI apps in Windows

2018-01-03 Thread Martin Krejcirik via Digitalmars-d-learn
On Friday, 29 December 2017 at 11:14:39 UTC, zabruk70 wrote: AFAIK, Windows GUI have no ANSI/OEM problem. You can use Unicode. Be advised there are some problems with console UTF-8 input/output in Windows. The most usable is Win10 new console window but I recommend to use Windows API

Re: how to localize console and GUI apps in Windows

2018-01-03 Thread thedeemon via Digitalmars-d-learn
On Wednesday, 3 January 2018 at 09:11:32 UTC, thedeemon wrote: you need to use TextOutW that accepts 16-bit Unicode, so just convert your UTF-8 D strings to 16-bit Unicode wstrings, there are appropriate conversion functions in Phobos. Some details: import std.utf : toUTF16z; ... string s =

Buy Real passport, drivers license, IELTS, ID Cards (http://buyrealfakedocument.com)

2018-01-03 Thread james via Digitalmars-d-learn
Get Registered IELTS certificates without attending the Exam ( http://buyrealfakedocument.com ) We are a unique manufacturer of high-quality registered citizenship documents with the best machines and holograms that duplicate as database database driver's license, passports, biometric

Re: how to localize console and GUI apps in Windows

2018-01-03 Thread thedeemon via Digitalmars-d-learn
On Wednesday, 3 January 2018 at 06:42:42 UTC, Andrei wrote: AFAIK, Windows GUI have no ANSI/OEM problem. You can use Unicode. Partly, yes. Just for a test I tried to "russify" the example Windows GUI program that comes with D installation pack (samples\d\winsamp.d). Window captions, button

Re: why @property cannot be pass as ref ?

2018-01-03 Thread Simen Kjærås via Digitalmars-d-learn
On Saturday, 30 December 2017 at 03:49:37 UTC, ChangLong wrote: What I am try to do is implement a unique data type. (the ownership auto moved into new handle) Have you considered std.typecons.Unique[0]? If yes, in what ways does it not cover your needs? Your example code written with

Re: Is it bad form to put code in package.d other than imports?

2018-01-03 Thread Soulsbane via Digitalmars-d-learn
On Wednesday, 3 January 2018 at 07:43:52 UTC, Jonathan M Davis wrote: On Wednesday, January 03, 2018 06:10:10 Soulsbane via Digitalmars-d-learn wrote: [...] The entire reason that the package.d feature was added was so that it would be possible to split a module into a package without

Re: Help optimizing UnCompress for gzipped files

2018-01-03 Thread Christian Köstlin via Digitalmars-d-learn
On 02.01.18 14:51, Adam D. Ruppe wrote: > On Tuesday, 2 January 2018 at 10:27:11 UTC, Christian Köstlin wrote: >> After this I analyzed the first step of the process (gunzipping the >> data from a file to memory), and found out, that dlangs UnCompress is >> much slower than java, and ruby and