Re: Type inference for constructors

2020-09-17 Thread Simen Kjærås via Digitalmars-d-learn
On Friday, 18 September 2020 at 05:43:56 UTC, data pulverizer wrote: I’d like to know if constructors of classes and structs can have type inference. So far, I am using a separate function for this purpose, for example: ``` import std.stdio: writeln; struct Pair(T, U) { T first; U second;

Type inference for constructors

2020-09-17 Thread data pulverizer via Digitalmars-d-learn
I’d like to know if constructors of classes and structs can have type inference. So far, I am using a separate function for this purpose, for example: ``` import std.stdio: writeln; struct Pair(T, U) { T first; U second; this(T first, U second) { this.first = first; this.second

Re: Proper way to exit with specific exit code?

2020-09-17 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Sep 17, 2020 at 09:53:07PM -0400, James Blachly via Digitalmars-d-learn wrote: [...] > I never considered this -- so when I call core.stdc.stdlib : exit, > none of my destructors get called? Yes. > Presumably also not scope(exit) blocks? Yes. > If this is the case, could we simply ad

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

2020-09-17 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 17 September 2020 at 22:25:47 UTC, claptrap wrote: If enum means manifiest constant, or compile time constant, then it makes more sense, as you allude to in a later post. But 'enum' is a terrible name for that and I dont think my brain will ever stop finding it incongruous. And

Re: Proper way to exit with specific exit code?

2020-09-17 Thread James Blachly via Digitalmars-d-learn
On 9/17/20 12:46 PM, IGotD- wrote: The only way is to return from main. The thing is that druntime runs initialization before main and then returning from main it runs all the tear down code including cleaning up the GC. This means there is no equivalent of the exit function in the C library. C

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

2020-09-17 Thread jmh530 via Digitalmars-d-learn
On Thursday, 17 September 2020 at 10:53:48 UTC, Mike Parker wrote: [snip] I can attest that in the 17 years I've been hanging around here, the fact that enum is used to indicate a manifest constant has not been a serious source of WTF posts. So I think "pretty much everyone coming to D" have

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

2020-09-17 Thread wjoe via Digitalmars-d-learn
On Thursday, 17 September 2020 at 22:33:46 UTC, Steven Schveighoffer wrote: 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 cal

Re: another question on hidden mixin names

2020-09-17 Thread 60rntogo via Digitalmars-d-learn
On Thursday, 17 September 2020 at 22:07:54 UTC, Simen Kjærås wrote: Usually, that would be: struct V { int x; mixin assign!"+" a; mixin assign!"-" b; alias opOpAssign = a.opOpAssign; alias opOpAssign = b.opOpAssign; } However, I can't seem to get that working. It seems to b

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 claptrap via Digitalmars-d-learn
On Thursday, 17 September 2020 at 10:56:28 UTC, Mike Parker wrote: On Thursday, 17 September 2020 at 09:44:20 UTC, claptrap wrote: Seriously how it's implemented is irrelevant. And to be clear, my point wasn't about how it's implemented. My point was that: enum { foo = 10; } and enum foo

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

2020-09-17 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Sep 17, 2020 at 06:06:56PM -0400, Steven Schveighoffer via Digitalmars-d-learn wrote: > 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) bri

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

2020-09-17 Thread aberba via Digitalmars-d-learn
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 data yourself. You can even regi

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 made

Re: another question on hidden mixin names

2020-09-17 Thread Simen Kjærås via Digitalmars-d-learn
On Thursday, 17 September 2020 at 21:05:59 UTC, 60rntogo wrote: struct V { int x; mixin assign!"+"; // mixin assign!"-"; } However, if I uncomment the second mixin, there is an error "v is not a scalar, it is a V". I guess I somehow need to merge these overloads, but I don't know how.

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

another question on hidden mixin names

2020-09-17 Thread 60rntogo via Digitalmars-d-learn
I suspect that this is similar to the issue I asked about here: https://forum.dlang.org/post/vukxaqprjbyrdpiou...@forum.dlang.org, but I can't figure it out. This compiles: --- private mixin template assign(string op_) { ref auto opOpAssign(string op, this RHS)(RHS rhs) if (op == op_) {

Re: Building LDC runtime for a microcontroller

2020-09-17 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Sep 17, 2020 at 08:40:06PM +, wjoe via Digitalmars-d-learn wrote: > On Thursday, 17 September 2020 at 19:27:41 UTC, Adam D. Ruppe wrote: > > fyi my baby was just born i'll come back to this but it might be a > > day or two [...] "A day or two"??! More likely a month for starters. :-D

Re: Building LDC runtime for a microcontroller

2020-09-17 Thread wjoe via Digitalmars-d-learn
On Thursday, 17 September 2020 at 19:27:41 UTC, Adam D. Ruppe wrote: fyi my baby was just born i'll come back to this but it might be a day or two congratulations! All the best for your family :)

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

2020-09-17 Thread aberba via Digitalmars-d-learn
On Thursday, 17 September 2020 at 16:32:55 UTC, WebFreak001 wrote: On Thursday, 17 September 2020 at 16:00:33 UTC, wjoe wrote: I found this [1] but unfortunately the post this refers to is a dead link and the content, unfortunately, didn't tell me anything that I didn't already find in the docs

Re: Building LDC runtime for a microcontroller

2020-09-17 Thread Adam D. Ruppe via Digitalmars-d-learn
fyi my baby was just born i'll come back to this but it might be a day or two

Re: Building LDC runtime for a microcontroller

2020-09-17 Thread Remi via Digitalmars-d-learn
On Thursday, 17 September 2020 at 09:53:57 UTC, Remi wrote: [snip] My problem here is mostly understanding the __initZ symbol and where it comes from. I mostly want classes and the bare minimum of std like you did for Tetris in WebAssembly for example. My project is OpenGL/SDL2 so there's a l

Re: vibe.d and video files?

2020-09-17 Thread WebFreak001 via Digitalmars-d-learn
On Thursday, 17 September 2020 at 18:29:12 UTC, bauss wrote: Does vibe.d not work properly with ex. mp4 files? I have a consistent issues that it will only play part of video files in the browser. As if it won't "stream" the rest of the video. Is that a problem with vibe.d or is it some conf

vibe.d and video files?

2020-09-17 Thread bauss via Digitalmars-d-learn
Does vibe.d not work properly with ex. mp4 files? I have a consistent issues that it will only play part of video files in the browser. As if it won't "stream" the rest of the video. Is that a problem with vibe.d or is it some configuration that needs to be enabled?

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

2020-09-17 Thread wjoe via Digitalmars-d-learn
On Thursday, 17 September 2020 at 16:32:55 UTC, WebFreak001 wrote: On Thursday, 17 September 2020 at 16:00:33 UTC, wjoe wrote: I found this [1] but unfortunately the post this refers to is a dead link and the content, unfortunately, didn't tell me anything that I didn't already find in the docs

Re: Proper way to exit with specific exit code?

2020-09-17 Thread IGotD- via Digitalmars-d-learn
On Thursday, 17 September 2020 at 14:58:48 UTC, drathier wrote: What's the proper way to exit with a specific exit code? I found a bunch of old threads discussing this, making sure destructors run and the runtime terminates properly, all of which seemingly concluding that it's sad that there i

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

2020-09-17 Thread WebFreak001 via Digitalmars-d-learn
On Thursday, 17 September 2020 at 16:00:33 UTC, wjoe wrote: I found this [1] but unfortunately the post this refers to is a dead link and the content, unfortunately, didn't tell me anything that I didn't already find in the docs. What I can get from the form is the form fields with content, t

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

2020-09-17 Thread wjoe via Digitalmars-d-learn
I found this [1] but unfortunately the post this refers to is a dead link and the content, unfortunately, didn't tell me anything that I didn't already find in the docs. What I can get from the form is the form fields with content, the field name for the file upload and the file name. But the

Re: Proper way to exit with specific exit code?

2020-09-17 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Sep 17, 2020 at 02:58:48PM +, drathier via Digitalmars-d-learn wrote: > What's the proper way to exit with a specific exit code? > > I found a bunch of old threads discussing this, making sure > destructors run and the runtime terminates properly, all of which > seemingly concluding t

Proper way to exit with specific exit code?

2020-09-17 Thread drathier via Digitalmars-d-learn
What's the proper way to exit with a specific exit code? I found a bunch of old threads discussing this, making sure destructors run and the runtime terminates properly, all of which seemingly concluding that it's sad that there isn't a way to do this easily, but hopefully things have changed

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

2020-09-17 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 17 September 2020 at 13:25:08 UTC, Mike Parker wrote: Well, I was already using anonymous enums for compile-time And, I should add, I have *never* seen C enums as an enumerated list of values. I've always seen them as an alternative for #defined constants because they're anonymo

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

2020-09-17 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 17 September 2020 at 13:13:46 UTC, Simen Kjærås wrote: To quote Bill Baxter from way back when (https://forum.dlang.org/post/fjdc4c$2gft$1...@digitalmars.com): > Why does: > final int x = 3; > make any more intuitive sense than: > enum int x = 3; > ? There are these thi

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

2020-09-17 Thread Simen Kjærås via Digitalmars-d-learn
On Thursday, 17 September 2020 at 10:56:28 UTC, Mike Parker wrote: On Thursday, 17 September 2020 at 09:44:20 UTC, claptrap wrote: Seriously how it's implemented is irrelevant. And to be clear, my point wasn't about how it's implemented. My point was that: enum { foo = 10; } and enum foo

Re: What kind of mangling has the LDC2 -X JsonFile "deco" field?

2020-09-17 Thread realhet via Digitalmars-d-learn
On Thursday, 17 September 2020 at 04:01:11 UTC, Adam D. Ruppe wrote: On Thursday, 17 September 2020 at 03:06:45 UTC, realhet wrote: Anyone can help me telling how to decode these please? Just prepend _D4name Thank you very much!

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

2020-09-17 Thread Ola Fosheim Grøstad via Digitalmars-d-learn
On Thursday, 17 September 2020 at 10:56:28 UTC, Mike Parker wrote: Are effectively the same thing, whether it's implemented that way or not. So why on earth would a new keyword be necessary? C++ made enums stricter by "enum class".

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

2020-09-17 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 17 September 2020 at 09:44:20 UTC, claptrap wrote: Seriously how it's implemented is irrelevant. And to be clear, my point wasn't about how it's implemented. My point was that: enum { foo = 10; } and enum foo = 10; Are effectively the same thing, whether it's implemented tha

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

2020-09-17 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 17 September 2020 at 09:44:20 UTC, claptrap wrote: Names are important, principle of least astonishment and all that, pretty much everyone coming to D is going be WTF in learning about that. And if you keep overloading existing keywords with more and more meanings the code gets

Specify dmd or ldc compiler and version in a json dub file?

2020-09-17 Thread Imperatorn via Digitalmars-d-learn
https://forum.dlang.org/post/nnxbwdypwepymgerz...@forum.dlang.org On Tuesday, 8 August 2017 at 09:17:02 UTC, data pulverizer wrote: Hi, I would like to know how to specify dmd or ldc compiler and version in a json dub file. Thanks in advance. https://dub.pm/settings.html

Re: Building LDC runtime for a microcontroller

2020-09-17 Thread Remi via Digitalmars-d-learn
On Wednesday, 16 September 2020 at 18:34:05 UTC, Adam D. Ruppe wrote: On Wednesday, 16 September 2020 at 17:59:41 UTC, Remi wrote: I tried to modify the hello.d example from your blog post. It works without changes but when I tried to do a string concatenation Yeah, concatenation is one of th

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

2020-09-17 Thread claptrap via Digitalmars-d-learn
On Thursday, 17 September 2020 at 01:57:39 UTC, Mike Parker wrote: On Thursday, 17 September 2020 at 00:32:40 UTC, Cecil Ward enum foo is essentially a shortcut for enum { foo }. It’s neither bent out of shape nor twisted. Consider that C++ added the new keyword constexpr for the same thing.

Re: Install multiple executables with DUB

2020-09-17 Thread glis-glis via Digitalmars-d-learn
On Tuesday, 8 September 2020 at 08:41:24 UTC, glis-glis wrote: Following the advice of drug, I moved the "tools" folder from src to the parent directory, added a dependency to "biophysics" with path ".." and build the binaries with "dub build --single tools/..." This works fine, however, n