Re: DDoc generation

2020-09-18 Thread James Blachly via Digitalmars-d-learn
On 9/18/20 9:35 AM, Russel Winder wrote: On Fri, 2020-09-18 at 09:02 -0400, Steven Schveighoffer via Digitalmars-d- learn wrote: […] it ddoc files, and compile those along with your application. https://dlang.org/spec/ddoc.html#using_ddoc_for_other_documentation Any small project examples

Re: Building LDC runtime for a microcontroller

2020-09-18 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 17 September 2020 at 09:53:57 UTC, Remi wrote: My problem here is mostly understanding the __initZ symbol and where it comes from. The compiler generates that when it spits out something that uses TypeInfo, which is a lot of things: ~= and ~ operators on built in arrays, the new

Question about linker errors when using slices

2020-09-18 Thread tspike via Digitalmars-d-learn
I’ve been using D for personal projects for almost a year now and I really love it. I recently ran across a linker error that I’m a little confused by. Consider the following files: platform.d: module platform; import app; struct PlatformData { AppData a; }

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

2020-09-18 Thread aberba via Digitalmars-d-learn
On Friday, 18 September 2020 at 00:07:12 UTC, wjoe wrote: 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

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

2020-09-18 Thread Patrick Schluter via Digitalmars-d-learn
On Wednesday, 16 September 2020 at 00:22:15 UTC, Steven Schveighoffer wrote: On 9/15/20 8:10 PM, James Blachly wrote: On 9/15/20 10:59 AM, Steven Schveighoffer wrote: [...] Steve: It sounds as if the spec is correct but the glyph (codepoint?) range is outdated. If this is the case, it would

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

2020-09-18 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 18 September 2020 at 22:02:07 UTC, aberba wrote: In this case you want to get the file(s) in memory...in the form of bytes (or buffer) and probably set a file size limit. Its all doable through a library but such a library doesn't exist in D yet. At least not that I know of. I

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

2020-09-18 Thread mw via Digitalmars-d-learn
On Friday, 18 September 2020 at 00:07:12 UTC, wjoe wrote: Are there other frameworks besides vibe that can do what I want? Just FYI, there is also: https://code.dlang.org/packages/hunt-framework I never used myself, you need to investigate.

Re: Why is dtor called for lazy parameter?

2020-09-18 Thread Simen Kjærås via Digitalmars-d-learn
On Friday, 18 September 2020 at 14:14:31 UTC, Andrey Zherikov wrote: It seems that dtor is called at exit from lazy delegate, not at exit form create(): == create() .do_something() .do_lazy() .do_something(); == Output: == -> void test.main() -> test.do_lazy(lazy S

Re: How to convert member function to free function?

2020-09-18 Thread Andrey Zherikov via Digitalmars-d-learn
On Friday, 18 September 2020 at 18:20:41 UTC, Andrey Zherikov wrote: How can I rewrite foo() function as a free-function that won't cause struct copying? I found solution: struct S { int i = -1; this(int n) {i=n;writeln(," ",i," ",__PRETTY_FUNCTION__);} this(ref return

How to convert member function to free function?

2020-09-18 Thread Andrey Zherikov via Digitalmars-d-learn
How can I rewrite foo() function as a free-function that won't cause struct copying? My simplified code is: struct S { ref S foo() return { return this; } } void main() { S().foo().foo().foo(); } If I write it like "auto foo(S s) { return s; }" then

Re: How to convert member function to free function?

2020-09-18 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Sep 18, 2020 at 06:20:41PM +, Andrey Zherikov via Digitalmars-d-learn wrote: > How can I rewrite foo() function as a free-function that won't cause > struct copying? My simplified code is: > > struct S > { > ref S foo() return > { > return this; > } > } >

Re: How to convert member function to free function?

2020-09-18 Thread Andrey Zherikov via Digitalmars-d-learn
On Friday, 18 September 2020 at 18:43:38 UTC, H. S. Teoh wrote: Why can't you return by ref, which would also avoid the copying? ref S foo(return ref S s) { return s; } Compiler errors out: onlineapp.d(9): Error: function onlineapp.foo(return ref S s) is not callable using argument

Re: Tuple poilerplate code

2020-09-18 Thread JG via Digitalmars-d-learn
On Wednesday, 2 September 2020 at 03:52:55 UTC, JG wrote: Thank you all for the interesting suggestions. Still thinking about this from time to time. Other than the suggestions given, this is what I have been playing around with. - import std.stdio; import

Re: Type inference for constructors

2020-09-18 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

Re: Building LDC runtime for a microcontroller

2020-09-18 Thread Remi 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 Oh probably most unexpected answer! Congratulations! Had 4 weeks myself, take care of your family, everything else can wait ;)

