Re: betterC and noboundscheck

2017-11-24 Thread Michael V. Franklin via Digitalmars-d-learn
On Wednesday, 22 November 2017 at 15:10:40 UTC, Oleg B wrote: import core.stdc.stdio; import std.algorithm : min; extern (C) void main() { char[256] buf; buf[] = '\0'; auto str = "hello world"; auto ln = min(buf.length, str.length); buf[0..ln] = str[0..ln]; printf("%s\n

Re: behaviour of spawnProcess

2017-11-24 Thread Vladimir Panteleev via Digitalmars-d-learn
On Saturday, 25 November 2017 at 02:32:17 UTC, Fra Mecca wrote: I have noticed that whenever j contains a string with a space in it, spawnprocess splits the string into another argument. That shouldn't happen. If you are on Windows, note that processes do not see the command line as an array

behaviour of spawnProcess

2017-11-24 Thread Fra Mecca via Digitalmars-d-learn
I have this snipper of code: auto pid = spawnProcess([exe, j], po.readEnd, pi.writeEnd, std.stdio.stderr); where exe is the executable name and j is argv[1]. I have noticed that whenever j contains a string with a space in it, spawnprocess splits the string into another argument. In this w

Re: Floating point types default to NaN?

2017-11-24 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, November 24, 2017 20:43:14 A Guy With a Question via Digitalmars- d-learn wrote: > On Friday, 24 November 2017 at 14:43:24 UTC, Adam D. Ruppe wrote: > > On Friday, 24 November 2017 at 14:30:44 UTC, A Guy With a > > > > Question wrote: > >> I would have expected 0 to be the default value.

Re: Floating point types default to NaN?

2017-11-24 Thread A Guy With a Question via Digitalmars-d-learn
On Friday, 24 November 2017 at 14:43:24 UTC, Adam D. Ruppe wrote: On Friday, 24 November 2017 at 14:30:44 UTC, A Guy With a Question wrote: I would have expected 0 to be the default value. What's the logic behind having them being NaN by default? It gives you a runtime error (sort of) if you

Re: Error: 'this' is only defined in non-static member functions

2017-11-24 Thread Steven Schveighoffer via Digitalmars-d-learn
On 11/22/17 7:35 PM, Jonathan M Davis wrote: On Thursday, November 23, 2017 00:17:46 A Guy With a Question via Digitalmars-d-learn wrote: here as non-static, nested class is associated with a specific instance of the class and has access to that class instance via its outer member. - Jonathan M

Re: Passing this to void *

2017-11-24 Thread Steven Schveighoffer via Digitalmars-d-learn
On 11/23/17 12:57 AM, Nicholas Wilson wrote: On Wednesday, 22 November 2017 at 15:07:08 UTC, Tim Hsu wrote: I am a C++ game developer and I want to give it a try. It seems "this" in Dlang is a reference instead of pointer. How can I pass it as void *? void foo(void *); class Pizza { public:

Re: GUI program on Mac OS in D?

2017-11-24 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-11-24 16:09, Adam D. Ruppe wrote: Thanks, this gets me started. Do you happen to know if there is anything like "pragma(lib)" for the -framework argument? (I don't use dub, so I took your config there to make my own command line, but it would be nice if I didn't have to specify the f

Re: GUI program on Mac OS in D?

2017-11-24 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 23 November 2017 at 17:28:43 UTC, Jacob Carlborg wrote: I have a simple example [2] of an application that shows a window with a WebKit view, i.e. and embedded browser. Thanks, this gets me started. Do you happen to know if there is anything like "pragma(lib)" for the -framework

Re: Floating point types default to NaN?

2017-11-24 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 24 November 2017 at 14:30:44 UTC, A Guy With a Question wrote: I would have expected 0 to be the default value. What's the logic behind having them being NaN by default? It gives you a runtime error (sort of) if you use an uninitialized variable. You ARE supposed to explicitly in

Floating point types default to NaN?

2017-11-24 Thread A Guy With a Question via Digitalmars-d-learn
I would have expected 0 to be the default value. What's the logic behind having them being NaN by default? https://dlang.org/spec/type.html

Re: dirEntries() and exceptions

2017-11-24 Thread rjframe via Digitalmars-d-learn
On Fri, 24 Nov 2017 12:02:47 +, doc wrote: > I'm trying recursively find files, and have some trouble to catch > exceptions if have no permission to read directory. > ... > > std.file.FileException@std/file.d(3798): > /tmp/systemd-private-8338348a306b4d589e3f6ba2bfd0c8fe-systemd- timesyncd.s

Re: Concurrency send immutable

2017-11-24 Thread SrMordred via Digitalmars-d-learn
Nice, thank you!

Re: Concurrency send immutable

2017-11-24 Thread drug via Digitalmars-d-learn
24.11.2017 15:53, SrMordred пишет: On Friday, 24 November 2017 at 12:36:42 UTC, Daniel Kozak wrote: Should print something like this: std.concurrency.OwnerTerminated@std/concurrency.d(223): Owner terminated Yes, it was, I was aware of this and put some sleep after that too. (immutable (int)[

Re: Concurrency send immutable

2017-11-24 Thread SrMordred via Digitalmars-d-learn
On Friday, 24 November 2017 at 12:36:42 UTC, Daniel Kozak wrote: Should print something like this: std.concurrency.OwnerTerminated@std/concurrency.d(223): Owner terminated Yes, it was, I was aware of this and put some sleep after that too. (immutable (int)[] v) OK that parenteshis was th

Re: Concurrency send immutable

2017-11-24 Thread Daniel Kozak via Digitalmars-d-learn
import std.stdio; import std.traits; int main(string[] args) { immutable int[] arr = [1,2,3,4,5]; writeln(ImplicitConversionTargets!(typeof(arr)).stringof); return 0; } On Fri, Nov 24, 2017 at 1:36 PM, Daniel Kozak wrote: > Should print something like this: > std.concurrency.OwnerTerminated@std

Re: Concurrency send immutable

2017-11-24 Thread Daniel Kozak via Digitalmars-d-learn
Should print something like this: std.concurrency.OwnerTerminated@std/concurrency.d(223): Owner terminated Because main thread is terminated, because types do not match this will work import std.stdio; import std.concurrency; void fun() { receive( (immutable (int)[] v) => writeln(v) ); } int ma

Re: Concurrency send immutable

2017-11-24 Thread SrMordred via Digitalmars-d-learn
On Friday, 24 November 2017 at 12:05:16 UTC, SrMordred wrote: immutable int[] arr = [1,2,3,4,5]; auto t = spawn({ receive( (immutable int[] v) => writeln(v) );}); t.send(arr); whats the problem here? Nothing prints out

Concurrency send immutable

2017-11-24 Thread SrMordred via Digitalmars-d-learn
immutable int[] arr = [1,2,3,4,5]; auto t = spawn({ receive( (immutable int[] v) => writeln(v) );}); t.send(arr); whats the problem here?

dirEntries() and exceptions

2017-11-24 Thread doc via Digitalmars-d-learn
I'm trying recursively find files, and have some trouble to catch exceptions if have no permission to read directory. [code] void main() { import std.file,std.stdio; auto farray = dirEntries("/tmp", "*.{d,py,pl,sh}", SpanMode.breadth); foreach (f; farray){writeln(f);}} [/code] std.file.FileEx

Re: Range violation

2017-11-24 Thread Mike Parker via Digitalmars-d-learn
On Friday, 24 November 2017 at 09:59:13 UTC, Vino wrote: if (args.length < 1 || args.length > 2) { writeln(args[0].baseName, ":No Arguments Provided"); exit(-1); } When you pass no arguments, this won't execute as args.length will still be 1, the only argument

Re: Range violation

2017-11-24 Thread Timoses via Digitalmars-d-learn
On Friday, 24 November 2017 at 09:59:13 UTC, Vino wrote: if (args.length < 1 || args.length > 2) { If args.length is 1 it will call string op = args[1]; However, args[1] accesses the second element. Due to above if statement args[1] can be called even though only args[0] exists.

Range violation

2017-11-24 Thread Vino via Digitalmars-d-learn
Hi All, Request your help on the below program, when I execute the program without passing any arguments it is throwing Range violation errors Error: core.exception.RangeError@test.d(21): Range violation 0x004068CC 0x00408CF3 0x00408CB7 0x00408BB8 0x0040558F 0x74FE336A in