Re: vibe.d: How to get the conent of a file upload ?

2020-09-19 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/19/20 3:36 PM, IGotD- wrote: On Saturday, 19 September 2020 at 19:27:40 UTC, Steven Schveighoffer wrote: I used Kai's book, and yeah, you have to do things the vibe way. But most web frameworks are that way I think. Do you have a reference to this book (web link, ISBN)? Sure:

Re: vibe.d: How to get the conent of a file upload ?

2020-09-19 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/19/20 6:59 AM, wjoe wrote: Handling file uploads is one example, another is command line arguments. The presumption here is there is vibe and there can only be vibe. It takes them from Runtime.args. Duh? This didn't make sense to me until I saw example where the initialization of vibe was

Re: vibe.d: How to get the conent of a file upload ?

2020-09-19 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/19/20 7:15 AM, ikod wrote: On Saturday, 19 September 2020 at 11:11:21 UTC, ikod wrote: On Friday, 18 September 2020 at 13:13:16 UTC, wjoe wrote: On Friday, 18 September 2020 at 12:58:29 UTC, Steven Schveighoffer wrote: On 9/18/20 8:39 AM, Steven Schveighoffer wrote: But again, solved

Re: Question about linker errors when using slices

2020-09-19 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/18/20 10:45 PM, tspike wrote: If you only compile platform.d, the linker will complain about “undefined references.” This is true when using dmd and gdc, though platform.d compiles just fine when using ldc. But the file only fails to compile when the “items” member of AppData is a slice;

Re: dub: Is it possible to have a library target and depend on it in the same dub config?

2020-09-18 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/18/20 7:38 AM, wjoe wrote: Something like this: configuration "lib" {   targetType "dynamicLibrary"   sourceDir "source/lib/" } configuration "app" {   targetType "executable"   sourceFiles "source/app.d"   linkWith "lib" } I found subConfiguration in the docs but that seems to be

Re: DDoc generation

2020-09-18 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/18/20 7:41 AM, Russel Winder wrote: Hi, I am trying to get to grips with DDoc for documenting an application. Getting the individual module HTML files seems to be the easy bit. The question is how to get an index.html (or equivalent) so as to have an application level entry point to the

Re: vibe.d: How to get the conent of a file upload ?

2020-09-18 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/18/20 8:39 AM, Steven Schveighoffer wrote: But again, solved with an enhancement that allows you to process the data in your code. I'll file the enhancement request for you, as I think it's a nice addition. https://github.com/vibe-d/vibe.d/issues/2478 -Steve

Re: vibe.d: How to get the conent of a file upload ?

2020-09-18 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/17/20 8:07 PM, wjoe wrote: Not a reply to this post in particular but to all the ones I've read so far. If I understand correctly. Vibe parses the form data and writes all files to disk. Where to ? See the code here:

Re: vibe.d: How to get the conent of a file upload ?

2020-09-17 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/17/20 6:13 PM, aberba wrote: On Thursday, 17 September 2020 at 21:57:37 UTC, Steven Schveighoffer wrote: On 9/17/20 1:08 PM, wjoe wrote: [...] the `files` property actually does the processing only when you call it. If you access the `bodyReader` property directly, you can process that

Re: enum and const or immutable ‘variable’ whose value is known at compile time

2020-09-17 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/17/20 9:13 AM, Simen Kjærås wrote: To be clear: I don't mind 'enum' being used this way, but if I were to do things over again, I would have used 'alias'. fun fact: for a (very) brief time, D had a `manifest` keyword that did exactly what enum does in this instance (not even sure it

Re: vibe.d: How to get the conent of a file upload ?

2020-09-17 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/17/20 1:08 PM, wjoe wrote: Every post or example I found copies the file, like your code does, too. Why is that ? The content of the file upload is embedded in the form data. There's no need for temporary files or copying at all. On top of that, if I upload a file to a server which is on

Re: Why is BOM required to use unicode in tokens?

2020-09-15 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/15/20 8:10 PM, James Blachly wrote: On 9/15/20 10:59 AM, Steven Schveighoffer wrote: Thanks to Paul, Jon, Dominikus and H.S. for thoughtful responses. What will it take (i.e. order of difficulty) to get this fixed -- will merely a bug report (and PR, not sure if I can tackle or not) do

Re: Why is BOM required to use unicode in tokens?

