Re: std/process.d: nothrow functions which throw (in struct ProcessPipes)

2020-07-21 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/21/20 8:49 AM, Adam D. Ruppe wrote: On Tuesday, 21 July 2020 at 12:44:23 UTC, Drone1h wrote: Would it be possible to explain this, please ? nothrow only applies to Exception and its children. Error is a different branch. Error means you have a programming error and cannot be caught

Re: std/process.d: nothrow functions which throw (in struct ProcessPipes)

2020-07-21 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/21/20 8:44 AM, Drone1h wrote: Hello All, In phobos/std/process.d, in the ProcessPipes struct, we can see a few functions which are marked with "nothrow", but which (under some conditions) throw:     @property File stdout() @safe nothrow     {     if ((_redirectFlags &

Re: miscellaneous array questions...

2020-07-21 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/21/20 7:10 AM, IGotD- wrote: On Monday, 20 July 2020 at 22:05:35 UTC, WhatMeWorry wrote: 2) "The total size of a static array cannot exceed 16Mb" What limits this? And with modern systems of 16GB and 32GB, isn't 16Mb excessively small?   (an aside: shouldn't that be 16MB in the

Re: Accurately serializing and deserializing a SysTime in binary format

2020-07-21 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/21/20 7:44 AM, Ecstatic Coder wrote: On Tuesday, 21 July 2020 at 11:01:20 UTC, drug wrote: On 7/20/20 10:04 PM, Ecstatic Coder wrote: I'm currently implementing a small open source backup tool (dub), and therefore I need to accurately store the file modification SysTime in binary format,

Re: std.process - avoid interaction with parent shell

2020-07-21 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/20/20 6:04 PM, Vladimir Panteleev wrote: On Monday, 20 July 2020 at 20:55:52 UTC, Steven Schveighoffer wrote: I tried redirecting /dev/null to stdin when executing my application (and I assumed that would pass onto the process child), but it still asks. What am I doing wrong?

Re: std.process - avoid interaction with parent shell

2020-07-20 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/20/20 5:24 PM, H. S. Teoh wrote: On Mon, Jul 20, 2020 at 04:55:52PM -0400, Steven Schveighoffer via Digitalmars-d-learn wrote: I am doing some scripting via D, and using std.process.execute to git clone things. I don't want any user interaction. Occasionally, I get a repository

std.process - avoid interaction with parent shell

2020-07-20 Thread Steven Schveighoffer via Digitalmars-d-learn
I am doing some scripting via D, and using std.process.execute to git clone things. I don't want any user interaction. Occasionally, I get a repository that no longer exists (404). Then git comes up and asks for a username/password. I want it to just fail. Apparently git has no option to be

Re: alias restriction??!

2020-07-19 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/19/20 4:21 PM, Carl Sturtivant wrote: On Sunday, 19 July 2020 at 17:06:14 UTC, Paul Backus wrote: Also, letting aliases refer to expressions essentially allows AST macros in through the back door. Consider the following example: [...] Perhaps what's needed is something more that is

Re: vibe.d and my first web service

2020-07-18 Thread Steven Schveighoffer via Digitalmars-d-learn
On Saturday, 18 July 2020 at 09:10:04 UTC, Mr. Backup wrote: by ctrl + c and start again the program cannot start again with error message: Failed to listen on ::1:8080 Failed to listen on 127.0.0.1:8080 Failed to listen for incoming HTTP connections on any of the supplied interfaces.

Re: getopt: How does arraySep work?

2020-07-16 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/16/20 1:13 PM, Andre Pany wrote: On Thursday, 16 July 2020 at 05:03:36 UTC, Jon Degenhardt wrote: On Wednesday, 15 July 2020 at 07:12:35 UTC, Andre Pany wrote: [...] An enhancement is likely to hit some corner-cases involving list termination requiring choices that are not fully

Re: getopt: How does arraySep work?

2020-07-14 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/14/20 10:22 AM, Steven Schveighoffer wrote: The documentation needs updating, it should say "parameters are added sequentially" or something like that, instead of "separation by whitespace". https://github.com/dlang/phobos/pull/7557 -Steve

Re: getopt: How does arraySep work?

2020-07-14 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/14/20 10:05 AM, Steven Schveighoffer wrote: Hm... that looks like it IS actually expecting to do what Andre wants. It's adding each successive parameter. If that doesn't work, then there's something wrong with the logic that decides whether a parameter is part of the previous argument

Re: getopt: How does arraySep work?

2020-07-14 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/14/20 9:51 AM, Anonymouse wrote: On Tuesday, 14 July 2020 at 11:12:06 UTC, Andre Pany wrote: [...] Steven Schveighoffer already answered while I was composing this, so discarding top half. As far as I can tell the default arraySep of "" splitting the argument by whitespace is simply

Re: getopt: How does arraySep work?

2020-07-14 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/14/20 7:12 AM, Andre Pany wrote: Hi, by reading the documentation of std.getopt I would assume, this is a valid call dmd -run sample.d --modelicalibs a b ``` d import std; void main(string[] args) {     string[] modelicaLibs;     getopt(args, "modelicalibs", );    

Re: how to assign to shared obj.systime?

2020-07-13 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/13/20 3:26 AM, Arafel wrote: On 13/7/20 3:46, Steven Schveighoffer wrote: On 7/11/20 6:15 AM, Arafel wrote: What I really miss is some way of telling the compiler "OK, I know what I'm doing, I'm already in a critical section, and that all the synchronization issues have been already

Re: how to assign to shared obj.systime?

2020-07-12 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/11/20 1:03 AM, Kagamin wrote: Steven's solution isn't good in the general case Right, you need to know that SysTime is actually a value type, and so it can be implicitly copied without problems with aliasing. In fact, the cast isn't needed to ensure there is no lingering aliasing. I

Re: how to assign to shared obj.systime?

2020-07-12 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/11/20 6:15 AM, Arafel wrote: Because the system don't know if just this lock is enough to protect this specific access. When you have multiple locks protecting multiple data, things can become messy. Yes. What I really miss is some way of telling the compiler "OK, I know what I'm

Re: So how do I find and remove an element from DList?

2020-07-10 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/10/20 3:08 PM, Ogi wrote: auto list = DList!int([1, 2, 3, 4]); list.remove(list[].find(2).take(1)); Error: function std.container.dlist.DList!int.DList.remove(Range r) is not callable using argument types (Take!(Range)) It works if I replace `remove` with `linearRemove`, but that

Re: how to assign to shared obj.systime?

2020-07-10 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/10/20 2:30 PM, mw wrote: On Friday, 10 July 2020 at 17:35:56 UTC, Steven Schveighoffer wrote: Mark your setTime as shared, then cast away shared (as you don't need atomics once it's locked), and assign: synchronized setTime(ref SysTime t) shared {     (cast()this).time = t; } I know I

Re: how to assign to shared obj.systime?

2020-07-10 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/10/20 1:18 PM, mw wrote: On Friday, 10 July 2020 at 08:48:38 UTC, Kagamin wrote: On Friday, 10 July 2020 at 05:12:06 UTC, mw wrote: looks like we still have to cast: as of 2020, sigh. Why not? Because cast is ugly. I've also tried this: ``` class A {     SysTime time;    

Re: Send empty assoc array to function

2020-07-10 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/10/20 4:15 AM, Max Samukha wrote: On Thursday, 9 July 2020 at 21:04:57 UTC, Steven Schveighoffer wrote: Why isn't [] accepted as an empty AA literal? Because it's an empty dynamic array literal. If D were to accept an empty AA literal, I'd expect it to be [:]. Just as typeof(null)

Re: Unexpected copy constructor behavior

2020-07-10 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/10/20 3:31 AM, psycha0s wrote: On Thursday, 9 July 2020 at 22:18:59 UTC, Steven Schveighoffer wrote: Looking at the generated AST, it's because the compiler is adding an auto-generated opAssign, which accepts a Foo by value. It is that object that is being created and destroyed. Is

Re: Unexpected copy constructor behavior

2020-07-09 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/9/20 6:08 PM, psycha0s wrote: import std.stdio; struct Foo { int value; this(int n) {     value = n;     writeln("constuctor ", ); } ~this() {     writeln("destuctor ", ); } this(ref return scope Foo other) {     value =

Re: Send empty assoc array to function

2020-07-09 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/9/20 5:13 PM, JN wrote: On Thursday, 9 July 2020 at 20:24:11 UTC, Steven Schveighoffer wrote: On 7/9/20 4:04 PM, JN wrote: Hmm, foo(null) seems to work, but is it correct way to do it? Yes, that is correct. Interesting. Often in D discussion, an argument pops up that the language

Re: Send empty assoc array to function

2020-07-09 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/9/20 4:31 PM, Max Samukha wrote: On Thursday, 9 July 2020 at 20:24:11 UTC, Steven Schveighoffer wrote: Yes, that is correct. Why isn't [] accepted as an empty AA literal? Because it's an empty dynamic array literal. If D were to accept an empty AA literal, I'd expect it to be [:].

Re: Send empty assoc array to function

2020-07-09 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/9/20 4:04 PM, JN wrote: On Thursday, 9 July 2020 at 19:53:42 UTC, JN wrote: void foo(int[int] bar) {     // ... } Is it possible to send an empty array literal? foo( [ 0 : 2 ] ) works foo( [] ) doesn't int[int] empty; foo(empty); works but it's two lines Hmm, foo(null) seems to

Re: constructing labels for static foreach inside switch inside foreach

2020-07-08 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/8/20 9:38 AM, ag0aep6g wrote: On 08.07.20 14:24, Steven Schveighoffer wrote: I solved it for now by extrapolating the inner code into a local template function. But this is definitely an awkward situation for static foreach. FWIW, you can write the extra function like this:     static

Re: constructing labels for static foreach inside switch inside foreach

2020-07-08 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/8/20 6:13 AM, Stanislav Blinov wrote: On Wednesday, 8 July 2020 at 02:06:01 UTC, Steven Schveighoffer wrote: Seems simple enough, except that this inner portion is unrolled, and if I have more than one type to run this on, I already have an "innerloop" label defined. Is there a way to

Re: constructing labels for static foreach inside switch inside foreach

2020-07-08 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/8/20 5:10 AM, cc wrote: I think I ran into similar problems due to the requirement to use a labeled break inside static foreach.  I got around it by defining enums when my target was found and checking if it existed via __traits(compiles) to "ignore" the rest of the loop. Thanks for

constructing labels for static foreach inside switch inside foreach

2020-07-07 Thread Steven Schveighoffer via Digitalmars-d-learn
OK, so I have a situation where I'm foreaching over a compile-time list of types. Inside the loop, I'm using a second loop over a set of input. Inside that loop, I'm using a switch on the input, and inside the switch, I'm foreaching over the type's members, to construct a switch that can

Re: Template function specialization doesn't work

2020-07-07 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/7/20 4:21 PM, IGotD- wrote: On Tuesday, 7 July 2020 at 20:14:19 UTC, IGotD- wrote: Thank you, that worked and now it picked the correct overloaded function. I don't understand why and it is a bit counter intuitive. Why two template arguments as I'm not even us using U? If you look at

Re: Template function specialization doesn't work

2020-07-07 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/7/20 4:04 PM, Steven Schveighoffer wrote: Have you tried (T: U[], U)(ref T[] s) ? Ugh... (T: U[], U)(ref T s) -Steve

Re: Template function specialization doesn't work

2020-07-07 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/7/20 3:53 PM, IGotD- wrote: I have two template functions void overloadedFunction(T)(ref T val) { } void overloadedFunction(T : T[])(ref T[] s) { } Obviously the second should be used when the parameter is a slice of any type, and the first should be used in other cases.

Re: BetterC Bug? Intended Behavior? Asking Here As Unsure

2020-07-07 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/7/20 8:26 AM, Steven Schveighoffer wrote: On 7/6/20 5:09 PM, kinke wrote: On Monday, 6 July 2020 at 20:25:11 UTC, Kayomn wrote: Though, admittedly I'm kind of used to seeing this error message since it appears any time you try and do something that relies on type info in betterC,

Re: BetterC Bug? Intended Behavior? Asking Here As Unsure

2020-07-07 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/6/20 5:09 PM, kinke wrote: On Monday, 6 July 2020 at 20:25:11 UTC, Kayomn wrote: Though, admittedly I'm kind of used to seeing this error message since it appears any time you try and do something that relies on type info in betterC, intentionally or not. A notable example is forgetting

Re: Associative array on the heap

2020-07-07 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/7/20 3:08 AM, mw wrote: On Tuesday, 19 May 2015 at 12:21:48 UTC, Steven Schveighoffer wrote: On 5/18/15 7:55 PM, Freddy wrote: How do you allocate an associative array on the heap? void main(){ alias A=int[string]; auto b=new A; } $ rdmd test test.d(4): Error: new can

Re: dub build=ddox, where the are the docs?

2020-07-07 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/6/20 5:04 PM, claptrap wrote: Ok yeah it starts up a server and opens a webpage, great, but where are the docs? Cant find any info on command line switches for dub or ddox on how to get it to just dump the docs in a folder. dub --build=ddox makes a server and runs it so you can serve

Re: Why is this allowed

2020-07-01 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/1/20 11:57 AM, Nathan S. wrote: On Tuesday, 30 June 2020 at 16:22:57 UTC, JN wrote: Spent some time debugging because I didn't notice it at first, essentially something like this: int[3] foo = [1, 2, 3]; foo = 5; writeln(foo);   // 5, 5, 5 Why does such code compile? I don't think this

Re: idiomatic output given -preview=nosharedaccess ,

2020-06-30 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/30/20 3:56 PM, Bruce Carneal wrote: Given -preview=nosharedaccess on the command line, "hello world" fails to compile (you are referred to core.atomic ...). What is the idiomatic way to get writeln style output from a nosharedaccess program? Is separate compilation the way to go?

Re: Why is this allowed

2020-06-30 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/30/20 2:22 PM, H. S. Teoh wrote: On Tue, Jun 30, 2020 at 02:06:13PM -0400, Steven Schveighoffer via Digitalmars-d-learn wrote: On 6/30/20 12:37 PM, Steven Schveighoffer wrote: [...] I take it back, I didn't realize this wasn't something that happened with dynamic arrays: int[] dyn = [1

Re: Why is this allowed

2020-06-30 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/30/20 12:37 PM, Steven Schveighoffer wrote: On 6/30/20 12:22 PM, JN wrote: Spent some time debugging because I didn't notice it at first, essentially something like this: int[3] foo = [1, 2, 3]; foo = 5; writeln(foo);   // 5, 5, 5 Why does such code compile? I don't think this should be

Re: Why is this allowed

2020-06-30 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/30/20 12:22 PM, JN wrote: Spent some time debugging because I didn't notice it at first, essentially something like this: int[3] foo = [1, 2, 3]; foo = 5; writeln(foo);   // 5, 5, 5 Why does such code compile? I don't think this should be permitted, because it's easy to make a mistake

Re: How to implement Canceleable spawn() from parent

2020-06-30 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/30/20 10:15 AM, Simen Kjærås wrote: On Tuesday, 30 June 2020 at 13:44:38 UTC, aberba wrote: On Tuesday, 30 June 2020 at 12:48:32 UTC, Simen Kjærås wrote: On Tuesday, 30 June 2020 at 08:15:54 UTC, aberba wrote: On Tuesday, 30 June 2020 at 00:33:41 UTC, Ali Çehreli wrote: On 6/29/20 4:34

Re: How to implement Canceleable spawn() from parent

2020-06-30 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/30/20 9:44 AM, aberba wrote: On Tuesday, 30 June 2020 at 12:48:32 UTC, Simen Kjærås wrote: So I guess the error is elsewhere, but I'm not sure where and how. Yeah, you're right. I changed receiveTimeout() to receive() to try something and forgot to change it back. Jeez, I hate

Re: Calling C functions

2020-06-30 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/30/20 3:00 AM, Kagamin wrote: On Monday, 29 June 2020 at 19:55:59 UTC, Steven Schveighoffer wrote: Yep, for sure. I'll file an issue. Anyone know why the calling convention would differ? It's easier to enforce left to right evaluation order this way: arguments are pushed to stack as

Re: scope guard question

2020-06-30 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/30/20 2:56 AM, Arjan wrote: On Monday, 29 June 2020 at 22:47:16 UTC, Steven Schveighoffer wrote: Yes. The return statement is inside the scope of the function, so it runs before the scope is exited. Are you saying the spec doesn't say that? Thanks for the assurance. The spec does state

Re: scope guard question

2020-06-29 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/29/20 6:31 PM, Arjan wrote: ``` void main() {   import std.stdio;   auto f = (){     string[] t;     { // inner scope   t ~= "hello";   scope( exit ) t ~= "world";     } // inner scope exit     return t;   };   f().writeln; // ["hello", "world"] } ``` removing the inner

Re: Calling C functions

2020-06-29 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/29/20 1:50 PM, Jacob Carlborg wrote: On Monday, 29 June 2020 at 16:34:33 UTC, Steven Schveighoffer wrote: Are you sure? On the ABI page [1] , it says "The extern (C) and extern (D) calling convention matches the C calling convention used by the supported C compiler on the host system."

Re: Calling C functions

2020-06-29 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/26/20 4:15 AM, Jacob Carlborg wrote: On Friday, 26 June 2020 at 00:30:22 UTC, Denis wrote: I have a two questions about calling C functions from D. (1) When passing a D callback to a C function, is there a way to write the code without having to prefix the callback declaration with

Re: Waiting on file descriptor/socket *AND* thread messages

2020-06-29 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/29/20 5:14 AM, ichneumwn wrote: Dear all, Is there some facility in D for a single statement/function call that will wait on both file descriptors, like Socket.select(), and will also wake up when there is something to be receive()'d? Not in the standard library. Such things require an

Re: figure out where a particular template function is located

2020-06-24 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/24/20 5:40 PM, kinke wrote: On Wednesday, 24 June 2020 at 21:05:12 UTC, Steven Schveighoffer wrote: I have a hard time believing that there's no way to do this! This would IMO be the job of the IDE. E.g., Visual D might be able to jump to the template declaration. Something useful

Re: figure out where a particular template function is located

2020-06-24 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/24/20 4:38 PM, Adam D. Ruppe wrote: On Wednesday, 24 June 2020 at 20:28:24 UTC, Steven Schveighoffer wrote: Is there a way to figure this out from the call? The .mangleof the instance might help track it down since it should give you the module name as part of that mangle. Then go in

figure out where a particular template function is located

2020-06-24 Thread Steven Schveighoffer via Digitalmars-d-learn
I have code that instantiates a template: templ!int("abc"); When I read the source of where I *think* this template should be, I can't find one that would match (I think). I feel like it's being imported elsewhere. How do I figure out what module (at least) this instantiated template is

Re: called copy constructor in foreach with ref on Range

2020-06-23 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/23/20 9:47 AM, Sebastiaan Koppe wrote: On Tuesday, 23 June 2020 at 07:30:29 UTC, Stanislav Blinov wrote: On Tuesday, 23 June 2020 at 05:24:37 UTC, H. S. Teoh wrote: I'm also wondering what's the motivation behind supporting non-copyable ranges, and whether it's worth the effort and

Re: opOpAssign of AA: defined behavior?

2020-06-23 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/23/20 5:15 AM, WebFreak001 wrote: I have the following code:     double[string] foo;     foo["a"] += 1; how is the opOpAssign on the AA defined? Is it defined to set the value to the value to the right of the opOpAssign if it isn't set for primitives or does it add the given value

Re: how to skip the next (n) item & continue from (n+1) with a range ? e.g. in File(fn).byLine();

2020-06-22 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/22/20 4:49 PM, mw wrote: On Monday, 22 June 2020 at 20:46:30 UTC, mw wrote: On Monday, 22 June 2020 at 20:00:50 UTC, Steven Schveighoffer wrote: I wouldn't recommend it, instead do a while loop: auto range = File(fn).byLine; while(!range.empty) {    auto line = range.front;   

Re: how to skip the next (n) item & continue from (n+1) with a range ? e.g. in File(fn).byLine();

2020-06-22 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/22/20 3:53 PM, mw wrote: Hi, I need this logic: ``` auto range = File(fn).byLine(); foreach (line; range) {   if (comeCond(line)) { // skip the next n line // and continue the foreach loop from the (n+1) line   } else { regularProcess(line);   } } ``` Is it possible

Re: When is exception throwing @nogc with -dip1008?

2020-06-22 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/22/20 10:36 AM, Per Nordlöw wrote: On Monday, 22 June 2020 at 14:10:15 UTC, Mike Parker wrote: https://github.com/dlang/DIPs/blob/master/DIPs/other/DIP1008.md The spec says: " The only place a refcounted Throwable is ever created is when the following statement is in the user code:

Re: Read to stdout doesn't trigger correct action

2020-06-22 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/22/20 10:05 AM, IGotD- wrote: This seems do some atomic operation preventing the D File class for stdio not to be initialized several times. I'm not quite sure if this is global or per thread but I guess it is for the entire process. For some reason the std File classes are never

Re: Passing a variable number of slices into a function

2020-06-22 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/21/20 10:04 PM, user1234 wrote: On Monday, 22 June 2020 at 01:47:49 UTC, repr-man wrote: Is there any way to pass an unknown number of slices into a function? I'm trying to do something along the lines of: void func(T)(T[] args...) {     //... } That wasn't working, [...] Thanks for

Re: Should the compiler be failing to infer template args here?

2020-06-19 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/19/20 12:38 PM, SealabJaster wrote: On Friday, 19 June 2020 at 16:31:50 UTC, Paul Backus wrote: This is a known issue: https://issues.dlang.org/show_bug.cgi?id=1807 "Reported: 2008"... yikes. Thanks anyway, glad to know I wasn't just going mad :) It's somewhat difficult to solve,

Re: Why is there no std.stream anymore?

2020-06-19 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/18/20 11:11 PM, Jesse Phillips wrote: On Thursday, 18 June 2020 at 14:53:58 UTC, aberba wrote: On Tuesday, 12 December 2017 at 20:51:30 UTC, Steven Schveighoffer wrote: On 12/11/17 6:33 PM, Seb wrote: [...] Since iopipe was mentioned several times, I will say a couple things: [...]

Re: Why is there no std.stream anymore?

2020-06-18 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/18/20 10:53 AM, aberba wrote: On Tuesday, 12 December 2017 at 20:51:30 UTC, Steven Schveighoffer wrote: On 12/11/17 6:33 PM, Seb wrote: [...] Since iopipe was mentioned several times, I will say a couple things: [...] I should really try iopipe this time round. I think I avoided

DIP1000 spec?

2020-06-12 Thread Steven Schveighoffer via Digitalmars-d-learn
I was just looking through the DIPs in the system, and noticed that DIP1000 is "superseded". I thought that was odd, since it's in the compiler as a switch and is a major driver of discussion and hope for memory safety. In the DIP it says [1]: "This DIP did not complete the review process.

Re: Why is there no range iteration with index by the language?

2020-06-10 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/9/20 7:53 PM, Q. Schroll wrote: Is there any particular reason why std.range : enumerate is a thing and     foreach (i, e; range) { ... } doesn't work from the get-go? I wouldn't have such an issue with it if static foreach would work with enumerate just fine. What is the use case for

Re: Error: llroundl cannot be interpreted at compile time, because it has no available source code

2020-06-08 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/8/20 2:53 PM, mw wrote: And with a symbol-to-c-func table, it should be able to just call that C func. Consider that the libc available to the compiler might not be the same as the libc for the target (e.g. cross compilation). Not just that, but this opens the compiler up to a huge

Re: Error: llroundl cannot be interpreted at compile time, because it has no available source code

2020-06-08 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/8/20 2:08 PM, mw wrote: Hi, I'm trying to build this package: https://code.dlang.org/packages/fixed however, the compiler error out: ldc2-1.21.0-linux-x86_64/bin/../import/std/math.d(5783,39): Error: llroundl cannot be interpreted at compile time, because it has no available source

Re: Mixin and imports

2020-06-08 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/8/20 11:11 AM, jmh530 wrote: On Monday, 8 June 2020 at 14:27:26 UTC, data pulverizer wrote: [snip] Out of curiosity what does the "." in front of `foo` mean? I've seen that in some D code on the compiler in GitHub and have no idea what it does. I tried Googling it to no avail. It

Re: Arrays and non-copyable elements

2020-06-07 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/7/20 10:07 PM, Stanislav Blinov wrote: On Monday, 8 June 2020 at 00:31:10 UTC, Steven Schveighoffer wrote: This is a bug, please file. What is likely happening is that the template is not moving the data to the underlying C call. That is not a bug, it's a shortcoming of

Re: Arrays and non-copyable elements

2020-06-07 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/7/20 7:25 PM, Jack Applegame wrote: I think it should compile. ``` struct NonCopyable {     int a;     this(this) @disable; } void main() {     NonCopyable[] arr = [NonCopyable(1), NonCopyable(2)]; // ok     arr ~= NonCopyable(3); // fails } ``` This is a bug, please file. What is

Re: What is the equivalent of -version=Flag for conditional compilation in the ldc2 compiler?

2020-06-05 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/5/20 6:36 PM, data pulverizer wrote: Hi, I was switching from dmd to ldc2 and would like to know the equivalent command line for conditional compilation -version=Flag I was using in dmd. I checked the ldc2 --help but didn't see anything relevant. Version there refers to compiler version

Re: App hangs, GC.collect() fixet it. Why?

2020-06-05 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/5/20 1:57 PM, Bastiaan Veelo wrote: I've been tracking down a hang in our pilot app. Using writeln, it appears to hang at newing a slice. After many hours of trying things, I discovered that program flow would continue past that point when I inserted a call to `GC.collect()` just before.

Re: writeln Function while reading a Text File is printing appending text "before text" and "after text" at the same position

2020-06-03 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/3/20 2:23 PM, BoQsc wrote: C:\Users\vaida\Desktop\Associative Array Sorting> rdmd testingGround.d 0.  The quick brown fox jumps over the lazy dog nonononoahahahaha Sphinx of black quartz, judge my vow. 2. # How vexingly quick daft zebras jump! 3. # The five boxing wizards jump quickly 4. #

Re: How to efficiently resolve Associative Arrays not being sorted?

2020-06-02 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/2/20 3:32 AM, BoQsc wrote: I want to read a file, put it into an array, make some search and replace on the content and output the modified text. However Associative Arrays seem to be unsorted by default. Should I drop the Associative Arrays and use something else? What are the ways to

Re: Making alias of a struct field needs "this".

2020-06-02 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/2/20 10:51 AM, realhet wrote: On Tuesday, 2 June 2020 at 13:10:55 UTC, Paul Backus wrote: On Tuesday, 2 June 2020 at 09:28:01 UTC, realhet wrote:     mixin("@property auto ", k, "() const { return ", v, "; }"); Wow, string mixin can process comma separated list, I gotta remember this,

Re: Garbage Collection Issue

2020-06-01 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/1/20 6:51 AM, IGotD- wrote: On Sunday, 31 May 2020 at 16:57:06 UTC, Steven Schveighoffer wrote: I can't imagine much of druntime working at all without TLS. Indeed, it is a requirement these days. I believe that's where these roots are being stored. I would really like if druntime

Re: Garbage Collection Issue

2020-06-01 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/1/20 5:53 AM, a11e99z wrote: On Sunday, 31 May 2020 at 16:57:06 UTC, Steven Schveighoffer wrote: I can't imagine much of druntime working at all without TLS. Indeed, it is a requirement these days. TLS is evil for async/await when any thread can execute any fiber (case where fiber

Re: Garbage Collection Issue

2020-05-31 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/30/20 9:51 PM, Marius Cristian Baciu wrote: I am encountering a strange problem with the GC on a specific platform: at the first attempt to clear the current memory pool to make room for a new allocation, the GC considers that the page in which the main thread resides (the one created in

Re: DMD 2.092 and DIP 25

2020-05-30 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/30/20 3:00 AM, Mike Parker wrote: The following declarations now give a deprecation warning: ```d struct ErrorInfo { private:     char[32] _error;     char[96] _message; public @nogc nothrow @property:     /**     Returns the string "Missing Symbol" to indicate a symbol load

Re: Determining @trusted-status

2020-05-29 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/28/20 8:09 PM, Clarice wrote: It seems that @safe will be de jure, whether by the current state of DIP1028 or otherwise. However, I'm unsure how to responsibly determine whether a FFI may be @trusted: the type signature and the body. Should I run, for example, a C library through valgrind

Re: A custom name for variables

2020-05-28 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/28/20 4:26 PM, Quantium wrote: I need to create a variable with custom name, like this import std; void main() {     string name;     readf(" %s", );     // some code that generates a variable of type integer and value 0 int value = 0; } Could you help me with that? If you are

Re: Distinguish between a null array and an empty array

2020-05-26 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/24/20 8:12 AM, bauss wrote: Is there a way to do that? Since the following are both true: int[] a = null; int[] b = []; assert(a is null); assert(!a.length); assert(b is null); assert(!b.length); What I would like is to tell that b is an empty array and a is a null array. The issue

Re: How to get the pointer of "this" ?

2020-05-26 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/26/20 8:08 AM, Johannes Loher wrote: On Tuesday, 26 May 2020 at 11:44:58 UTC, Vinod K Chandran wrote: On Monday, 25 May 2020 at 16:39:30 UTC, Mike Parker wrote: On Monday, 25 May 2020 at 08:39:23 UTC, John Burton wrote: I believe that in D *this* is a reference to the object and not a

Re: Learning Vibe.d

2020-05-26 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/25/20 5:49 AM, Daniel Kozak wrote: On Sun, May 24, 2020 at 10:06 AM Russel Winder via Digitalmars-d-learn wrote: For my purposes switching to using SIGKILL rather than SIGTERM in my tests seems to work with 1.9.1, so I'll go with that till 1.9.2 or 1.10.0 produces a fix rather than

Flagging spam on forum.dlang.org

2020-05-26 Thread Steven Schveighoffer via Digitalmars-d-learn
Someone asked this question in response to SPAM, and I don't want to answer it there, because I'm expecting that entire subthread to be removed. Yes, there is a flag button on forum.dlang.org. I'm not sure if you need permissions to access it, but it allows you to flag the maintainers to look

Re: Learning Vibe.d

2020-05-23 Thread Steven Schveighoffer via Digitalmars-d-learn
On Saturday, 23 May 2020 at 15:47:59 UTC, Russel Winder wrote: Hi, I thought I would try and do the async version of my mock AVR850 using the vibe.d TCP stuff. This is not HTTP, it is proper networking! ;-) Problem one is that vibe.d sever processes never seem to terminate. I am using

Re: How to use base class & child class as parameter in one function ?

2020-05-22 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/22/20 5:39 PM, Vinod K Chandran wrote: On Friday, 22 May 2020 at 20:51:20 UTC, Steven Schveighoffer wrote: On 5/22/20 4:04 PM, Vinod K Chandran wrote: [...] Yes. What you cannot do is this (which I hope doesn't compile in VB.net, but I wouldn't be surprised): Dim sampleList As New

Re: How to use base class & child class as parameter in one function ?

2020-05-22 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/22/20 4:04 PM, Vinod K Chandran wrote: On Friday, 22 May 2020 at 16:12:12 UTC, Steven Schveighoffer wrote: On 5/22/20 9:10 AM, Vinod K Chandran wrote: On Friday, 22 May 2020 at 12:21:25 UTC, rikki cattermole wrote: if (Child child = cast(Child)parent) { assert(child !is null); }

Re: How to use base class & child class as parameter in one function ?

2020-05-22 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/22/20 9:10 AM, Vinod K Chandran wrote: On Friday, 22 May 2020 at 12:21:25 UTC, rikki cattermole wrote: if (Child child = cast(Child)parent) { assert(child !is null); } Actually, problem occurs in addHandler function. It expects an argument of type "EventArgs", not MouseEventArgs.

Re: redirect std out to a string?

2020-05-21 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/21/20 12:29 AM, Kaitlyn Emmons wrote: is there a way to redirect std out to a string or a buffer without using a temp file? D's I/O is dependent on C's FILE * API, so if you can make that write to a string, then you could do it in D. I don't think there's a way to do it in C. So likely

Re: How to allocate/free memory under @nogc

2020-05-21 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/20/20 10:50 PM, data pulverizer wrote: how do you allocate/free memory without using the garbage collector? Use C malloc and free. Does allocating and freeing memory using `GC.malloc` and `GC.free` avoid D's garbage collector? No, an allocation can trigger a collection. D does not

Re: Assignment of tuples

2020-05-20 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/20/20 8:17 AM, Russel Winder wrote: So I have an enum: enum RC5Command: Tuple!(ubyte, ubyte) { Standby = tuple(to!ubyte(0x10), to!ubyte(0x0c)), … I can do: RC5Command rc5command = RC5Command.CD; However, if I do: rc5command = RC5Command.BD; I get:

Re: None of the overloads of kill are callable using argument types:

2020-05-19 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/18/20 9:18 PM, Ali Çehreli wrote: On 5/18/20 1:11 PM, BoQsc wrote:> I'm trying to kill my own process, but I'm being unsuccessful at the > compilation of the program. It seems that neither getpid nor > thisProcessID returns a correct type value for the kill function. Of course, Adam D.

Re: Compare string with German umlauts

2020-05-18 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/18/20 9:44 AM, Martin Tschierschke wrote: Hi, I have to find a certain line in a file, with a text containing umlauts. How do you do this? The following was not working: foreach(i,line; file){  if(line=="My text with ö oe, ä ae or ü"){    writeln("found it at line",i)  } } I ended up

Re: How should I move in a DList ?

2020-05-13 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/13/20 5:57 AM, Gabriel wrote: Hello, As I am totally new to D (my background is mainly C++) I am having trouble porting an algorithm that simplifies a polyline in 2D, very similar to this one: http://psimpl.sourceforge.net/reumann-witkam.html Here is what I would like: 1) Use a

Re: Get unknown symbol (struct, method, class) tagged with User Defined Attributes

2020-05-11 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/11/20 11:30 PM, Doug wrote: On Tuesday, 12 May 2020 at 02:53:53 UTC, Adam D. Ruppe wrote: see std.traits.getSymbolsByUDA Thanks for the link. I did see that one. But that function searches within known symbols. My use case if for a library that's used outside of my application. In

Re: Probably a trivial question regarding version identifier and unittest

2020-05-11 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/11/20 9:54 PM, WhatMeWorry wrote: I'm trying to study Adam Ruppe's terminal.d sub-package and I see the following code segment: version(demos) unittest {     import arsd.terminal;     void main()     {     // . . .     }     main; // exclude from docs } Looks like a good

Re: D and Async I/O

2020-05-11 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/11/20 3:46 PM, ikod wrote: On Monday, 11 May 2020 at 17:34:41 UTC, Jacob Carlborg wrote: On 2020-05-11 16:44, Russel Winder wrote: Crickey, a third option. This wil increase my dithering! ;-) Forth: Mecca [1] :) [1] https://github.com/weka-io/mecca And probably more. At least I also

Re: Different visibility in template for class and struct?

2020-05-11 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/11/20 11:40 AM, Shigeki Karita wrote: On Monday, 11 May 2020 at 15:29:53 UTC, Steven Schveighoffer wrote: On 5/11/20 11:11 AM, Shigeki Karita wrote: [...] First, it actually does compile, I think because the compiler recognizes that LocalS is POD (plain old data), without methods, so

Re: Different visibility in template for class and struct?

2020-05-11 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/11/20 11:11 AM, Shigeki Karita wrote: Why is local struct visible in this outer template, while local class is not? https://wandbox.org/permlink/MfsDa68qgaMSIr4a https://dlang.org/spec/template.html#instantiation_scope --- enum p(T) = __traits(compiles, new T()); class GlobalC {}

<    6   7   8   9   10   11   12   13   14   15   >