Re: sumtype 1.0.0

2020-11-17 Thread aliak via Digitalmars-d-announce
On Sunday, 15 November 2020 at 20:05:16 UTC, Paul Backus wrote: SumType is a generic discriminated union type for modern D. It is designed to be an improved alternative to `std.variant.Algebraic`. [...] Alright!!  A 1.0.0 release! Awesome work here!

Re: Renaming Flag!"" in API

2020-10-12 Thread aliak via Digitalmars-d-learn
On Monday, 12 October 2020 at 10:24:44 UTC, FreeSlave wrote: Let's say I use Flag type named 'myflagname' in API like this: import std.typecons; void func(Flag!"myflagname" flag) { //... } void main() { func(Yes.myflagname); } Later I realize that 'myflagname' is a bad name and I want to

Re: Is it possible to "overload" based on visibility?

2020-09-23 Thread aliak via Digitalmars-d-learn
On Wednesday, 23 September 2020 at 19:27:13 UTC, Steven Schveighoffer wrote: This is a bug in the language. 勞

Re: Is it possible to "overload" based on visibility?

2020-09-23 Thread aliak via Digitalmars-d-learn
On Wednesday, 23 September 2020 at 18:38:53 UTC, 60rntogo wrote: There are really two questions here, one that I intended to ask and one that came out while I was trying to figure out the answer. Consider this simple code: [...] Yeah, you can make a property setter: private void x(int

Re: Article: the feature that makes D my favorite programming language

2020-07-27 Thread Aliak via Digitalmars-d-announce
On Saturday, 25 July 2020 at 16:22:52 UTC, H. S. Teoh wrote: On Sat, Jul 25, 2020 at 01:28:34PM +, Adam D. Ruppe via Digitalmars-d-announce wrote: On Saturday, 25 July 2020 at 11:12:16 UTC, aberba wrote: > Oop! Chaining the writeln too could have increased the wow > factor. I didn't see

Re: vibe.d and my first web service

2020-07-18 Thread aliak via Digitalmars-d-learn
On Saturday, 18 July 2020 at 09:10:04 UTC, Mr. Backup wrote: Hello, I wanted to create simple web service to start learning more about D lang and compare with another languages. I have used "dub init -t vibe.d" to create basic example: [...] Think it's just Vibe.d: I had a similar issue:

Re: DIP1028 - Rationale for accepting as is

2020-05-27 Thread Aliak via Digitalmars-d-announce
On Wednesday, 27 May 2020 at 02:42:24 UTC, Walter Bright wrote: On 5/24/2020 6:04 PM, Timon Gehr wrote: Implicit greenwashing by the compiler is a nuisance that makes it harder to do the job correctly and easier to do the wrong thing. You and I are just going to disagree about that.

Re: DIP1028 - Rationale for accepting as is

2020-05-24 Thread aliak via Digitalmars-d-announce
On Sunday, 24 May 2020 at 11:30:53 UTC, Johannes Loher wrote: On Sunday, 24 May 2020 at 11:25:06 UTC, aliak wrote: On Sunday, 24 May 2020 at 10:40:11 UTC, Johannes Loher wrote: does not work). But I admit that it is still a bit weird to have 2 different defaults. Is that any more or less

Re: DIP1028 - Rationale for accepting as is

2020-05-24 Thread aliak via Digitalmars-d-announce
On Sunday, 24 May 2020 at 10:40:11 UTC, Johannes Loher wrote: does not work). But I admit that it is still a bit weird to have 2 different defaults. Is that any more or less weirder than having functions inferred with different attributes based on context?

Re: DIP1028 - Rationale for accepting as is

2020-05-22 Thread aliak via Digitalmars-d-announce
First, thank you for the explanation! I have a few observations though, mainly that the exception analogy feels like more an argument against the DIP than for it. And I also have an alternative proposal that might be considered? On Friday, 22 May 2020 at 01:22:19 UTC, Walter Bright wrote:

Re: Can't get dub dustmite to work

2020-04-27 Thread Aliak via Digitalmars-d-learn
On Monday, 27 April 2020 at 06:23:08 UTC, Andre Pany wrote: On Sunday, 26 April 2020 at 22:07:56 UTC, aliak wrote: On Saturday, 25 April 2020 at 18:52:45 UTC, Andre Pany wrote: [...] I'm sorry I didn't follow. You mean like: "dub test" ?? I dont pass anything to the -b or -c flag if

Re: Can't get dub dustmite to work

2020-04-26 Thread aliak via Digitalmars-d-learn
On Saturday, 25 April 2020 at 18:52:45 UTC, Andre Pany wrote: How do you call dub test causing the issue? Maybe there is a difference in the configuration/build type. I'm sorry I didn't follow. You mean like: "dub test" ?? I dont pass anything to the -b or -c flag if that's what you

Re: Can't get dub dustmite to work

2020-04-26 Thread aliak via Digitalmars-d-learn
On Saturday, 25 April 2020 at 19:00:55 UTC, Anonymouse wrote: On Saturday, 25 April 2020 at 09:38:59 UTC, aliak wrote: Then I run this dub dustmite command: dub dustmite -b unittest ../dubdust --compiler-regex="never matches" I have had zero luck with dustmite via dub. I would honestly