Re: Building LDC runtime for a microcontroller

2020-09-18 Thread Dylan Graham via Digitalmars-d-learn
On Monday, 7 September 2020 at 19:12:59 UTC, aberba wrote: On Monday, 7 September 2020 at 16:18:00 UTC, IGotD- wrote: On Monday, 7 September 2020 at 15:23:28 UTC, Severin Teona wrote: [...] Use betterC, which is much better suited for microcontrollers than the full D. The disadvantage is

Re: Why is dtor called for lazy parameter?

2020-09-18 Thread ikod via Digitalmars-d-learn
On Friday, 18 September 2020 at 10:43:47 UTC, Andrey Zherikov wrote: I have this code: == class S ... auto create() { writeln("-> ",__PRETTY_FUNCTION__); scope(exit) writeln("<- ",__PRETTY_FUNCTION__); return scoped!S(1); } If you replace this line with "return new

DDoc generation

2020-09-18 Thread Russel Winder via Digitalmars-d-learn
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 generated documentation. -- Russel.

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

2020-09-18 Thread wjoe via Digitalmars-d-learn
On Friday, 18 September 2020 at 11:44:39 UTC, Atwork wrote: On Friday, 18 September 2020 at 00:07:12 UTC, wjoe wrote: And if not, how is data processed with a 10mb file upload followed by a few number fields ? It needs to read all of the file data to get to the other data fields, doesn't it ?

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

2020-09-18 Thread Mike Parker via Digitalmars-d-learn
On Friday, 18 September 2020 at 11:38:14 UTC, 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

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

2020-09-18 Thread Danny Arends via Digitalmars-d-learn
On Friday, 18 September 2020 at 11:38:14 UTC, 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

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: Proper way to exit with specific exit code?

2020-09-18 Thread IGotD- via Digitalmars-d-learn
On Friday, 18 September 2020 at 05:02:21 UTC, H. S. Teoh wrote: That's the obvious solution, except that actually implementing it is not so simple. When you have multiple threads listening for each other and/or doing work, there is no 100% guaranteed way of cleanly shutting all of them down

Re: Type inference for constructors

2020-09-18 Thread data pulverizer via Digitalmars-d-learn
On Friday, 18 September 2020 at 06:43:12 UTC, Simen Kjærås wrote: On Friday, 18 September 2020 at 05:43:56 UTC, data pulverizer That's issue 1997: https://issues.dlang.org/show_bug.cgi?id=1997 D's templates are turing complete, and there may be arbitrary amounts of logic obscuring the mapping

Re: Why is dtor called for lazy parameter?

2020-09-18 Thread Simen Kjærås via Digitalmars-d-learn
On Friday, 18 September 2020 at 10:43:47 UTC, Andrey Zherikov wrote: Why is dtor called before returning from do_lazy function - see (1)? It seems cause uninitialized parameter in do_something call after it in (2)-(3). As ikod mentions, it's because of scoped!S. As for why it does this,

Re: Why is dtor called for lazy parameter?

