Re: Mac IDE with Intellisense

2015-09-27 Thread Johannes Loher via Digitalmars-d-learn
On Saturday, 26 September 2015 at 18:27:52 UTC, Mike McKee wrote: On Saturday, 26 September 2015 at 10:31:13 UTC, wobbles wrote: Have you installed dkit for sublime? As in? https://github.com/yazd/DKit Looks like it's alpha and doesn't run on Mac? No homebrew install? I'm using this and

problem with std.range.choose()

2016-02-16 Thread Johannes Loher via Digitalmars-d-learn
Hello, I have a problem with using std.range.choose(): When using std.range.choose() on a range R, for which hasElaborateCopyConstructor!R is true, then a postblit for the result of std.range.choose() is created, which includes a call to R.__postblit(). However, hasElaborateCopyConstructor!R

Re: problem with std.range.choose()

2016-02-20 Thread Johannes Loher via Digitalmars-d-learn
On Wednesday, 17 February 2016 at 01:35:34 UTC, Johannes Loher wrote: Hello, I have a problem with using std.range.choose(): When using std.range.choose() on a range R, for which hasElaborateCopyConstructor!R is true, then a postblit for the result of std.range.choose() is created, which

Question regarding Base64 decoding

2016-07-31 Thread Johannes Loher via Digitalmars-d-learn
Currently, the function Base64.decode for decoding char[] to ubyte[] has an in contract, that should ensure that the supplied buffer is large enough. However, it uses the function decodeLength, which does not give the accurate decodeLength, but instead an upper bound (decodeLength can be up to 2

Re: Converting int to dchar?

2016-07-31 Thread Johannes Loher via Digitalmars-d-learn
Am 31.07.2016 um 23:46 schrieb Seb: > On Sunday, 31 July 2016 at 21:31:52 UTC, Darren wrote: >> Hey, all. >> >> I'm pretty much a programming novice, so I hope you can bear with me. >> Does anyone know how I can change an int into a char equivalent? >> >> e.g. >> int i = 5; >> dchar value; >>

Re: Initializing static array with contents of (static and dynamic) arrays

2016-07-05 Thread Johannes Loher via Digitalmars-d-learn
Am 05.07.2016 um 00:41 schrieb Rene Zwanenburg: > On Monday, 4 July 2016 at 19:22:52 UTC, Johannes Loher wrote: >> This looks really nice, but I have several occurences of this, with >> different arrays (and lengths), so i would need to create several of >> those structs. But it looks really clean

Re: Initializing static array with contents of (static and dynamic) arrays

2016-07-05 Thread Johannes Loher via Digitalmars-d-learn
Am 05.07.2016 um 17:12 schrieb Johannes Loher: > Am 05.07.2016 um 16:39 schrieb Rene Zwanenburg: >> On Tuesday, 5 July 2016 at 12:34:20 UTC, Johannes Loher wrote: >>> I tried this, but it does not work correctly with slices. >> >> The length of a slice is a runtime value, which is why it can't be

Re: Initializing static array with contents of (static and dynamic) arrays

2016-07-05 Thread Johannes Loher via Digitalmars-d-learn
Am 05.07.2016 um 17:22 schrieb Marc Schütz: > auto concat(T : E[n], E, size_t n)(const E[][] args...) @nogc > { > size_t offset = 0; > T result = void; > foreach(arr; args) { > result[offset .. offset+arr.length] = arr; > offset += arr.length; > } >

Re: Initializing static array with contents of (static and dynamic) arrays

2016-07-05 Thread Johannes Loher via Digitalmars-d-learn
Am 05.07.2016 um 16:39 schrieb Rene Zwanenburg: > On Tuesday, 5 July 2016 at 12:34:20 UTC, Johannes Loher wrote: >> I tried this, but it does not work correctly with slices. > > The length of a slice is a runtime value, which is why it can't be used > to set static array size. What were you

Initializing static array with contents of (static and dynamic) arrays

2016-07-04 Thread Johannes Loher via Digitalmars-d-learn
In a project I am currently working on, I have lot's of code of the following form: static immutable ubyte[4] sigma0 = [101, 120, 112, 97]; static immutable ubyte[4] sigma1 = [110, 100, 32, 51]; static immutable ubyte[4] sigma2 = [ 50, 45, 98, 121]; static immutable ubyte[4] sigma3 = [116,

Re: Initializing static array with contents of (static and dynamic) arrays

2016-07-04 Thread Johannes Loher via Digitalmars-d-learn
Am 04.07.2016 um 20:33 schrieb Ali Çehreli: > On 07/04/2016 07:31 AM, Johannes Loher wrote: >> In a project I am currently working on, I have lot's of code of the >> following form: >> >> static immutable ubyte[4] sigma0 = [101, 120, 112, 97]; >> static immutable ubyte[4] sigma1 = [110, 100, 32,

Re: Initializing static array with contents of (static and dynamic) arrays

2016-07-04 Thread Johannes Loher via Digitalmars-d-learn
Am 04.07.2016 um 19:24 schrieb ZombineDev: > On Monday, 4 July 2016 at 14:31:41 UTC, Johannes Loher wrote: >> In a project I am currently working on, I have lot's of code of the >> following form: >> >> static immutable ubyte[4] sigma0 = [101, 120, 112, 97]; static >> immutable ubyte[4] sigma1 =

Re: Question regarding Base64 decoding

2016-08-08 Thread Johannes Loher via Digitalmars-d-learn
Am 02.08.2016 um 00:47 schrieb Seb: > On Monday, 1 August 2016 at 08:53:30 UTC, Kagamin wrote: >> A bug. > > ... which should be filled at Bugzilla and/or fixed. Thanks! :) I created a pullrequest: https://github.com/dlang/phobos/pull/4720

Re: Getting the superclass of a type?

2016-09-05 Thread Johannes Loher via Digitalmars-d-learn
Am 05.09.2016 um 17:43 schrieb Lodovico Giaretta: > On Monday, 5 September 2016 at 15:20:10 UTC, pineapple wrote: >> I'd like to be able to write something like this, but I haven't been >> able to find anything in the docs >> >> class Base{} >> class Sub: Base{} >> static

forwarding build type to dependencies with dub

2016-09-07 Thread Johannes Loher via Digitalmars-d-learn
Is it possible to forward the build type to the dependencies of a dub project? For example, if I build my project with dub build -b unittest is it possible to make dub build the dependencies of my project also with the unittest build type? Even better would be a way to specify for which

vibed.web.auth framework and redirection

2017-08-07 Thread Johannes Loher via Digitalmars-d-learn
Hello I'd like to use the vibed.web.auth framework for authentication in my vibe.d app. If a user is not authorized to access a certain page, he should be redirected to another page (a custom error page for example, or the login page in my case). At the moment, I'm using the following

Re: Manually calling postblots recursively

2017-06-22 Thread Johannes Loher via Digitalmars-d-learn
On Sunday, 18 June 2017 at 14:16:03 UTC, Basile B. wrote: On Sunday, 18 June 2017 at 09:41:01 UTC, Johannes Loher wrote: Hey, I'm trying to work on https://issues.dlang.org/show_bug.cgi?id=15708 so I decided it might be interesting to find a way to (recursively) call all postblits that belong

Manually calling postblots recursively

2017-06-18 Thread Johannes Loher via Digitalmars-d-learn
Hey, I'm trying to work on https://issues.dlang.org/show_bug.cgi?id=15708 so I decided it might be interesting to find a way to (recursively) call all postblits that belong to certain struct or static array. This is what I came up with so far: import std.traits; void callPostblits(S)(ref S

Re: Request scoped information in Vibe.d

2018-07-29 Thread Johannes Loher via Digitalmars-d-learn
On Sunday, 22 July 2018 at 18:21:21 UTC, Venkat wrote: On Sunday, 22 July 2018 at 08:43:23 UTC, Johannes Loher wrote: On Sunday, 22 July 2018 at 06:21:40 UTC, Venkat wrote: [...] What is your usecase? If you simply want to pass a variable to a diet template, just pass it as a template

Question about template argument matching with alias this

2018-07-29 Thread Johannes Loher via Digitalmars-d-learn
I have a question about template argument matching in combination with implicit conversion and alias this. Consider the following code: interface SomeInterface { } class SomeClass : SomeInterface { } struct SomeStruct { SomeClass someClass; alias someClass this; } template

Re: Question about template argument matching with alias this

2018-07-29 Thread Johannes Loher via Digitalmars-d-learn
On Sunday, 29 July 2018 at 20:51:45 UTC, Alex wrote: Do you mean something like this? [...] Yeah, I know that it possible to implement the template like this, but that is not the point here. I would like to know why it does not work the way I described it. To me it seems very strange, that

Re: vibe.d: Finding out if currently in webinterface request

2018-08-10 Thread Johannes Loher via Digitalmars-d-learn
On Friday, 10 August 2018 at 09:33:34 UTC, Timoses wrote: On Thursday, 9 August 2018 at 21:59:24 UTC, Johannes Loher wrote: I already posted this in the vibe.d forums (https://forum.rejectedsoftware.com/groups/rejectedsoftware.vibed/thread/58891/), but it seems, there is not a lot of activity

vibe.d: Finding out if currently in webinterface request

2018-08-09 Thread Johannes Loher via Digitalmars-d-learn
I already posted this in the vibe.d forums (https://forum.rejectedsoftware.com/groups/rejectedsoftware.vibed/thread/58891/), but it seems, there is not a lot of activity over there, so I am cross posting this here: Is there a way to find out, if we are currently in a webinterface request? My

Re: Request scoped information in Vibe.d

2018-07-22 Thread Johannes Loher via Digitalmars-d-learn
On Sunday, 22 July 2018 at 06:21:40 UTC, Venkat wrote: How do I make variables available to diet templates ? Java has request.setAttribute. Vibe.d's HTTPServerRequest has params and queryString. But by the looks of it, neither one of them is created for the purpose of temporary storage in the

making a struct an inputRange with free functions

2018-04-16 Thread Johannes Loher via Digitalmars-d-learn
Is there a way to do this? Here is a naive implementation: https://run.dlang.io/is/JKvL80 . It does not pass `isInputRange` (I think, because the free functions are not visible in the scope of `isInputRange`). Trying to iterate over it with a foreach loop results in a compile error: Error:

Re: making a struct an inputRange with free functions

2018-04-16 Thread Johannes Loher via Digitalmars-d-learn
Am 16.04.2018 um 21:27 schrieb Jonathan M Davis: > On Monday, April 16, 2018 21:10:03 Johannes Loher via Digitalmars-d-learn > wrote: >> Is there a way to do this? Here is a naive implementation: >> https://run.dlang.io/is/JKvL80 . >> >> It does not pass `isInputRan

Re: VibeD Rest Interface Generator

2018-03-03 Thread Johannes Loher via Digitalmars-d-learn
On Saturday, 3 March 2018 at 02:32:11 UTC, Mario wrote: So I've been learning D since the day 11 (I posted for first time here) and now I've decided to try Vibe.D to make my company API. The fact is that I've achieved to do it (according to the provided code) and it works! But it shows a

Re: cas and interfaces

2018-12-25 Thread Johannes Loher via Digitalmars-d-learn
On Monday, 24 December 2018 at 11:23:32 UTC, Johan Engelen wrote: On Sunday, 23 December 2018 at 14:07:04 UTC, Johannes Loher wrote: [...] The types of the 2nd and 3rd arguments of `cas` do not have to be the same, and aren't in your case. I think what's happening is that you are

cas and interfaces

2018-12-23 Thread Johannes Loher via Digitalmars-d-learn
I recently played around with atomic operations. While doing so, I noticed a problem with the interaction of interfaces and cas. Consider the following program: ``` import core.atomic; import std.stdio; interface TestInterface { } class TestClass : TestInterface { } void main() { shared

typeof function literals which define the types of its parameters but do not give their parameters names

2018-12-26 Thread Johannes Loher via Digitalmars-d-learn
Hey all, I am a bit confused about the inferred types of function literals which do not name their parameters (something like `(int) {}`). The confusion arises from the fact that the inferred type sometimes is `void` (might be the case, because the function literal is inferred to be a

Re: typeof function literals which define the types of its parameters but do not give their parameters names

2018-12-27 Thread Johannes Loher via Digitalmars-d-learn
On Thursday, 27 December 2018 at 04:27:03 UTC, Steven Schveighoffer wrote: On 12/26/18 10:52 PM, Johannes Loher wrote: Hey all, I am a bit confused about the inferred types of function literals which do not name their parameters (something like `(int) {}`). The confusion arises from the fact

Re: typeof function literals which define the types of its parameters but do not give their parameters names

2018-12-27 Thread Johannes Loher via Digitalmars-d-learn
On Thursday, 27 December 2018 at 08:53:30 UTC, Johannes Loher wrote: On Thursday, 27 December 2018 at 04:27:03 UTC, Steven Schveighoffer wrote: [...] As a side note: During last DConf I talked to Walter and Andrei about the fact that `typeof(SomeTemplate) == void` and they agreed that it

Re: Why do ints defined in template mixins have garbage values?

2018-12-12 Thread Johannes Loher via Digitalmars-d-learn
On Tuesday, 11 December 2018 at 21:09:55 UTC, Johannes Riecken wrote: Code: import std.conv; import std.stdio; mixin template genInts() { enum arr = [0,1]; static foreach (t; arr) { mixin("int i" ~ to!string(t) ~ " = 5;"); } } void main() { mixin genInts!(); writeln(i0);

Re: Understanding SIGSEGV issues

2019-01-09 Thread Johannes Loher via Digitalmars-d-learn
On Wednesday, 9 January 2019 at 16:48:47 UTC, Russel Winder wrote: On Tue, 2019-01-08 at 11:51 +, Nicholas Wilson via Digitalmars-d-learn wrote: [...] […] [...] [...] If debugger integration is that important to you, you might want to try out visual studio code with the corresponding

Re: Aliasing a mixin (or alternative ways to profile a scope)

2019-03-07 Thread Johannes Loher via Digitalmars-d-learn
Am 07.03.19 um 22:50 schrieb Johannes Loher: > [...] As a small addition, if you always want to pass the function name as a parameter, you can simplify this to the following: ``` enum profile_scope(string name = __FUNCTION__) = "import core.stdc.stdio : printf; printf(\"" ~ name ~ "\n\");

Re: 2 class issues

2019-03-07 Thread Johannes Loher via Digitalmars-d-learn
Am 07.03.19 um 11:38 schrieb spir: > Hello, > > First, I am not very experimented with the combination of static lang > (alloc & typing) and OO (class-based). I'm implementing a library for > lexical analysis (lexing), with 2 minor issues: > > -1- How to enforce that subclasses implement given

Re: Aliasing a mixin (or alternative ways to profile a scope)

2019-03-07 Thread Johannes Loher via Digitalmars-d-learn
Am 07.03.19 um 21:07 schrieb Simon: > Hello, > > I am currently porting the frontend of my instrumenting profiler to D. > It features a C++-makro that profiles the time between entering and > leaving a scope (achieved with con-/destructors in C++). Since D has > scopeguards, I hoped to achieve

Re: Aliasing a mixin (or alternative ways to profile a scope)

2019-03-07 Thread Johannes Loher via Digitalmars-d-learn
Am 07.03.19 um 22:21 schrieb Simon: > > Is there a way to achieve this while compiling with -betterC? I use a > custom string struct right now, and your version needs TypeInfo, > concatening using ~ needs the garbage collector. I have the feeling D is > really not agreeing with the way I want to

Re: Should I prefix package names with the name of my program?

2019-01-29 Thread Johannes Loher via Digitalmars-d-learn
Am 28.01.19 um 18:29 schrieb H. S. Teoh: > On Mon, Jan 28, 2019 at 04:59:22PM +, Victor Porton via > Digitalmars-d-learn wrote: >> Should I prefix all module names with `xmlboiler.` (where XML Boiler >> is the name of my program). These packages are expected to be used >> internally by my

Re: How to mixin finction name?

2019-04-14 Thread Johannes Loher via Digitalmars-d-learn
Am 14.04.19 um 15:22 schrieb Adam D. Ruppe: > [...] > Though, I'd point out the mixin code doesn't have to be too ugly. > Consider this: > > void main() > { >     enum letters = ['A', 'B', 'C']; > >     static foreach(ch; letters) >     { >     mixin(q{ >     void print}~ch~q{(int i) { >

Re: Function parameters UDAs

2019-06-10 Thread Johannes Loher via Digitalmars-d-learn
On Wednesday, 14 November 2018 at 18:05:55 UTC, Adam D. Ruppe wrote: On Wednesday, 14 November 2018 at 16:28:19 UTC, Radu wrote: Looks like that there is no easy way to extract a function parameters UDA list. Indeed, the only way I can find is kinda crazy: --- void foo(int f, @("test")

Re: Why after writeln the binaryHeap become empty?

2019-06-18 Thread Johannes Loher via Digitalmars-d-learn
Am 18.06.19 um 17:45 schrieb lili: > Hi Guys: >    see this code > ~~~ >     int[] ar = [1,2,3,4,52,34,22]; >     auto h = heapify(ar); >     assert(h.length() == ar.length); >     writeln("h:",h); >     assert(h.empty()); > ~~~ > dmd v2.086.0  run all assert passed. Why? The result of heapify is

Re: Meson build system user learning D.

2019-05-19 Thread Johannes Loher via Digitalmars-d-learn
Am 18.05.19 um 08:20 schrieb Mike Brockus: > Hello there this is your hometown Meson build system user here just > happen to have a > question related to unit testing in D. > > So is there a way to run the unit-test in the test main as a costume > test runner in > "test/test.d", and run the

Re: Meson build system user learning D.

2019-05-20 Thread Johannes Loher via Digitalmars-d-learn
On Sunday, 19 May 2019 at 16:47:39 UTC, Mike Brockus wrote: On Sunday, 19 May 2019 at 07:46:11 UTC, Johannes Loher wrote: Am 18.05.19 um 08:20 schrieb Mike Brockus: [...] Hey there, I already tried to answer your questions on reddit. You can post links here by simply pasting the URL (the

Re: How should I sort a doubly linked list the D way?

2019-08-13 Thread Johannes Loher via Digitalmars-d-learn
Am 13.08.19 um 11:48 schrieb Mirjam Akkersdijk: > Hello there, > If I had a DLL, how would I sort it judging by the node contents, the D > way? > > In C if I were to sort a piece of malloc'd memory pointing to node > pointers, I would write my compare function and let qsort sort it out. > In D, I

Re: Throwing from a lambda isn't supported by the compiler

2019-09-09 Thread Johannes Loher via Digitalmars-d-learn
On Monday, 9 September 2019 at 10:46:10 UTC, Dennis wrote: Such a shame it got rejected in favor of ugly 'no return' annotations [...] This is incorrect. It was rejected because the proposal was not solid enough. While it is true that a lot of people seemed to prefer an annotation based

Why is Throwable.TraceInfo.toString not @safe?

2019-07-21 Thread Johannes Loher via Digitalmars-d-learn
I'd like to log stacktraces of caught exceptions in an @safe manner. However, Throwable.TraceInfo.toString is not @safe (or @trusted), so this is not possible. Why is it not @safe? Can it be @trusted? Thanks for your help!

Re: Why is Throwable.TraceInfo.toString not @safe?

2019-07-22 Thread Johannes Loher via Digitalmars-d-learn
Am 22.07.19 um 20:38 schrieb Jonathan M Davis: > On Monday, July 22, 2019 1:29:21 AM MDT Johannes Loher via Digitalmars-d- > learn wrote: >> Am 22.07.19 um 05:16 schrieb Paul Backus: >>> On Sunday, 21 July 2019 at 18:03:33 UTC, Johannes Loher wrote: >>>> I'd

Re: Why is Throwable.TraceInfo.toString not @safe?

2019-07-22 Thread Johannes Loher via Digitalmars-d-learn
Am 22.07.19 um 05:16 schrieb Paul Backus: > On Sunday, 21 July 2019 at 18:03:33 UTC, Johannes Loher wrote: >> I'd like to log stacktraces of caught exceptions in an @safe manner. >> However, Throwable.TraceInfo.toString is not @safe (or @trusted), so >> this is not possible. Why is it not @safe?

Re: Unexpectedly nice case of auto return type

2019-12-06 Thread Johannes Loher via Digitalmars-d-learn
On Tuesday, 3 December 2019 at 10:06:22 UTC, Mike Parker wrote: On Tuesday, 3 December 2019 at 10:03:22 UTC, Basile B. wrote: That's interesting details of D developement. Since you reply to the first message I think you have not followed but in the last reply I told that maybe we should be

Re: What's the best way to find out which exceptions may be thrown ?

2020-05-27 Thread Johannes Loher via Digitalmars-d-learn
Am 27.05.20 um 12:30 schrieb wjoe: > > Could you please elaborate why checked exceptions are more annoying? > > The only exposure to checked exceptions I had was with Java and I always > liked and appreciated them. > It's super annoying the fiddle around with catch(Exception) all over the >

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

2020-05-26 Thread Johannes Loher via Digitalmars-d-learn
Am 26.05.20 um 16:17 schrieb Vinod K Chandran: > On Tuesday, 26 May 2020 at 13:48:52 UTC, ag0aep6g wrote: >> On 26.05.20 15:43, Vinod K Chandran wrote: >>> So far now, two solutions are very clear for this problem. >>> 1. As per John Chapman's suggestion - use >>> cast(DWORD_PTR)cast(void*)this).

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

2020-05-26 Thread Johannes Loher via Digitalmars-d-learn
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 pointer like in C++. So I think that writing

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

2020-05-26 Thread Johannes Loher via Digitalmars-d-learn
On Tuesday, 26 May 2020 at 12:08:29 UTC, Johannes Loher wrote: [...] Small correction: I said that this is an lvalue and that you cannot take the address of lvalues. Of course that is incorrect, I meant to say that rvalues (this is an rvalue and you cannot take the address of rvalues).

Re: A custom name for variables

2020-05-28 Thread Johannes Loher via Digitalmars-d-learn
On Thursday, 28 May 2020 at 20:26:55 UTC, 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 } Could you help me with that? Do you want

Re: Determining @trusted-status

2020-05-28 Thread Johannes Loher via Digitalmars-d-learn
On Friday, 29 May 2020 at 00:09:56 UTC, 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

Re: how to achieve C's Token Pasting (##) Operator to generate variable name in D?

2020-05-30 Thread Johannes Loher via Digitalmars-d-learn
On Saturday, 30 May 2020 at 23:39:31 UTC, mw wrote: On Saturday, 30 May 2020 at 22:21:14 UTC, Paul Backus wrote: [...] Thank you all for the reply. I hate to write boilerplate code: [...] import std.stdio : writeln; mixin template f(T, string name, T value = T.init) { mixin("T _" ~

Re: I want Sublime 3 D auto import !

2020-06-01 Thread Johannes Loher via Digitalmars-d-learn
On Monday, 1 June 2020 at 16:18:44 UTC, Виталий Фадеев wrote: I want Sublime D auto import ! When typing code like this: class Uno : IStylable { // } I want will be auto added "import IStylable" at begin of file. Like this: import ui.istylable : IStylable;

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

2020-05-27 Thread Johannes Loher via Digitalmars-d-learn
On Tuesday, 26 May 2020 at 22:23:19 UTC, bauss wrote: On Tuesday, 26 May 2020 at 12:08:29 UTC, Johannes Loher wrote: [...] You can just do this to get around it: auto button = this; log(); True, somebody else posted the same idea already. But as explained, it doesn't do

isInputRange not satisfied even if all individual conditions are satisfied

2020-06-26 Thread Johannes Loher via Digitalmars-d-learn
Recently, I read about problems regarding the API design of ranges (not being able to make them const, differences between class and struct based ranges etc.). One of the issues that came up what the fact that sometimes it is useful to use the class wrappers `InputRangeObject` etc. if you need to

Re: isInputRange not satisfied even if all individual conditions are satisfied

2020-06-26 Thread Johannes Loher via Digitalmars-d-learn
Am 26.06.20 um 15:35 schrieb ag0aep6g: > `isInputRange!R` fails because it has no knowledge of your free `empty` > function. Without `empty`, `R` is obviously not a range. Ah, OK, that makes sense. It's kind of sad though because it really limits the extensibility of existing types with UFCS. Do

Why is it possible to call non-const member functions of rvalues but a compile error to modify members or rvalues directly?

2020-06-13 Thread Johannes Loher via Digitalmars-d-learn
Consider the following example: ``` struct A { auto a(int _a) { return this._a = _a; } int _a = 0; } void main() { static assert(!__traits(compiles, { A()._a = 2; })); static assert(__traits(compiles, { A().a(2); })); } ``` (https://run.dlang.io/is/GkmpA8) Why

Re: Why is it possible to call non-const member functions of rvalues but a compile error to modify members or rvalues directly?

2020-06-14 Thread Johannes Loher via Digitalmars-d-learn
On Saturday, 13 June 2020 at 12:47:31 UTC, Stanislav Blinov wrote: [...] The temporary exists until the end of full expression, or until the end of enclosing statement. It is simply not an lvalue for the caller, but it certainly exists, and so its interface must function. So public data

Re: Running unit tests from DUB single file packages

2020-12-01 Thread Johannes Loher via Digitalmars-d-learn
Am 01.12.20 um 14:55 schrieb drug: > On 12/1/20 2:40 PM, Johannes Loher wrote: >> ... >> However, I am having trouble running the unit tests when using the >> ... > > This can be one of solution https://github.com/dlang/dub/pull/2050 > Thanks! Let's see if it gets merged or if a slightly more

Re: Running unit tests from DUB single file packages

2020-12-01 Thread Johannes Loher via Digitalmars-d-learn
Am 01.12.20 um 14:52 schrieb jmh530: > On Tuesday, 1 December 2020 at 13:52:35 UTC, jmh530 wrote: >> On Tuesday, 1 December 2020 at 11:40:38 UTC, Johannes Loher wrote: >>> [snip] >>> >>> Any hints on how to execute unit tests from single file DUB packages? >>> Is it even possible at the moment?

Running unit tests from DUB single file packages

2020-12-01 Thread Johannes Loher via Digitalmars-d-learn
Hello everybody, when solving today's problem for the adventofcode [1], I decided to try out DUB's single file package feature, in order to keep things short. When doing the adventofcode, I always use the given examples as unit tests in order to verify that my solutions are actually correct.

Re: Selective unittesting in DUB

2020-12-01 Thread Johannes Loher via Digitalmars-d-learn
Am 01.12.20 um 08:11 schrieb ryuukk_: > Running .\dawn-test-application.exe > 2 modules passed unittests > > > Wich ones? it should print > > > ``` > Running tests for target X > > - src/module_a.d Tests: OK   <-- line in green > - src/module_b.d Tests: OK >