2020-09-15 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/15/20 10:18 AM, James Blachly wrote: On 9/15/20 4:36 AM, Dominikus Dittes Scherkl wrote: On Tuesday, 15 September 2020 at 06:49:08 UTC, Jon Degenhardt wrote: On Tuesday, 15 September 2020 at 02:23:31 UTC, Paul Backus wrote: Identifiers start with a letter, _, or universal alpha, and are

Re: Get enum value name as string at compile time?

2020-09-14 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/14/20 2:25 AM, Simen Kjærås wrote: On Monday, 14 September 2020 at 03:48:51 UTC, Steven Schveighoffer wrote: Consider the enum: enum Foo { a, b } Foo.a.stringof => "a" enum x = Foo.a; x.stringof => "cast(Foo)0" Is there another way I can take an enum value that's known at compile time

Get enum value name as string at compile time?

2020-09-13 Thread Steven Schveighoffer via Digitalmars-d-learn
Consider the enum: enum Foo { a, b } Foo.a.stringof => "a" enum x = Foo.a; x.stringof => "cast(Foo)0" Is there another way I can take an enum value that's known at compile time (but not the actual identifier), and get the name of it? I know I can use a switch, or to!string. But I was hoping

Re: Call C variadic function from D variadic function

2020-09-13 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/13/20 2:35 PM, Paul Backus wrote: On Sunday, 13 September 2020 at 17:23:42 UTC, Steven Schveighoffer wrote: On 9/13/20 12:55 PM, James Blachly wrote: ``` /// Add a single line to an existing header auto addLine(T...)(RecordType type, T kvargs) if(kvargs.length > 0 &&

Re: Call C variadic function from D variadic function

2020-09-13 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/13/20 12:55 PM, James Blachly wrote: Summary: Can a typesafe D variadic function, or D variadic template pass its parameters to a C variadic function? Background: I maintain a library binding [0] to htslib, a high-performance and very widely used C library for high-throughput sequencing

Re: Initialize to None

2020-09-05 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/5/20 11:42 PM, N.S. wrote: I'd like to check whether a variable is initialized or not. And I'd also like to uninitialize a variable that is already initialized. Thanks! int x = void; if (x == void) There isn't a way to check this. {     writeln("x not initialized"); } else {     //

Re: I think Associative Array should throw Exception

2020-09-04 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/4/20 1:48 AM, Jesse Phillips wrote: On Thursday, 3 September 2020 at 15:12:14 UTC, Steven Schveighoffer wrote: int[int] aa; aa[4] = 5; auto b = aa[4]; How is this code broken? It's valid, will never throw, and there's no reason that we should break it by adding an exception into the mix.

Re: I think Associative Array should throw Exception

2020-09-03 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/3/20 10:43 AM, Jesse Phillips wrote: On Tuesday, 1 September 2020 at 18:55:20 UTC, Steven Schveighoffer wrote: On 9/1/20 2:20 PM, Jesse Phillips wrote: Using RangeError is nice as it allows code to use array index inside `nothrow.` This is the big sticking point -- code that is nothrow

Re: Annotating SortedRange.empty const: Best way to auto-deduce annotations?

2020-09-02 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/2/20 5:23 PM, SimonN wrote: Hi, About this issue in Phobos: https://issues.dlang.org/show_bug.cgi?id=21216 SortedRange.empty should be const, .front should be inout Just adding const/inout to SortedRange's methods won't be enough; if we add const/inout here, then many other Phobos ranges

Re: Bug in import(...) on Windows?

2020-09-02 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/2/20 4:48 PM, Andrey Zherikov wrote: On Wednesday, 2 September 2020 at 20:23:15 UTC, Steven Schveighoffer wrote: What I'm wondering is if it needs to be ./file instead of .\file. Can you hard code that and see if it works? This actually works:     pragma(msg, import("file"));    

Re: Bug in import(...) on Windows?

2020-09-02 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/2/20 1:47 PM, Adam D. Ruppe wrote: On Wednesday, 2 September 2020 at 17:39:04 UTC, Andrey Zherikov wrote: Is this a bug in dmd? I think it is an old bug filed (I can't find it though) about inconsistent platform behavior but it is allowed by spec for the compiler to reject any path

Re: How to create compile-time container?

2020-09-02 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/2/20 5:56 AM, Andrey Zherikov wrote: == Everything works well until I have included scripts in subdirectories: ├── dir1 │   ├── dir2 │   │   └── script │   └── script └── script Content: == script msg hello include dir1/script == dir1/script msg hello

Re: I think Associative Array should throw Exception

2020-09-02 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/1/20 10:46 PM, James Blachly wrote: On 9/1/20 2:55 PM, Steven Schveighoffer wrote: On 9/1/20 2:20 PM, Jesse Phillips wrote: Using RangeError is nice as it allows code to use array index inside `nothrow.` This is the big sticking point -- code that is nothrow would no longer be able to

Re: How to create compile-time container?

2020-09-01 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/1/20 3:09 PM, Andrey Zherikov wrote: Unfortunately this won't work if there is a function 'bar' in different module that calls 'foo': You should post a full example you expect to work or not work, then we can discuss. I think it should work (I've tried it), but there are several

Re: How to create compile-time container?

2020-09-01 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/1/20 2:19 PM, Andrey Zherikov wrote: On Monday, 31 August 2020 at 20:44:16 UTC, Adam D. Ruppe wrote: On Monday, 31 August 2020 at 20:39:10 UTC, Andrey Zherikov wrote: How can I do that? You can use a normal string[] BUT it is only allowed to be modified inside its own function. Then

Re: I think Associative Array should throw Exception

2020-09-01 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/1/20 2:20 PM, Jesse Phillips wrote: Using RangeError is nice as it allows code to use array index inside `nothrow.` This is the big sticking point -- code that is nothrow would no longer be able to use AAs. It makes the idea, unfortunately, a non-starter. What is wrong with using

Re: Template argument deduction fails with alias

2020-08-31 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/31/20 9:11 PM, Ben Jones wrote: I have an alias that looks like static if(...){   alias AliasType = SumType!(...); } which I use in a template constraint for a function template: bool func(T: AliasType!Args, Args...)(T t){ ... } When I try to call func with an AliasType object, the

Re: How do I convert an ISO 8601 datetime into a unix timestamp - at compile-time?

2020-08-28 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/27/20 9:54 PM, Andrej Mitrovic wrote: - import std.datetime; void main () {     static time = SysTime(DateTime.fromISOString("20220101T00")).toUnixTime; } - - /Library/D/dmd/src/phobos/std/concurrency.d(2574): Error: static variable lock cannot be read at compile time

Re: How to get the element type of an array?

2020-08-25 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/25/20 4:38 AM, Jon Degenhardt wrote: On Tuesday, 25 August 2020 at 05:02:46 UTC, Basile B. wrote: On Tuesday, 25 August 2020 at 03:41:06 UTC, Jon Degenhardt wrote: What's the best way to get the element type of an array at compile time? Something like std.range.ElementType except that

Re: __FILE__ and __LINE__ in case of import expression

2020-08-23 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/23/20 8:42 AM, Andrey Zherikov wrote: On Saturday, 22 August 2020 at 03:43:10 UTC, Steven Schveighoffer wrote: On 8/21/20 6:34 PM, Adam D. Ruppe wrote: On Friday, 21 August 2020 at 22:12:48 UTC, Steven Schveighoffer wrote: And honestly, if it says the source is "mixin-50, line 1", I think

Re: __FILE__ and __LINE__ in case of import expression

2020-08-21 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/21/20 6:34 PM, Adam D. Ruppe wrote: On Friday, 21 August 2020 at 22:12:48 UTC, Steven Schveighoffer wrote: And honestly, if it says the source is "mixin-50, line 1", I think people will get it. I could probably live with that too, but the status quo is pretty useful as-is. I wonder if

Re: __FILE__ and __LINE__ in case of import expression

2020-08-21 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/21/20 5:56 PM, Adam D. Ruppe wrote: On Friday, 21 August 2020 at 21:42:21 UTC, Steven Schveighoffer wrote: While not necessarily a "bug", it's not very useful. Maybe not in this case, but it is perfectly accurate for cases like: mixin(q{    some code here }); Where it will actually

Re: __FILE__ and __LINE__ in case of import expression

2020-08-21 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/21/20 5:08 PM, Adam D. Ruppe wrote: On Friday, 21 August 2020 at 21:06:11 UTC, Steven Schveighoffer wrote: The hybrid line number (original source line number + mixin line number) seems like a bug to me. I'm not so sure without seeing all the code. Remember to the compiler, the mixin

Re: __FILE__ and __LINE__ in case of import expression

2020-08-21 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/21/20 4:54 PM, Andrey Zherikov wrote: On Friday, 21 August 2020 at 20:44:27 UTC, Andrey Zherikov wrote: Thanks for this link! I can use "#line" to fix line number but not file name: file: 'foo.d-mixin-1', line: '6', module: 'test', function: 'test.main', pretty function: 'int

Re: __FILE__ and __LINE__ in case of import expression

2020-08-21 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/21/20 10:01 AM, Andrey Zherikov wrote: How can I get __FILE__ and __LINE__ values correct in case of import expression? ... So the output from line #16 (1) is correct although from line #17 (2) is not: file name is neither 'test.d' not 'foo.d' and line number is 22 although both test.d

Re: SIGUSR1 in clock_nanosleep()? how to isolate this issue?

2020-08-20 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/20/20 2:58 PM, mw wrote: Hi, I run into an issue: it's SIGUSR1 in clock_nanosleep() The GC uses SIGUSR1 (and SIGUSR2). Maybe that's the issue? https://github.com/dlang/druntime/blob/e1fb19829ebef0419782de43ce4b0e2a1ba140be/src/core/thread/osthread.d#L1946 -Steve

Re: how stdin stream works?

2020-08-19 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/19/20 1:44 PM, Flade wrote: Hi everyone! I'm trying to do error handling (with the try block) and when I give a wrong value to the variable (it is an integer and I give a non-number value), then It doesn't let me re get input. The code: int x; bool not_accepted = false; while

Re: `enum x;` - what is it?

2020-08-19 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/19/20 10:06 AM, Victor Porton wrote: This declaration does compile: enum x; But what is it? Is it an equivalent of enum x { } ? What in the specification allows this looking a nonsense enum x; ? I use it as a symbol for UDAs. enum required; struct S { @required int x; } which

Re: Types of lambda args

2020-08-16 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/16/20 8:27 PM, Adam D. Ruppe wrote: On Monday, 17 August 2020 at 00:20:24 UTC, Cecil Ward wrote: In a lambda, how do we know what types the arguments are? In something like     (x) => x * x In that the compiler figures it out from usage context. So if you pass it to a int

Re: Autodecode?

2020-08-16 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/16/20 4:53 PM, JN wrote: Related to this thread: https://forum.dlang.org/post/xtjzhkvszdiwvrmry...@forum.dlang.org I don't want to hijack it with my newbie questions. What is autodecode and why is it such a big deal? From what I've seen it's related to handling Unicode characters? And D

Re: Cannot call @system funciton (stdout)

2020-08-16 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/16/20 6:07 AM, Simen Kjærås wrote: On Saturday, 15 August 2020 at 23:59:36 UTC, Joel wrote: ../../JMiscLib/source/jmisc/base.d(176,2): Error: @safe function jmisc.base.upDateStatus!string.upDateStatus cannot call @system function std.stdio.makeGlobal!"core.stdc.stdio.stdout".makeGlobal

Re: Leaving a pointer to it on the stack

2020-08-13 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/13/20 4:51 PM, Andre Pany wrote: On Thursday, 13 August 2020 at 20:11:50 UTC, Steven Schveighoffer wrote: The garbage collector scans all of the stack as if it were an array of pointers. So if you have a pointer to it anywhere on the stack, it won't be collected. However, it only scans

Re: Leaving a pointer to it on the stack

2020-08-13 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/13/20 4:04 PM, Andre Pany wrote: Hi, in the specification https://dlang.org/spec/interfaceToC.html#storage_allocation there is this paragraph: "Leaving a pointer to it on the stack (as a parameter or automatic variable), as the garbage collector will scan the stack." I have some

Re: vibe.d and my first web service

2020-08-13 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/13/20 3:28 AM, WebFreak001 wrote: On Wednesday, 12 August 2020 at 21:11:54 UTC, Daniel Kozak wrote: [...] Unfortunately, I think vibe-d is dead. With every release it is worse than before and it seems there is almost no activity. So D really need new champion here maybe hunt will be

Re: DMD: how to restore old unittest+main

2020-08-13 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/13/20 5:02 AM, Nils Lankila wrote: On Thursday, 13 August 2020 at 08:49:21 UTC, WebFreak001 wrote: On Thursday, 13 August 2020 at 07:52:07 UTC, novice3 wrote: Hello. I don't use dub. I use Windows and *.d file association to compile small apps by dmd with "-i -unittest -g" switches. Now

Re: Reading from stdin significantly slower than reading file directly?

2020-08-13 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/12/20 6:44 PM, methonash wrote: Hi, Relative beginner to D-lang here, and I'm very confused by the apparent performance disparity I've noticed between programs that do the following: 1) cat some-large-file | D-program-reading-stdin-byLine() 2) D-program-directly-reading-file-byLine()

Re: __vector(ubyte[32]) misalignment

2020-08-10 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/10/20 2:53 PM, Bruce Carneal wrote: No biggee but it looks like there is some duplicate code at the end of the __alignPad unittest. Hah! I think I copy-pasted that intending to write a new test, but then tried it separately and found another issue (typeid(__vector(ubyte[32])).talign

Re: __vector(ubyte[32]) misalignment

2020-08-10 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/9/20 8:46 AM, Steven Schveighoffer wrote: On 8/9/20 8:37 AM, Steven Schveighoffer wrote: I think this has come up before, there may even be a bug report on it. Found one, I'll see if I can fix the array runtime: https://issues.dlang.org/show_bug.cgi?id=10826 Bruce, I have a PR to

Re: Factory pattern for classes

2020-08-09 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/9/20 10:27 AM, lexxn wrote: On Sunday, 9 August 2020 at 12:24:05 UTC, Steven Schveighoffer wrote: Object getClassById(uint id) {     if (id == 0) {     return new A;     } else if(id == 1) {     return new B;     } else {     return new C;     } } I assume that the correct

Re: Factory pattern for classes

2020-08-09 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/9/20 10:58 AM, lexxn wrote: On Sunday, 9 August 2020 at 12:24:05 UTC, Steven Schveighoffer wrote: If you know what your class is going to be, I'd just import the file that contains it and avoid the whole Object.factory deal. It's going to go away anyways. Not sure if it's a good idea

Re: __vector(ubyte[32]) misalignment

2020-08-09 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/9/20 8:37 AM, Steven Schveighoffer wrote: I think this has come up before, there may even be a bug report on it. Found one, I'll see if I can fix the array runtime: https://issues.dlang.org/show_bug.cgi?id=10826 -Steve

Re: __vector(ubyte[32]) misalignment

2020-08-09 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/9/20 8:09 AM, Bruce Carneal wrote: On Sunday, 9 August 2020 at 09:58:18 UTC, Johan wrote: On Sunday, 9 August 2020 at 01:03:51 UTC, Bruce Carneal wrote: The .alignof attribute of __vector(ubyte[32]) is 32 but initializing an array of such vectors via an assignment to .length has given me

Re: String argument with optional value in std.getopt

2020-08-09 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/8/20 7:58 PM, Hassan wrote: Hello I'm trying to get getopt to recognize an argument that may or may not take a value. Here's an example : ../hashtrack --list ../hashtrack --list filter The problem is that if I point list to a string variable, the first call fails with "Missing value

Re: Factory pattern for classes

2020-08-09 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/9/20 5:16 AM, lexxn wrote: I'm trying to get the factory pattern going with classes class A {} class B {} class C {} auto getClassById(uint id) {     if (id == 0) {     return cast(A)Object.factory("A");     } else if(id == 1) {     return cast(B)Object.factory("B");     }

Re: problem using std.format on Arm

2020-08-08 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/8/20 1:00 PM, Jeremiah Glover wrote: What can I do to fix this and get the most recent version of phobos that will compile? You are using an old version of the compiler. formattedRead used to accept only pointers, not by ref. See https://github.com/dlang/phobos/pull/5009 Try doing:

Re: iopipe code to count lines in gzipped file works with v 0.1.7 but fails with 0.2.1

2020-08-07 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/7/20 9:31 PM, Steven Schveighoffer wrote: On 8/7/20 8:57 PM, Steven Schveighoffer wrote: I think this is an issue with dub when using an inline recipe file, but I don't know? ugh. This is an issue with iopipe specifying io version 0.2.x. I will fix this. OK, iopipe 0.2.2 is released,

Re: iopipe code to count lines in gzipped file works with v 0.1.7 but fails with 0.2.1

2020-08-07 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/7/20 8:57 PM, Steven Schveighoffer wrote: I tried adding dependency "io" version="~>0.3.0" But it fails with: Got no configuration for dependency io ~>0.3.1 of hello ~master!? If I add dependency "io" version="*" it works. I think this is an issue with dub when using an inline recipe

Re: iopipe code to count lines in gzipped file works with v 0.1.7 but fails with 0.2.1

2020-08-07 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/7/20 9:40 AM, Andrew wrote: Hi, This code to count lines in a gzipped file exits with "Program exited with code -9" when run with the latest version of the library, I guess because I am doing unsafe things. BTW the safety improvements only change whether it compiles as @safe or not.

Re: iopipe code to count lines in gzipped file works with v 0.1.7 but fails with 0.2.1

2020-08-07 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/7/20 9:40 AM, Andrew wrote: Hi, This code to count lines in a gzipped file exits with "Program exited with code -9" when run with the latest version of the library, I guess because I am doing unsafe things. Could someone tell me how to change it to make it work? The actual program I'm

Re: Is there an alternative of `go get`

2020-08-07 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/7/20 3:28 AM, Cogitri wrote: On Friday, 7 August 2020 at 07:17:25 UTC, Ky-Anh Huynh wrote: Hi everyone, `go get` in Golang world has a simple way to fetch and install binary ``` $ go get github/foo/bar.git $ export PATH=$PATH:$(go env GOPATH)/bin $ bar --help ``` This saves a lot of

Re: Non-recursive maxSizeOf

2020-08-06 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/6/20 9:23 AM, Adam D. Ruppe wrote: On Thursday, 6 August 2020 at 13:18:40 UTC, Per Nordlöw wrote:     mixin(T.stringof ~ " _store" ~ T.mangleof ~ Never ever use mixin(T.stringof). Always just use mixin("T") instead. mixin("T _store", T.mangleof /* or just idx is gonna be

Re: std.conv.ConvException from double to uint64_t, but only locally in a large project

2020-08-04 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/4/20 2:15 PM, Steven Schveighoffer wrote: I'll file a bug. https://issues.dlang.org/show_bug.cgi?id=21112 -Steve

Re: std.conv.ConvException from double to uint64_t, but only locally in a large project

2020-08-04 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/4/20 1:36 PM, drathier wrote: I'm getting a crash when I'm converting a double to an uint64_t. ``` std.conv.ConvException@/usr/local/opt/dmd/include/dlang/dmd/std/conv.d(2054): Value (1596) does not match any member value of enum '__c_ulonglong' ``` I've narrowed down the code to this:

Re: Template functions inside interface

2020-08-04 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/4/20 9:39 AM, Adam D. Ruppe wrote: On Tuesday, 4 August 2020 at 13:36:15 UTC, Zans wrote: Is there any way to declare template functions inside interface and then override them in a class? No, the templates in the interface are automatically considered `final`. So the body must be in

Re: safety and auto vectorization

2020-08-03 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/3/20 3:22 PM, Bruce Carneal wrote: Thanks Steve (and Chad).  Summary: underspecified, varying behavior across versions, buggy. Steve, what's the best way for me to report this?  Are spec issues lumped in with the other bugzilla reports? Yep. You can file under dlang.org with the spec

Re: safety and auto vectorization

2020-08-03 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/2/20 1:31 PM, Bruce Carneal wrote: import std; void f0(int[] a, int[] b, int[] dst) @safe {     dst[] = a[] + b[]; } void f1(int[] a, int[] b, int[] dst) @trusted {     const minLen = min(a.length, b.length, dst.length);     dst[0..minLen] = a[0..minLen] + b[0..minLen];    

Re: Idiomatic D code to avoid or detect devision by zero

2020-08-03 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/3/20 5:53 AM, Martin Tschierschke wrote: On Friday, 31 July 2020 at 14:18:15 UTC, Steven Schveighoffer wrote: On 7/31/20 9:55 AM, Martin Tschierschke wrote: What would be the idiomatic way to write a floating point division occuring inside a loop and handle the case of division by zero.

Re: dynamic array .length vs .reserve - what's the difference?

2020-08-01 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/31/20 12:32 PM, wjoe wrote: On Friday, 31 July 2020 at 04:28:57 UTC, Ali Çehreli wrote: Another option, which is curiously said to be more performant in memory allocation than native arrays, is std.array.Appender. I've used function-local static Appenders to cut down on memory allocation.

Re: Idiomatic D code to avoid or detect devision by zero

2020-07-31 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/31/20 9:55 AM, Martin Tschierschke wrote: What would be the idiomatic way to write a floating point division occuring inside a loop and handle the case of division by zero. c = a/b; // b might be zero sometimes, than set c to an other value (d). (In the moment I check the divisor being

Re: dynamic array .length vs .reserve - what's the difference?

2020-07-30 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/30/20 11:58 AM, wjoe wrote: I just stumbled upon code like this: struct Foo(T) {     T[] b;     this(int n)     {     b.reserve(n);     b.length = n;     } } ..reserve looks redundant. It is, in this case. Reserve will extend the allocated length to n, but not adjust the

Re: dub build to generate different kinds of libs

2020-07-28 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/28/20 5:50 PM, jeff thompson wrote: Hello Im brand new to D (loving it btw!) and have decided to build a largish windows project in the language. First question, is there a dub.json setup to have a dub build to generate multiple binaries in one call? Like a dll and a static lib. Seems

Re: Why are std.bitmanip.bitfields so big ?

2020-07-28 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/28/20 5:46 AM, MoonlightSentinel wrote: On Tuesday, 28 July 2020 at 09:28:27 UTC, wjoe wrote: It was run on the doc page. I suppose the examples are wrapped in a unittest block? Indeed, see

Re: Help with Ranges

2020-07-27 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/27/20 1:10 PM, Charles wrote: Still, I'm confused since, as far as I know, map wraps its source, i.e. the array in this case, which is sortable. It seems to me the only reason I can't sort MapResult is because it doesn't have the proper interface. Let's talk about a concrete example,

Re: Why are std.bitmanip.bitfields so big ?

2020-07-27 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/27/20 5:49 AM, wjoe wrote: struct A {     mixin(bitfields!(    bool, "flag1",    1,    bool, "flag2",    1,    uint, "", 6)); } Is this inside a function? If so, put `static` on it. What you are seeing is the 8-byte frame pointer that comes from inner structs so

Re: Help with Ranges

2020-07-26 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/26/20 3:10 AM, Charles wrote: Suppose I have the following line of code where arr is an array, doSomething is some predicate that does a lot of processing on each element, sort must come after the mapping, and there are more operations done to the range after sort:

Re: Returning range of inout objects from inout method

2020-07-25 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/25/20 4:07 PM, Steven Schveighoffer wrote: On 7/25/20 3:16 PM, FreeSlave wrote: On Saturday, 25 July 2020 at 14:19:15 UTC, Steven Schveighoffer wrote: The only way to do this without code duplication (but with generated code duplication) is to template the byAction function on the type

Re: Returning range of inout objects from inout method

2020-07-25 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/25/20 3:16 PM, FreeSlave wrote: On Saturday, 25 July 2020 at 14:19:15 UTC, Steven Schveighoffer wrote: The only way to do this without code duplication (but with generated code duplication) is to template the byAction function on the type of `this`: auto byAction(this This)() { /*

Re: Returning range of inout objects from inout method

2020-07-25 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/25/20 8:26 AM, FreeSlave wrote: I want to be able to return a range of const objects from the const object and a range mutable objects from the mutable object. inout comes to mind, but not applicable in this case, because inout must be applied to the return type as whole, which does not

Re: Feedback to stdout when a specific unittest is run

2020-07-23 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/23/20 11:10 AM, Per Nordlöw wrote: Is it possible to activate some feedback print to stdout when a unittest is started and ended to track which unittests that take the longest to execute? Alternatively inject a hook being run before each test is run. Yes, you can copy the code [1], and

Re: Alternative to std.range.choose

2020-07-22 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/22/20 12:33 AM, James Gray wrote: Is there a better way to achieve behaviour similar to rangeFuncIf below? f gives a contrived example of when one might want this. g is how one might try and achieve the same with std.range.choose. import std.stdio; import std.range : only, chain, join,

Re: miscellaneous array questions...

2020-07-21 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/21/20 8:34 AM, Adam D. Ruppe wrote: The others aren't wrong about stack size limits playing some role, but the primary reason is that it is a weird hack for @safe, believe it or not. ... I don't recall exactly when this was discussed but it came up in the earlier days of @safe, I'm

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

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