2020-09-18 Thread Andrey Zherikov via Digitalmars-d-learn
On Friday, 18 September 2020 at 10:54:41 UTC, ikod wrote: On Friday, 18 September 2020 at 10:43:47 UTC, Andrey Zherikov wrote: I have this code: == class S ... auto create() { writeln("-> ",__PRETTY_FUNCTION__); scope(exit) writeln("<- ",__PRETTY_FUNCTION__); return

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

2020-09-18 Thread claptrap via Digitalmars-d-learn
On Friday, 18 September 2020 at 02:49:30 UTC, Mike Parker wrote: 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

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

2020-09-18 Thread wjoe via Digitalmars-d-learn
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 related to external dependencies.

Re: Why is dtor called for lazy parameter?

2020-09-18 Thread Andrey Zherikov via Digitalmars-d-learn
On Friday, 18 September 2020 at 11:31:39 UTC, Simen Kjærås wrote: On Friday, 18 September 2020 at 10:43:47 UTC, Andrey Zherikov wrote: Why is dtor called before returning from do_lazy function - see (1)? It seems cause uninitialized parameter in do_something call after it in (2)-(3). As ikod

Why is dtor called for lazy parameter?

2020-09-18 Thread Andrey Zherikov via Digitalmars-d-learn
I have this code: == class S { int i = -1; this(int n) { i = n; writeln(i," ",__PRETTY_FUNCTION__); } ~this() { writeln(i," ",__PRETTY_FUNCTION__); } } auto create() { writeln("-> ",__PRETTY_FUNCTION__); scope(exit) writeln("<- ",__PRETTY_FUNCTION__); return

DDoc Web page

2020-09-18 Thread Russel Winder via Digitalmars-d-learn
I see that: https://dlang.org/spec/ddoc.html refers to: https://docs.oracle.com/javase/7/docs/technotes/guides/javadoc/index.html which is really rather ancient and definitely out of date. Should change this to: https://docs.oracle.com/en/java/javase/15/javadoc/index.html -- Russel.

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

2020-09-18 Thread Atwork via Digitalmars-d-learn
On Friday, 18 September 2020 at 00:07:12 UTC, wjoe wrote: And if not, how is data processed with a 10mb file upload followed by a few number fields ? It needs to read all of the file data to get to the other data fields, doesn't it ? Yes and no

dub: Is it possible to extend or specialize configurations ?

2020-09-18 Thread wjoe via Digitalmars-d-learn
configuration "app" { versions "CLI" target "executable" ... } configuration "guiapp" : "app" { versions "GUI" sourceFiles "source/gui.d" } The guiapp should basically inherit the "app" configuration and extend/override whatever else is needed/different.

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

2020-09-18 Thread wjoe via Digitalmars-d-learn
On Friday, 18 September 2020 at 12:03:45 UTC, Mike Parker wrote: On Friday, 18 September 2020 at 11:38:14 UTC, wjoe wrote: Something like this: configuration "lib" { targetType "dynamicLibrary" sourceDir "source/lib/" } configuration "app" { targetType "executable" sourceFiles

Re: Why is dtor called for lazy parameter?

2020-09-18 Thread Simen Kjærås via Digitalmars-d-learn
On Friday, 18 September 2020 at 12:32:49 UTC, Andrey Zherikov wrote: == The output is: == -> void test.main() -> test.do_lazy(lazy S s) -> test.create() 1 S test.S.this(int n) <- test.create() 1 void test.S.~this() ===-1 (2) <- test.do_lazy(lazy S s) -> 1703096

Re: Why is dtor called for lazy parameter?

2020-09-18 Thread drug via Digitalmars-d-learn
On 9/18/20 4:30 PM, drug wrote: Can't you put a var on the stack? ``` auto instance = create(); instance     .do_lazy()     .do_something(); ``` Ah, I totally missed your point. Now I see you can't...

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: dub: Is it possible to have a library target and depend on it in the same dub config?

2020-09-18 Thread wjoe via Digitalmars-d-learn
On Friday, 18 September 2020 at 14:15:27 UTC, Steven Schveighoffer wrote: On 9/18/20 7:38 AM, wjoe wrote: [...] There are other options. for instance dub (the project) has a library and an application. the config looks like this: configuration "application" { targetType

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: Why is BOM required to use unicode in tokens?

2020-09-18 Thread GK via Digitalmars-d-learn
On Tuesday, 15 September 2020 at 16:23:01 UTC, Jon Degenhardt wrote: # The 'Ш' and 'ä' characters are fine. $ echo $'import std.stdio; void Шä() { writeln("Hello World!"); } void main() { Шä(); }' | dmd -run - Hello World! # But not '∂' $ echo $'import std.stdio; void x∂() { writeln("Hello

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: Why is dtor called for lazy parameter?

2020-09-18 Thread drug via Digitalmars-d-learn
Can't you put a var on the stack? ``` auto instance = create(); instance .do_lazy() .do_something(); ```

Re: DDoc generation

2020-09-18 Thread Russel Winder via Digitalmars-d-learn
On Fri, 2020-09-18 at 09:02 -0400, Steven Schveighoffer via Digitalmars-d- learn wrote: […] > > it ddoc files, and compile those along with your > application. > > https://dlang.org/spec/ddoc.html#using_ddoc_for_other_documentation > Any small project examples anywhere? -- Russel.

Re: Neater "not version (...)" ?

2020-09-18 Thread Jacob Carlborg via Digitalmars-d-learn
On 2020-09-16 21:04, Vladimirs Nordholm wrote: Ah, I guess it boils down to this then. Doesn't really make it "neater", but thank you for the tip! You only need to declare the enums ones. -- /Jacob Carlborg

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

2020-09-18 Thread Mike Parker via Digitalmars-d-learn
On Friday, 18 September 2020 at 12:28:30 UTC, wjoe wrote: 2 issues though. - It doesn't build the library automatically, and You'll have to invoke dub once for each config. Just slap both commands in a script. - Linking fails because error: ld: cannot find -llib Built it manually via dub

Re: get element index when using each!(x)

2020-09-18 Thread Jacob Carlborg via Digitalmars-d-learn
On 2020-09-17 05:16, Paul Backus wrote: Worth knowing that the tuples you get from enumerate actually have named members, so you can write:     s.enumerate.each!(x => writeln(x.index, ":", x.value)); It actually works out of the box for `each`: s.each!((index, value) => writeln(index,

Re: Proper way to exit with specific exit code?

2020-09-18 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Sep 18, 2020 at 08:20:59AM +, IGotD- via Digitalmars-d-learn wrote: > On Friday, 18 September 2020 at 05:02:21 UTC, H. S. Teoh wrote: > > > > That's the obvious solution, except that actually implementing it is not > > so simple. When you have multiple threads listening for each

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

2020-09-18 Thread wjoe via Digitalmars-d-learn
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 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.

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

2020-09-18 Thread wjoe via Digitalmars-d-learn
On Friday, 18 September 2020 at 12:39:43 UTC, Steven Schveighoffer wrote: On 9/17/20 8:07 PM, wjoe wrote: [...] See the code here: https://github.com/vibe-d/vibe.d/blob/ebebfa827f568cc9bced4bec2b66edc043a8adf7/inet/vibe/inet/webform.d#L311 [...] No, not at the moment. Which is why I was

Re: Why is dtor called for lazy parameter?

2020-09-18 Thread Andrey Zherikov via Digitalmars-d-learn
On Friday, 18 September 2020 at 13:28:39 UTC, Simen Kjærås wrote: Indeed. As we can see from the output, first do_lazy() is called from test.main, then create() is called (this happens inside do_lazy, as s is lazy). When create() returns, the scoped!S you created goes out of scope and is

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

2020-09-18 Thread wjoe via Digitalmars-d-learn
On Friday, 18 September 2020 at 14:01:55 UTC, Mike Parker wrote: On Friday, 18 September 2020 at 12:28:30 UTC, wjoe wrote: 2 issues though. - It doesn't build the library automatically, and You'll have to invoke dub once for each config. Just slap both commands in a script. - Linking