Debugging a druntime issue found by AutoTester

2017-12-11 Thread Ali Çehreli via Digitalmars-d-learn
The automatic tests for a PR failed for a target that I could not test myself: 32-bit build on Darwin_64_32. https://auto-tester.puremagic.com/show-run.ghtml?projectid=1=2940199=20802787=true Testing attach_detach timelimit -t 10 ./generated/osx/debug/32/attach_detach

Re: Static array as immutable

2017-12-11 Thread Radu via Digitalmars-d-learn
On Tuesday, 12 December 2017 at 07:33:47 UTC, Ivan Trombley wrote: Is there some way that I can make this array immutable? static float[256] ga = void; static foreach (i; 0 .. 256) ga[i] = (i / 255.0f) ^^ (1 / 2.2f); Check https://dlang.org/phobos/std_exception.html#assumeUnique

Static array as immutable

2017-12-11 Thread Ivan Trombley via Digitalmars-d-learn
Is there some way that I can make this array immutable? static float[256] ga = void; static foreach (i; 0 .. 256) ga[i] = (i / 255.0f) ^^ (1 / 2.2f);

Re: OT (Was: Re: What's the proper way to use std.getopt?)

2017-12-11 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, December 11, 2017 15:38:44 H. S. Teoh via Digitalmars-d-learn wrote: > On Mon, Dec 11, 2017 at 11:35:53PM +, Seb via Digitalmars-d-learn > wrote: [...] > > > D style would be to use sth. like this (instead of try/catch): > > > > ``` > > scope(failure) { > > > > e.msg.writeln; > >

Re: Why is there no std.stream anymore?

2017-12-11 Thread codephantom via Digitalmars-d-learn
On Tuesday, 12 December 2017 at 02:15:13 UTC, codephantom wrote: just playing around with this also...in case you only want to read n bytes.. // --- module test; import std.stdio, std.file, std.exception; import std.datetime.stopwatch; void main() { string

Re: Why is there no std.stream anymore?

2017-12-11 Thread codephantom via Digitalmars-d-learn
On Monday, 11 December 2017 at 20:51:41 UTC, Jordi Gutiérrez Hermoso wrote: I'd like to read from a file, one byte at a time, without loading the whole file in memory. just playing around with this // module test; import std.stdio, std.file, std.exception; void

Re: Open Scene Graph For D?

2017-12-11 Thread Tofu ninja via Digitalmars-d-learn
On Thursday, 7 December 2017 at 19:30:13 UTC, Tofu ninja wrote: Is there a binding for it? Just a question, trying to convince people at work to use D and that is something they asked about. Guess not

Re: Clarify "Starting as a Contributor" document

2017-12-11 Thread Seb via Digitalmars-d-learn
On Monday, 11 December 2017 at 14:13:41 UTC, Dukc wrote: On Sunday, 10 December 2017 at 08:18:17 UTC, Ali Çehreli wrote: This page is very good: https://wiki.dlang.org/Starting_as_a_Contributor I need clarifications Another oddity: Someone has apparently made DRuntime build to use

Re: What's the proper way to use std.getopt?

2017-12-11 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 11 December 2017 at 20:58:25 UTC, Jordi Gutiérrez Hermoso wrote: I don't quite understand what to do if getopt throws. I would have hoped for something like I might have already said this to you on IRC but the way I'd do it (if you must do this) is: void main(string[] args) {

Re: Clarify "Starting as a Contributor" document

2017-12-11 Thread Seb via Digitalmars-d-learn
On Monday, 11 December 2017 at 06:43:46 UTC, Ali Çehreli wrote: On 12/10/2017 12:36 AM, Seb wrote: > [...] is no harm > [...] Thanks. I don't care anymore. :) >> [...] should have >> [...] a comment >> [...] necessary >> [...] message should > [...] second part > [...] opened a PR and > [...]

OT (Was: Re: What's the proper way to use std.getopt?)

2017-12-11 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Dec 11, 2017 at 11:35:53PM +, Seb via Digitalmars-d-learn wrote: [...] > D style would be to use sth. like this (instead of try/catch): > > ``` > scope(failure) { > e.msg.writeln; > 1.exit; > } > ``` Frankly, much as I love UFCS syntax, I think this is taking it a little too far.

Re: What's the proper way to use std.getopt?

2017-12-11 Thread Jordi Gutiérrez Hermoso via Digitalmars-d-learn
On Monday, 11 December 2017 at 21:24:41 UTC, Mike Wey wrote: try { auto helpInformation = getopt( args, "input|i", "The input", , "output|o", "The output", ); if (helpInformation.helpWanted) {

Re: Get pointer or reference of an element in Array(struct)

2017-12-11 Thread Arun Chandrasekaran via Digitalmars-d-learn
On Saturday, 9 December 2017 at 19:26:26 UTC, David Nadlinger wrote: but "free" references don't exist in the language. To the point! Thanks!

Re: What's the proper way to use std.getopt?

2017-12-11 Thread Seb via Digitalmars-d-learn
On Monday, 11 December 2017 at 21:24:41 UTC, Mike Wey wrote: On 11-12-17 21:58, Jordi Gutiérrez Hermoso wrote: [...] I would use something like this, print the help information for --help, print an error for invalid arguments: ``` try { auto helpInformation = getopt(

Re: Why is there no std.stream anymore?

2017-12-11 Thread Seb via Digitalmars-d-learn
On Monday, 11 December 2017 at 22:58:53 UTC, Jordi Gutiérrez Hermoso wrote: On Monday, 11 December 2017 at 21:21:51 UTC, Steven Schveighoffer wrote: Use the undead repository: Wow, really? Is the removal of stream from D some kind of error that hasn't been corrected yet? Well of course you

Re: Why is there no std.stream anymore?

2017-12-11 Thread flamencofantasy via Digitalmars-d-learn
On Monday, 11 December 2017 at 20:51:41 UTC, Jordi Gutiérrez Hermoso wrote: I'd like to read from a file, one byte at a time, without loading the whole file in memory. I was hoping I could do something like auto f = File("somefile"); foreach(c; f.byChar) { process(c); } but

Re: Why is there no std.stream anymore?

2017-12-11 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, December 11, 2017 22:58:53 Jordi Gutiérrez Hermoso via Digitalmars-d-learn wrote: > On Monday, 11 December 2017 at 21:21:51 UTC, Steven Schveighoffer > > wrote: > > Use the undead repository: > Wow, really? Is the removal of stream from D some kind of error > that hasn't been corrected

Re: Why is there no std.stream anymore?

2017-12-11 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/11/17 5:58 PM, Jordi Gutiérrez Hermoso wrote: On Monday, 11 December 2017 at 21:21:51 UTC, Steven Schveighoffer wrote: Use the undead repository: Wow, really? Is the removal of stream from D some kind of error that hasn't been corrected yet? No, it was removed because it was

Re: File.byLine for either Windows / Unix newlines

2017-12-11 Thread Dennis via Digitalmars-d-learn
Thanks for your reply, that clears it up. On Monday, 11 December 2017 at 21:13:11 UTC, Steven Schveighoffer wrote: 3. Stop using Windows ;) Haha, if only the rest of the userbase would follow.

Re: Overloading float operators

2017-12-11 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, December 11, 2017 19:28:47 rumbu via Digitalmars-d-learn wrote: > Is there any way to overload specific floating point operators? > https://dlang.org/spec/expression.html#floating-point-comparisons If those haven't been deprecated yet, they almost certainly will be. It was decided that

Re: Why is there no std.stream anymore?

2017-12-11 Thread Jordi Gutiérrez Hermoso via Digitalmars-d-learn
On Monday, 11 December 2017 at 21:21:51 UTC, Steven Schveighoffer wrote: Use the undead repository: Wow, really? Is the removal of stream from D some kind of error that hasn't been corrected yet?

Re: What's the proper way to use std.getopt?

2017-12-11 Thread Mike Wey via Digitalmars-d-learn
On 11-12-17 21:58, Jordi Gutiérrez Hermoso wrote: but instead, the docstring from getopt is only generated if all arguments are valid, i.e. when it's the least needed because the user already knew what to input. What's the proper style, then? Can someone show me a good example of how to use

Re: Why is there no std.stream anymore?

2017-12-11 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/11/17 3:51 PM, Jordi Gutiérrez Hermoso wrote: I'd like to read from a file, one byte at a time, without loading the whole file in memory. I was hoping I could do something like    auto f = File("somefile");    foreach(c; f.byChar) {    process(c);    } but there appears to be

Re: File.byLine for either Windows / Unix newlines

2017-12-11 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/11/17 10:40 AM, Dennis wrote: I'm on Windows and I recently got confused by how Phobos functions handle newlines. ``` void main() {     import std.stdio;     import std.path : buildPath, tempDir;     auto path = buildPath(tempDir(), "test.txt");     auto file = new File(path, "w");

Re: Tuple Array Sorting

2017-12-11 Thread Biotronic via Digitalmars-d-learn
On Monday, 11 December 2017 at 19:46:04 UTC, Vino wrote: import std.algorithm; import std.container.array; import std.file: SpanMode, dirEntries, isDir ; import std.stdio: writefln, writeln; import std.typecons: Tuple, tuple; import std.range: chain; void main () { auto FFs =

What's the proper way to use std.getopt?

2017-12-11 Thread Jordi Gutiérrez Hermoso via Digitalmars-d-learn
I don't quite understand what to do if getopt throws. I would have hoped for something like int arg1; string arg2; auto parser = getopt("opt1", "docstring 1", , "opt2", "docstring 2", ); try { auto opts = parser.parse(args) } except(BadArguments) {

Re: return ref this -dip1000

2017-12-11 Thread vit via Digitalmars-d-learn
On Monday, 11 December 2017 at 20:44:06 UTC, Eugene Wissner wrote: On Monday, 11 December 2017 at 20:40:09 UTC, vit wrote: This code doesn't compile with -dip1000: struct Foo{ int foo; ref int bar(){ return foo; } } Error: returning `this.foo` escapes a reference to

Why is there no std.stream anymore?

2017-12-11 Thread Jordi Gutiérrez Hermoso via Digitalmars-d-learn
I'd like to read from a file, one byte at a time, without loading the whole file in memory. I was hoping I could do something like auto f = File("somefile"); foreach(c; f.byChar) { process(c); } but there appears to be no such way to do it anymore. Instead, the stdlib seems

Re: return ref this -dip1000

2017-12-11 Thread Eugene Wissner via Digitalmars-d-learn
On Monday, 11 December 2017 at 20:40:09 UTC, vit wrote: This code doesn't compile with -dip1000: struct Foo{ int foo; ref int bar(){ return foo; } } Error: returning `this.foo` escapes a reference to parameter `this`, perhaps annotate with `return` How can be

return ref this -dip1000

2017-12-11 Thread vit via Digitalmars-d-learn
This code doesn't compile with -dip1000: struct Foo{ int foo; ref int bar(){ return foo; } } Error: returning `this.foo` escapes a reference to parameter `this`, perhaps annotate with `return` How can be annotated this parameter with 'return ref' ?

Re: Overloading float operators

2017-12-11 Thread ag0aep6g via Digitalmars-d-learn
On 12/11/2017 08:28 PM, rumbu wrote: Is there any way to overload specific floating point operators? https://dlang.org/spec/expression.html#floating-point-comparisons Those don't seem to work anymore. At least since 2.073, dmd rejects them and says to use std.math.isNaN instead. Looks like

Re: Tuple Array Sorting

2017-12-11 Thread Vino via Digitalmars-d-learn
On Monday, 11 December 2017 at 19:23:40 UTC, Seb wrote: On Monday, 11 December 2017 at 16:15:14 UTC, Vino wrote: On Monday, 11 December 2017 at 15:54:11 UTC, Biotronic wrote: [...] Hi Biotronic, I tried your code with multiple folder's , but no luck the output is not sorted. Program:

Overloading float operators

2017-12-11 Thread rumbu via Digitalmars-d-learn
Is there any way to overload specific floating point operators? https://dlang.org/spec/expression.html#floating-point-comparisons I'm using a decimal data type (a struct) and one of the possible values is NaN, that's why I need these operators. I know also that this also was discussed, but is

Re: Tuple Array Sorting

2017-12-11 Thread Seb via Digitalmars-d-learn
On Monday, 11 December 2017 at 16:15:14 UTC, Vino wrote: On Monday, 11 December 2017 at 15:54:11 UTC, Biotronic wrote: [...] Hi Biotronic, I tried your code with multiple folder's , but no luck the output is not sorted. Program: import std.algorithm: filter, map, sort; import

Re: Tuple Array Sorting

2017-12-11 Thread Vino via Digitalmars-d-learn
On Monday, 11 December 2017 at 15:54:11 UTC, Biotronic wrote: On Monday, 11 December 2017 at 15:33:08 UTC, Vino wrote: On Monday, 11 December 2017 at 15:15:47 UTC, Biotronic wrote: [...] Hi, I tired that but no luck, below is the output, in your code you have one folder "auto folders =

Re: Tuple Array Sorting

2017-12-11 Thread Biotronic via Digitalmars-d-learn
On Monday, 11 December 2017 at 15:33:08 UTC, Vino wrote: On Monday, 11 December 2017 at 15:15:47 UTC, Biotronic wrote: On Monday, 11 December 2017 at 14:52:35 UTC, Vino wrote: Example Program and Output import std.algorithm: filter, map, sort; import std.container.array; import std.file:

Re: Tuple Array Sorting

2017-12-11 Thread Biotronic via Digitalmars-d-learn
On Monday, 11 December 2017 at 15:33:08 UTC, Vino wrote: I tired that but no luck, below is the output, in your code you have one folder "auto folders = ["D:\\Dev"];" if you have multiple folder then output is not sorted. Works on my machine. Of course, since time toSimpleString returns

File.byLine for either Windows / Unix newlines

2017-12-11 Thread Dennis via Digitalmars-d-learn
I'm on Windows and I recently got confused by how Phobos functions handle newlines. ``` void main() { import std.stdio; import std.path : buildPath, tempDir; auto path = buildPath(tempDir(), "test.txt"); auto file = new File(path, "w"); file.write("hello there!\n");

Re: Tuple Array Sorting

2017-12-11 Thread Vino via Digitalmars-d-learn
On Monday, 11 December 2017 at 15:15:47 UTC, Biotronic wrote: On Monday, 11 December 2017 at 14:52:35 UTC, Vino wrote: Example Program and Output import std.algorithm: filter, map, sort; import std.container.array; import std.file: SpanMode, dirEntries, isDir ; import std.range: chain; import

Re: Tuple Array Sorting

2017-12-11 Thread Biotronic via Digitalmars-d-learn
On Monday, 11 December 2017 at 14:52:35 UTC, Vino wrote: Example Program and Output import std.algorithm: filter, map, sort; import std.container.array; import std.file: SpanMode, dirEntries, isDir ; import std.range: chain; import std.stdio: writefln; import std.typecons: Tuple, tuple; void

Re: Tuple Array Sorting

2017-12-11 Thread Vino via Digitalmars-d-learn
On Monday, 11 December 2017 at 14:25:16 UTC, Vino wrote: On Monday, 11 December 2017 at 13:58:49 UTC, Vino wrote: Hi All, Request your help in tuple array sorting, I have a function which returns tuple values as below so how do i sort this type of array based on the time stamp(Acceding

Re: Tuple Array Sorting

2017-12-11 Thread Vino via Digitalmars-d-learn
On Monday, 11 December 2017 at 13:58:49 UTC, Vino wrote: Hi All, Request your help in tuple array sorting, I have a function which returns tuple values as below so how do i sort this type of array based on the time stamp(Acceding order) . Eg: C:\Temp\EXPORT\dir2 2017-Sep-06 16:06:58

Re: Clarify "Starting as a Contributor" document

2017-12-11 Thread Dukc via Digitalmars-d-learn
On Sunday, 10 December 2017 at 08:18:17 UTC, Ali Çehreli wrote: This page is very good: https://wiki.dlang.org/Starting_as_a_Contributor I need clarifications Another oddity: Someone has apparently made DRuntime build to use ../dmd/generated/windows/32/dmd instead of the "system" dmd

Tuple Array Sorting

2017-12-11 Thread Vino via Digitalmars-d-learn
Hi All, Request your help in tuple array sorting, I have a function which returns tuple values as below so how do i sort this type of array based on the time stamp(Acceding order) . Eg: C:\Temp\EXPORT\dir2 2017-Sep-06 16:06:58 C:\Temp\BACKUP\dir2 2017-Sep-09 22:44:11 C:\Temp\TEAM\dir1

Re: libcurl acting differently to curl.exe

2017-12-11 Thread ikod via Digitalmars-d-learn
On Monday, 11 December 2017 at 03:53:25 UTC, Josh wrote: The POST C code was: /* Sample code generated by the curl command line tool ** * All curl_easy_setopt() options are documented at: * https://curl.haxx.se/libcurl/c/curl_easy_setopt.html Maybe off-topic but you can

Re: check mountpoint status and send email on timeout/failure?

2017-12-11 Thread Nicholas Wilson via Digitalmars-d-learn
On Monday, 11 December 2017 at 10:50:17 UTC, biocyberman wrote: For someone using NFS or some other remote filesystems, one may have experienced many times the nasty silent hang. For example, if I run `ls /mnt/remote/nfsmount`, and the remote NFS server is down while /mnt/remote/nfsmount was

Re: Seed Value for reduce function

2017-12-11 Thread Vino via Digitalmars-d-learn
On Sunday, 10 December 2017 at 06:01:49 UTC, Ali Çehreli wrote: On 12/09/2017 06:19 PM, Vino wrote: [...] When no seed value is specified, fold (and reduce) take the first element as the seed. When the range is empty, then there is a run-time failure:

check mountpoint status and send email on timeout/failure?

2017-12-11 Thread biocyberman via Digitalmars-d-learn
For someone using NFS or some other remote filesystems, one may have experienced many times the nasty silent hang. For example, if I run `ls /mnt/remote/nfsmount`, and the remote NFS server is down while /mnt/remote/nfsmount was mounted, it will take very long time or forever for the `ls`