Can't get dub dustmite to work

2020-04-25 Thread aliak via Digitalmars-d-learn
Trying to get dub dustmite to work, but I keep getting "initial test fails" This is the error from a vanilla dub test: ``` result ~wip: building configuration "result-test-unittest"... inout(SumType!(int, FailureContainer)) ../../.dub/packages/sumtype-0.9.4/sumtype/src/sumtype.d(1322,4):

Re: Integration tests

2020-04-22 Thread aliak via Digitalmars-d-learn
On Wednesday, 22 April 2020 at 10:32:48 UTC, Russel Winder wrote: Now I discover Python, Rust, and Go have far nicer abstractions for writing Internet code than D does. Does D really not have a TcpListener abstraction? It really doesn't :( And D has so much potential as server tech with

Re: Option and Result [was Integration tests]

2020-04-21 Thread aliak via Digitalmars-d-learn
On Tuesday, 21 April 2020 at 16:30:15 UTC, Russel Winder wrote: On Mon, 2020-04-20 at 20:19 +, aliak via Digitalmars-d-learn wrote: […] [0]: https://github.com/aliak00/optional Rust has Option and Result, and most languages are rapidly introducing at least Option if not Result

Re: Integration tests

2020-04-20 Thread aliak via Digitalmars-d-learn
On Friday, 17 April 2020 at 16:56:57 UTC, Russel Winder wrote: Hi, Thinking of trying to do the next project in D rather than Rust, but… Rust has built in unit testing on a module basis. D has this so no problem. Rust allows for integration tests in the tests directory of a project.

Re: DLS deprecation

2020-04-08 Thread aliak via Digitalmars-d-announce
On Tuesday, 7 April 2020 at 22:20:40 UTC, Laurent Tréguier wrote: On Tuesday, 7 April 2020 at 20:03:21 UTC, Aliak wrote: Is what you’re working on shareable information (just out of curiosity)? It's shareable (it's on Github just like DLS); it's a mobile app, the Android version is in

Re: DLS deprecation

2020-04-07 Thread Aliak via Digitalmars-d-announce
On Tuesday, 7 April 2020 at 19:12:49 UTC, Laurent Tréguier wrote: I started working on this project to make it more comfortable to write D back in 2017, published a VSCode extension a couple months later, and continued working on it throughout 2018. In 2019 however, I slowed down, and

Re: dub sourceFiles

2020-04-01 Thread aliak via Digitalmars-d-learn
On Tuesday, 31 March 2020 at 15:23:48 UTC, Anonymouse wrote: I have a library package that I split up into subpackages, but I'm having to do mental gymnastics to make it only compile the files I want. The problem is that even if you specify some `sourceFiles`, it will build everything under

Re: Pattern matching via switch?

2020-03-14 Thread aliak via Digitalmars-d-learn
On Saturday, 14 March 2020 at 19:04:28 UTC, 12345swordy wrote: I.E. switch (object) case Type1 t1: case Type2 t2: case Type3 t3: You can use the sumtype package (https://code.dlang.org/packages/sumtype): alias T = SumType!(Type1, Type2, Type3); T(object).match!( (Type1 t1)

Re: Safely wrapping an uncopyable struct to implement an interface

2020-03-04 Thread aliak via Digitalmars-d-learn
On Wednesday, 4 March 2020 at 12:03:48 UTC, Gregor Mückl wrote: Hi! I've just created a situation in my code that is summarized by the following example. I don't know how to solve it with @safe code. A third party library provides a struct that is not copyable: // provided by third party

Re: in not working for arrays is silly, change my view

2020-03-02 Thread aliak via Digitalmars-d-learn
On Monday, 2 March 2020 at 23:27:22 UTC, Steven Schveighoffer wrote: What I think is happening is that it determines nobody is using the result, and the function is pure, so it doesn't bother calling that function (probably not even the lambda, and then probably removes the loop completely).

Re: in not working for arrays is silly, change my view

2020-03-02 Thread aliak via Digitalmars-d-learn
On Monday, 2 March 2020 at 21:33:37 UTC, Steven Schveighoffer wrote: On 3/2/20 3:52 PM, aliak wrote: On Monday, 2 March 2020 at 15:47:26 UTC, Steven Schveighoffer wrote: On 3/2/20 6:52 AM, Andrea Fontana wrote: On Saturday, 29 February 2020 at 20:11:24 UTC, Steven Schveighoffer wrote: 1. in

Re: in not working for arrays is silly, change my view

2020-03-02 Thread aliak via Digitalmars-d-learn
On Monday, 2 March 2020 at 15:47:26 UTC, Steven Schveighoffer wrote: On 3/2/20 6:52 AM, Andrea Fontana wrote: On Saturday, 29 February 2020 at 20:11:24 UTC, Steven Schveighoffer wrote: 1. in is supposed to be O(lg(n)) or better. Generic code may depend on this property. Searching an array is

Re: in not working for arrays is silly, change my view

2020-03-02 Thread aliak via Digitalmars-d-learn
On Monday, 2 March 2020 at 15:50:08 UTC, Steven Schveighoffer wrote: On 3/2/20 6:39 AM, JN wrote: On Saturday, 29 February 2020 at 21:56:51 UTC, Ali Çehreli wrote: Because you mentioned canFind, I think you want the semantics to be "is there an element with this value." If so, it would be

Re: DIP 1027---String Interpolation---Format Assessment

2020-03-01 Thread aliak via Digitalmars-d-announce
On Saturday, 29 February 2020 at 14:41:16 UTC, Steven Schveighoffer wrote: On 2/28/20 7:57 PM, aliak wrote: I actually didn't realize it was a video, thought it was just an article! - But anyway, it was just to point out that swift lowers to specialized types when it comes to interpolation

Re: DIP 1027---String Interpolation---Format Assessment

2020-02-28 Thread aliak via Digitalmars-d-announce
On Friday, 28 February 2020 at 19:16:08 UTC, Steven Schveighoffer wrote: On 2/28/20 5:17 AM, Jacob Carlborg wrote: On Friday, 28 February 2020 at 03:10:48 UTC, Walter Bright wrote: I don't know Swift, but this looks like the "generate strings and concatenate them" approach. No, it

Re: DIP 1027---String Interpolation---Format Assessment

2020-02-27 Thread Aliak via Digitalmars-d-announce
On Thursday, 27 February 2020 at 18:19:03 UTC, Adam D. Ruppe wrote: On Thursday, 27 February 2020 at 17:41:12 UTC, Petar Kirov [ZombineDev] wrote: [...] Right, that actually is what my old proposal was (and I fought for it on the first few pages of the last thread), and this is very close

Re: DIP 1027---String Interpolation---Format Assessment

2020-02-27 Thread aliak via Digitalmars-d-announce
On Thursday, 27 February 2020 at 09:34:23 UTC, Walter Bright wrote: On 2/26/2020 7:41 AM, Arine wrote: Yah, what's unwanted about that? 1. unwanted extra string allocation 2. poor performance 3. doesn't work with printf 4. doesn't work with writef 5. non-default formats require extra temp

Re: DIP 1027---String Interpolation---Format Assessment

2020-02-26 Thread aliak via Digitalmars-d-announce
On Tuesday, 25 February 2020 at 16:04:59 UTC, Arine wrote: ``How to distinguish a different type? Use a different type. No, is there another simpler way to do that instead?`` Is this really the line of thinking going on here? It seems Walter has these arbitrary rules he's following which led

Re: DIP 1027---String Interpolation---Format Assessment

2020-02-26 Thread aliak via Digitalmars-d-announce
On Wednesday, 26 February 2020 at 09:45:55 UTC, Walter Bright wrote: On 2/25/2020 1:36 AM, aliak wrote: This may have already been answered in the other threads, but I was just wondering if anyone managed to propose a way to avoid this scenario with DIP1027? void f(string s, int i = 0);

Re: DIP 1027---String Interpolation---Format Assessment

2020-02-25 Thread Aliak via Digitalmars-d-announce
On Tuesday, 25 February 2020 at 13:04:41 UTC, Adam D. Ruppe wrote: On Tuesday, 25 February 2020 at 09:36:25 UTC, aliak wrote: [...] Yes, that is the key impetus of our amendment, which I also wrote up on a gist weeks ago and it is now on github too!

Re: DIP 1027---String Interpolation---Format Assessment

2020-02-25 Thread aliak via Digitalmars-d-announce
On Tuesday, 25 February 2020 at 07:07:50 UTC, Walter Bright wrote: All DIP1027 did was turn an istring into a tuple. That's it. The user can then do whatever they want with the tuple, including overloading a custom function based on the tuple arguments. DIP1027 did not actually do ANY

Re: DIP 1027---String Interpolation---Format Assessment

2020-02-24 Thread aliak via Digitalmars-d-announce
On Monday, 24 February 2020 at 21:23:43 UTC, Adam D. Ruppe wrote: On Monday, 24 February 2020 at 20:55:16 UTC, Walter Bright wrote: and proposed a lowering to: > i"your hex data is ${%02x}someByte" > > (_d_interpolated_string!("your hex data is ", > _d_interpolated_format_spec("%02x"))(),

Re: Is deprecating a template supposed to work?

2020-02-20 Thread aliak via Digitalmars-d-learn
On Thursday, 20 February 2020 at 23:21:23 UTC, MoonlightSentinel wrote: On Thursday, 20 February 2020 at 22:31:16 UTC, aliak wrote: Is this suppose to give a deprecation error message? deprecated("a") alias A(T) = B!T; template B(T) { alias B = T; } void main() { A!int a; // should

Is deprecating a template supposed to work?

2020-02-20 Thread aliak via Digitalmars-d-learn
Is this suppose to give a deprecation error message? deprecated("a") alias A(T) = B!T; template B(T) { alias B = T; } void main() { A!int a; // should this cause a message "a" ? } ?? Or am I using it wrong maybe?

Re: Bolts 1.4 - added experimental signatures for D

2020-02-19 Thread aliak via Digitalmars-d-announce
On Friday, 14 February 2020 at 21:33:01 UTC, aliak wrote: Hi, [...] Cheers, - ali Ok, you can now model an actual input range with most of it's caveats: interface InputRange(T) { @property bool empty(); @property T front(); @ignoreAttributes void popFront(); } struct MyRange {

Bolts 1.4 - added experimental signatures for D

2020-02-14 Thread aliak via Digitalmars-d-announce
Hi, I've released an experimental implementation of the concept of traits/signatures/protocols-ish. The basics seems to work decently well, with very decent error messages e.g.: source/bolts/experimental/signature.d(111,17): Error: static assert: "Type Y is missing the following members of

Re: How do you find the struct types in a module? - getting Error: unknown

2020-02-13 Thread aliak via Digitalmars-d-learn
On Thursday, 13 February 2020 at 15:38:37 UTC, Steven Schveighoffer wrote: On 2/13/20 9:47 AM, aliak wrote: [...] Not sure about your error, but here is a working version (don't use mixins, use __traits(getMember)): import std.meta; template ListOfStructs(alias mod) { enum

How do you find the struct types in a module? - getting Error: unknown

2020-02-13 Thread aliak via Digitalmars-d-learn
Hi, I'm trying to get a typed list of structs in my current module that matches certain criteria. Something like: module mod; struct X {} struct Y {} alias allTypes = ListOfTypes!mod; But I'm having a bit of trouble. I have this so far: template ListOfTypes(alias T) { import std.meta;

Re: Hum Humm, Typedef

2019-12-01 Thread aliak via Digitalmars-d-learn
On Saturday, 30 November 2019 at 18:15:47 UTC, Treebeard wrote: Hoom, hum, I met a dark forest of complains from the compilers here. [...] /me thinks it's a bug Pushed a pr. Let's see. https://github.com/dlang/phobos/pull/7298

Re: Referance usage in async function

2019-11-30 Thread aliak via Digitalmars-d-learn
On Saturday, 30 November 2019 at 13:45:00 UTC, kerdemdemir wrote: I have simplified my problem which can be seen below. import std.stdio; import vibe.core.core; import vibe.core.concurrency; import vibe.data.json; void main() { int[] list; bool ListManipulator(ref int[] list) {

Re: How to wait for a shell process to finish on ctrl+c before exiting?

2019-11-25 Thread aliak via Digitalmars-d-learn
On Sunday, 24 November 2019 at 17:04:49 UTC, Steven Schveighoffer wrote: On 11/24/19 10:44 AM, aliak wrote: [...] Hm.. are you sure that ctrl-c isn't also sending the signal to your child process? I thought it did. -Steve Yesh, you're right. That extra kill is unnecessary and was

Re: How to wait for a shell process to finish on ctrl+c before exiting?

2019-11-25 Thread aliak via Digitalmars-d-learn
On Sunday, 24 November 2019 at 16:05:14 UTC, mipri wrote: On Sunday, 24 November 2019 at 15:44:00 UTC, aliak wrote: [...] This might be useful: --- #! /usr/bin/env rdmd import std; import core.stdc.signal; [...] waitpid, of course! Thanks agin :)

How to wait for a shell process to finish on ctrl+c before exiting?

2019-11-24 Thread aliak via Digitalmars-d-learn
I'm writing some command line tooling stuff, and one of the command spins up a docker compose file (which in short, spins up some services and aggregates the output of each service to stdout). When a user presses ctrl+c, i would like to pass on the ctrl+c to the spawned process and wait till

Re: Spawning a process, then killing it on SIGINT

2019-11-24 Thread aliak via Digitalmars-d-learn
On Saturday, 23 November 2019 at 12:19:27 UTC, Steven Schveighoffer wrote: On 11/23/19 4:54 AM, aliak wrote: Is there a way to go about killing a process after spawning it on a SIGINT? I can't do this for e.g. because kill is not @nogc. Pid currentSpawnedPid; extern(C) void

Re: Spawning a process, then killing it on SIGINT

2019-11-24 Thread aliak via Digitalmars-d-learn
On Saturday, 23 November 2019 at 10:09:51 UTC, mipri wrote: On Saturday, 23 November 2019 at 09:54:48 UTC, aliak wrote: Is there a way to go about killing a process after spawning it on a SIGINT? I can't do this for e.g. because kill is not @nogc. Well, this works: import std; import

Spawning a process, then killing it on SIGINT

2019-11-23 Thread aliak via Digitalmars-d-learn
Is there a way to go about killing a process after spawning it on a SIGINT? I can't do this for e.g. because kill is not @nogc. Pid currentSpawnedPid; extern(C) void killCurrentPidHandler(int sig) nothrow @nogc @system { kill(currentSpawnedPid, sig); } int main() { currentSpawnedPid =

Re: release of code-d 0.21.0 + serve-d 0.5.1

2019-11-14 Thread Aliak via Digitalmars-d-announce
On Wednesday, 13 November 2019 at 23:17:21 UTC, WebFreak001 wrote: hi everyone, after a long time there is finally a new update for my Visual Studio Code extension "code-d" [...] Wow! Well done on the effort!!

Re: D for microservices: ldc, rdmd, dub now available on Alpine x86_64

2019-11-05 Thread aliak via Digitalmars-d-announce
On Tuesday, 5 November 2019 at 02:16:28 UTC, Mathias Lang wrote: Hi all, Recently there have been inquiries about support for D on Alpine Linux, a distribution mostly used in combination with Docker to create lightweight container images for microservices. [...] This is great! Much thanks

Re: When will you announce DConf 2020?

2019-11-03 Thread Aliak via Digitalmars-d-announce
On Sunday, 3 November 2019 at 00:51:38 UTC, Murilo wrote: Hi guys. I'm eager to attend the next DConf, which is why I'm already planning everything about how I will travel from Brazil to the UK(or maybe Germany). When will you announce the place and date of the next DConf? Hey! That’s

Re: Átila's Vision of D's Future

2019-10-16 Thread Aliak via Digitalmars-d-announce
On Wednesday, 16 October 2019 at 12:11:23 UTC, bachmeier wrote: On Wednesday, 16 October 2019 at 09:46:49 UTC, aliak wrote: On Tuesday, 15 October 2019 at 20:33:32 UTC, Walter Bright wrote: On 10/15/2019 6:11 AM, Mike Parker wrote: Reddit:

Re: Átila's Vision of D's Future

2019-10-16 Thread Aliak via Digitalmars-d-announce
On Wednesday, 16 October 2019 at 17:55:24 UTC, Meta wrote: On Wednesday, 16 October 2019 at 09:46:49 UTC, aliak wrote: It's better to link straight to an item on hackernews as links on the front page disappear very fast. https://news.ycombinator.com/item?id=21257943 Cheers, - Ali HN has

Re: Átila's Vision of D's Future

2019-10-16 Thread aliak via Digitalmars-d-announce
On Tuesday, 15 October 2019 at 20:33:32 UTC, Walter Bright wrote: On 10/15/2019 6:11 AM, Mike Parker wrote: Reddit: https://www.reddit.com/r/d_language/comments/di7gwl/%C3%A1tilas_vision_of_ds_future/ It's also on the front page of hacker news: https://news.ycombinator.com/news It's better

Re: CodinGame adds support for 2 new programming languages

2019-10-02 Thread Aliak via Digitalmars-d-announce
On Thursday, 26 September 2019 at 15:58:46 UTC, Andre Pany wrote: Hi, Based on the voting results (https://www.codingame.com/forum/t/poll-what-programming-language-would-you-like-codingame-to-support-next) Codingame is currently adding 2 new programming languages, Type Script and D! Thanks

Re: deep copying a struct

2019-09-06 Thread aliak via Digitalmars-d-learn
On Friday, 6 September 2019 at 10:37:16 UTC, aliak wrote: Are there any library APIs that allow this: I just put this together. Any holes other the AA related ones? Will it work with classes? auto dupDeep(T)(ref T thing) { import std.range: ElementType; import std.traits:

deep copying a struct

2019-09-06 Thread aliak via Digitalmars-d-learn
Are there any library APIs that allow this: struct S { int[] arr; } void main() { const a = S([1,2,3]); S b = a.copy; // deep dup/copy } I'd also like to avoid implementing a copy constructor for each type.

Re: advise about safety of using move in an opAssign with __traits(isRef

2019-08-18 Thread aliak via Digitalmars-d-learn
On Saturday, 17 August 2019 at 16:43:51 UTC, Paul Backus wrote: On Friday, 16 August 2019 at 08:07:28 UTC, aliak wrote: Hi, I'm trying to fix a use-case where you have a wrapper template type (it's an optional) and the wrapping type has @disable this(this). And having this scenario work:

Re: advise about safety of using move in an opAssign with __traits(isRef

2019-08-17 Thread aliak via Digitalmars-d-learn
On Friday, 16 August 2019 at 14:29:26 UTC, Paul Backus wrote: On Friday, 16 August 2019 at 08:07:28 UTC, aliak wrote: [...] Even simpler: void opAssign(auto ref Optional!T rhs) { import core.lifetime: forward; this._value = forward!rhs; } That doesn't work with private members

advise about safety of using move in an opAssign with __traits(isRef

2019-08-16 Thread aliak via Digitalmars-d-learn
Hi, I'm trying to fix a use-case where you have a wrapper template type (it's an optional) and the wrapping type has @disable this(this). And having this scenario work: struct S { @disable this(this); } Optional!S fun() {...} Optional!S a; a = fun.move; Now that won't work because of the

Re: Passing nested template function

2019-08-10 Thread aliak via Digitalmars-d-learn
On Saturday, 10 August 2019 at 17:45:43 UTC, Prateek Nayak wrote: A nested function can be passed to another function evident from this example: https://run.dlang.io/is/6waRkB However if the nested function is a template function, it raises an error https://run.dlang.io/is/PQhkwl The error

Re: LDC 1.17.0-beta1

2019-08-10 Thread aliak via Digitalmars-d-announce
On Saturday, 10 August 2019 at 15:51:28 UTC, kinke wrote: Glad to announce the first beta for LDC 1.17: Nice! * Based on D 2.087.1+ (stable from some days ago). * The DMD fix wrt. 'local templates can now receive local Are there plans to port this or is it just too unworkable as is?

Re: optional 1.0.0 beta with "or/frontOr/Throw" range utilities

2019-07-30 Thread aliak via Digitalmars-d-announce
On Tuesday, 30 July 2019 at 12:58:08 UTC, Jesse Phillips wrote: On Monday, 29 July 2019 at 22:17:20 UTC, aliak wrote: * NotNull has been removed Why was it removed. It seems like this would be nice to have for class and pointers. I personally didn't find use for it, too much friction to

Re: optional 1.0.0 beta with "or/frontOr/Throw" range utilities

2019-07-30 Thread aliak via Digitalmars-d-announce
On Tuesday, 30 July 2019 at 04:18:28 UTC, Les De Ridder wrote: On Monday, 29 July 2019 at 22:17:20 UTC, aliak wrote: [...] * dispatch() has been renamed to oc(); "optional chain" Why not 'chain()' or 'optionalChain()'? Only because chain is in range and optionalChain is too long 路‍♂️.

Re: optional 1.0.0 beta with "or/frontOr/Throw" range utilities

2019-07-29 Thread Aliak via Digitalmars-d-announce
On Monday, 29 July 2019 at 22:17:20 UTC, aliak wrote: Hi Link: https://code.dlang.org/packages/optional

optional 1.0.0 beta with "or/frontOr/Throw" range utilities

2019-07-29 Thread aliak via Digitalmars-d-announce
Hi, After some feedback from the community [0], I'm happy to finally get the optional package to a 1.0.0 version. There is one breaking change with how pointer semantics behave, in that the previous version treated some!(int*)(null) as a non-empty optional, and some!Class(null) as an empty

cannot use local __lambda1 as parameter to non-global template

2019-07-26 Thread aliak via Digitalmars-d-learn
Can someone help me understand the details around why this fails? import std; struct W(T) { T value; auto hook(handlers...)() { return handlers[0](value); } } template f(handlers...) { auto ref f(T)(auto ref T value) { return value.hook!handlers; } } @nogc

Re: cannot use local __lambda1 as parameter to non-global template

2019-07-26 Thread aliak via Digitalmars-d-learn
On Friday, 26 July 2019 at 16:20:10 UTC, aliak wrote: Can someone help me understand the details around why this fails? import std; struct W(T) { T value; auto hook(handlers...)() { return handlers[0](value); } } template f(handlers...) { auto ref f(T)(auto ref T

Re: cannot use local __lambda1 as parameter to non-global template

2019-07-26 Thread aliak via Digitalmars-d-learn
On Friday, 26 July 2019 at 16:21:52 UTC, aliak wrote: On Friday, 26 July 2019 at 16:20:10 UTC, aliak wrote: Can someone help me understand the details around why this fails? import std; struct W(T) { T value; auto hook(handlers...)() { return handlers[0](value); } }

Re: Any way to move in @disabled this(this) type in to a wrapping template?

2019-07-25 Thread aliak via Digitalmars-d-learn
On Thursday, 25 July 2019 at 21:23:33 UTC, Paul Backus wrote: On Thursday, 25 July 2019 at 20:38:59 UTC, aliak wrote: On Thursday, 25 July 2019 at 19:35:36 UTC, aliak wrote: Basically, can template W be made to handle an S that can't be copied? import std; static struct S { int i;

Re: Any way to move in @disabled this(this) type in to a wrapping template?

2019-07-25 Thread aliak via Digitalmars-d-learn
On Thursday, 25 July 2019 at 19:35:36 UTC, aliak wrote: Basically, can template W be made to handle an S that can't be copied? import std; static struct S { int i; @disable this(this); this(int i) { this.i = i; } } struct W(T) { T value; this(T value) { this.value

Any way to move in @disabled this(this) type in to a wrapping template?

2019-07-25 Thread aliak via Digitalmars-d-learn
Basically, can template W be made to handle an S that can't be copied? import std; static struct S { int i; @disable this(this); this(int i) { this.i = i; } } struct W(T) { T value; this(T value) { this.value = value; } } auto wrap(T)(T value) { return

Re: dip1000, perhaps annotate with return, and vibe-d

2019-07-25 Thread aliak via Digitalmars-d-learn
On Wednesday, 24 July 2019 at 16:23:48 UTC, Paul Backus wrote: On Wednesday, 24 July 2019 at 12:54:51 UTC, aliak wrote: [...] It should go on the constructor's parameter; i.e., this(auto return ref T value) { /* ... */ } Under the hood, a constructor actually returns the constructed value

Re: Redis client hunt-redis RC1 released

2019-07-25 Thread aliak via Digitalmars-d-announce
On Tuesday, 23 July 2019 at 07:57:06 UTC, zoujiaqing wrote: A Powerfull Redis client library for D Programming Language. Porting from java Jedis, support redis 3.x / 4.x all features and 5.x some features. [...] Awesome! Huntlabs seem to really be putting in a lot of work on backend

dip1000, perhaps annotate with return, and vibe-d

2019-07-24 Thread aliak via Digitalmars-d-learn
Trying to get dip1000 flag in use. I have this error: Error: returning Optional(null, false).this(value) escapes a reference to parameter value, perhaps annotate with return in this function: public auto some(T)(auto ref T value) { return Optional!T(value); // <-- error on this line }

Re: segfault in ldc release only - looks like some kind of optimization bug?

2019-07-22 Thread aliak via Digitalmars-d-learn
On Tuesday, 23 July 2019 at 00:36:49 UTC, Exil wrote: auto ref get(T)(W!T value) { return value.front; } You're returning a reference to a temporary that gets deleted at the end of the function's scope. The "auto ref" here will be a "ref". . oh ... shit you're right. Ok so this

segfault in ldc release only - looks like some kind of optimization bug?

2019-07-22 Thread aliak via Digitalmars-d-learn
Hi, so I had this weird bug that was driving me crazy and only segfaulted with ldc in release build - (I'm using ldc 1.16.0). This is the code that segfaults. All parts seem to be necessary for it to happen, or at least I think so. I've gone in circles minimizing so I've probably missed

Re: can not find the error: Error: TypeInfo cannot be used with -betterC

2019-07-17 Thread aliak via Digitalmars-d-learn
On Wednesday, 17 July 2019 at 15:52:39 UTC, Newbie2019 wrote: when build my project with -betterC, it throw this error: Error: TypeInfo cannot be used with -betterC There is no location information about it, how can I find what code cause this ? You usually get that *extrememly* unhelpful

Re: bolts meta programming library version 1.0.0 - including the from idiom

2019-07-17 Thread aliak via Digitalmars-d-announce
On Wednesday, 17 July 2019 at 16:29:34 UTC, victoroak wrote: On Monday, 15 July 2019 at 11:13:10 UTC, aliak wrote: I've been using a set of meta tools for a while now, so decided to release it as 1.0.0 with a few enhancements chucked on. [...] Looks nice. Though, I see it has some problems

Re: bolts meta programming library version 1.0.0 - including the from idiom

2019-07-15 Thread Aliak via Digitalmars-d-announce
On Monday, 15 July 2019 at 21:20:16 UTC, Atila Neves wrote: On Monday, 15 July 2019 at 11:13:10 UTC, aliak wrote: I've been using a set of meta tools for a while now, so decided to release it as 1.0.0 with a few enhancements chucked on. [...] Nice! I'm working on something similar but with

bolts meta programming library version 1.0.0 - including the from idiom

2019-07-15 Thread aliak via Digitalmars-d-announce
I've been using a set of meta tools for a while now, so decided to release it as 1.0.0 with a few enhancements chucked on. Two of the highlights are the non-eponymous "member" and "iz" templates, which are shown below with some code. The library also includes the "from" template because I

Re: Trying to alias this a grapheme range + making it a forward range

2019-07-09 Thread aliak via Digitalmars-d-learn
On Monday, 8 July 2019 at 23:01:49 UTC, ag0aep6g wrote: On 08.07.19 23:55, aliak wrote: [...] `source.front` is a temporary `Grapheme` and you're calling `opSlice` on it. The documentation for `Grapheme.opSlice` warns: "Invalidates when this Grapheme leaves the scope, attempts to use it

Trying to alias this a grapheme range + making it a forward range

2019-07-08 Thread aliak via Digitalmars-d-learn
Problem 1: I'm trying to get a string to behave as a .byGrapheme range by default, but I can't figure out Grapheme. I'm trying to replicate this behavior: foreach (g; "hello".byGrapheme) { write(g[]); } In a custom type: struct ustring { string data; this(string data) {

Re: Anyway to compare function aliases? Or any ideas?

2019-07-04 Thread aliak via Digitalmars-d-learn
On Thursday, 4 July 2019 at 15:22:08 UTC, Marco de Wild wrote: On Thursday, 4 July 2019 at 15:10:05 UTC, aliak wrote: [...] I don't know if it will solve your whole problem, but have you tried __traits(isSame, W0.fun, fun)? Reduced example: struct Foo(alias fun){ alias bar = fun; }

Anyway to compare function aliases? Or any ideas?

2019-07-04 Thread aliak via Digitalmars-d-learn
Any ideas on how to be able to do something like this? struct S(alias _fun) { alias Fun = _fun; } void algorithm(alias f, T)(T s) { static if ( == ) { // trivial return } else { // must perform work, then return } } Can you use function addresses in some way? I've seen that

Re: Cushion the state transition table library released

2019-06-27 Thread aliak via Digitalmars-d-announce
On Wednesday, 26 June 2019 at 15:20:45 UTC, ag0aep6g wrote: On 26.06.19 16:01, SHOO wrote: [...] You've got bad `@trusted`s. Quoting from there: [...] No. [...] [...] [...] Noo. [...] [...] [...] [...] [...] [...] [...] Nooo. [...] [...] [...] [...] [...] [...]

Re: LDC 1.16.0

2019-06-21 Thread aliak via Digitalmars-d-announce
On Thursday, 20 June 2019 at 17:36:45 UTC, kinke wrote: Glad to announce LDC 1.16: * Based on D 2.086.1. * Non-Windows x86: Faster `real` versions of std.math.{tan,expi}. * Windows: Fix linking DLLs with MinGW-based libs. * WebAssembly: No need for an explicit `-L--export-dynamic` anymore.

Re: What is iota function full name

2019-06-21 Thread aliak via Digitalmars-d-learn
On Friday, 21 June 2019 at 09:01:17 UTC, lili wrote: Hi Guys: What is range.iota function full name That is the full name. Or what do you mean? Found on the internet somewhere: "The function is named after the integer function ⍳ from the programming language APL."

Re: Range violation error when reading from a file

2019-06-18 Thread aliak via Digitalmars-d-learn
On Tuesday, 18 June 2019 at 01:15:54 UTC, Samir wrote: On Monday, 17 June 2019 at 03:46:11 UTC, Norm wrote: On Monday, 17 June 2019 at 00:22:23 UTC, Samir wrote: Any suggestions on how to rectify? You could change the IF to `if(line.length > 0 && line[0] == '>')` Thanks, Norm. That

Re: How does this template work?

2019-06-17 Thread aliak via Digitalmars-d-learn
On Monday, 17 June 2019 at 18:25:24 UTC, Robert M. Münch wrote: On 2019-06-16 15:14:37 +, rikki cattermole said: observerObject is an eponymous template. What this means (in essence) is the symbol inside the template block == template block. Hmm... ok. Is there any reason to have these

Re: Range violation error when reading from a file

2019-06-17 Thread aliak via Digitalmars-d-learn
On Monday, 17 June 2019 at 00:22:23 UTC, Samir wrote: Also, if I run the program below with the same file, I don't get any range violation errors: Ya, writeln will not access individual elements of a range if there aren't any. So no violations occur. HOWEVER, the output is interesting.

Re: Range violation error when reading from a file

2019-06-16 Thread aliak via Digitalmars-d-learn
On Sunday, 16 June 2019 at 23:44:49 UTC, Samir wrote: On Sunday, 16 June 2019 at 23:03:04 UTC, aliak wrote: stripping the last line could result in an empty line if it just has strippable characters? The last line of the file is just text but without a newline (\n) character or any other

Re: Range violation error when reading from a file

2019-06-16 Thread aliak via Digitalmars-d-learn
On Sunday, 16 June 2019 at 22:47:14 UTC, Samir wrote: I am trying to read from a text file using the following code: import std.stdio; import std.string; void main() { File file = File("test.txt"); string line; while (!file.eof()) { line = strip(file.readln()); if

Re: Beta 2.087.0

2019-06-16 Thread aliak via Digitalmars-d-announce
On Sunday, 16 June 2019 at 22:47:57 UTC, Martin Nowak wrote: Glad to announce the first beta for the 2.087.0 release, ♥ to the 66 contributors. http://dlang.org/download.html#dmd_beta http://dlang.org/changelog/2.087.0.html As usual please report any bugs at https://issues.dlang.org

Optional 0.15.0 now compatible with vibe-d, @safe, @nogc, betterC.

2019-06-04 Thread aliak via Digitalmars-d-announce
Hey, I've recently released optional 0.15.0 [0] that includes support for vibe-d serialization/deserialization. So you can use it instead of Nullable for types that may or may not be there (I got bit by Nullable again so felt this had to be added [1]) Also of note is that it can be used in

Re: Is there a way to disable copying of an alias this'd member? - trying to make a NotNull type

2019-05-24 Thread aliak via Digitalmars-d-learn
On Friday, 24 May 2019 at 12:03:08 UTC, Simen Kjærås wrote: On Friday, 24 May 2019 at 11:40:20 UTC, aliak wrote: It's ref so that you can do this for e.g. class C { int i; } auto a = notNull!C; a.i = 3; That's a valid concern for a struct, but classes are already reference types, so you're

Re: Is there a way to disable copying of an alias this'd member? - trying to make a NotNull type

2019-05-24 Thread aliak via Digitalmars-d-learn
On Friday, 24 May 2019 at 10:40:01 UTC, Simen Kjærås wrote: On Friday, 24 May 2019 at 10:16:50 UTC, aliak wrote: Basically, I want this to fail: auto notNull(T, Args...)(Args args) { return NotNull!T(new T(args)); } struct NotNull(T) { private T _value; @property ref inout(T) value()

Is there a way to disable copying of an alias this'd member? - trying to make a NotNull type

2019-05-24 Thread aliak via Digitalmars-d-learn
Basically, I want this to fail: auto notNull(T, Args...)(Args args) { return NotNull!T(new T(args)); } struct NotNull(T) { private T _value; @property ref inout(T) value() inout { return this._value; } alias value this; //disable opAssign to null as well } class C {} void func(ref

Re: LDC 1.16.0-beta1

2019-05-09 Thread aliak via Digitalmars-d-announce
On Thursday, 9 May 2019 at 21:14:02 UTC, kinke wrote: Glad to announce the first beta for LDC 1.16; mainly just an upgrade to D 2.086.0. Full release log and downloads: https://github.com/ldc-developers/ldc/releases/tag/v1.16.0-beta1 Please help test, and thanks to all contributors! Yay!!

  1   2   3   4   5   >