Re: Is there a more elegant way to do this in D?

2021-04-09 Thread ddcovery via Digitalmars-d-learn
On Thursday, 8 April 2021 at 04:02:26 UTC, Ali Çehreli wrote: On 4/7/21 8:57 PM, Brad wrote:     auto a = [1,0,1,1,1,0,1,0,1,1,1,1,0]; I want to come out of this with a string that looks like this: 101110100 Me, me, me, me! :) import std; void main() { auto a =

Re: Why many programmers don't like GC?

2021-01-19 Thread ddcovery via Digitalmars-d-learn
On Tuesday, 19 January 2021 at 11:25:13 UTC, Ola Fosheim Grøstad wrote: On Tuesday, 19 January 2021 at 10:43:45 UTC, Ola Fosheim Grøstad wrote: On Tuesday, 19 January 2021 at 10:36:13 UTC, ddcovery wrote: GC if D is not enough for you), but think about the thousands of experienced developers

Re: Why many programmers don't like GC?

2021-01-19 Thread ddcovery via Digitalmars-d-learn
On Monday, 18 January 2021 at 15:18:40 UTC, aberba wrote: From my experiencing freelancing, I've come to see that a large portion of clients' decision stems from other things like familiarity and ecosystem (packages, frameworks, vendor/cloud support, engineering hiring pool,

Re: Open question: what code pattern you use usually for null safety problem

2021-01-15 Thread ddcovery via Digitalmars-d-learn
On Friday, 15 January 2021 at 14:25:09 UTC, Steven Schveighoffer wrote: On 1/15/21 9:19 AM, Steven Schveighoffer wrote: Something similar to BlackHole or WhiteHole. Essentially there's a default action for null for all types/fields/methods, and everything else is passed through. And now

Re: Open question: what code pattern you use usually for null safety problem

2021-01-15 Thread ddcovery via Digitalmars-d-learn
On Friday, 15 January 2021 at 14:19:35 UTC, Steven Schveighoffer wrote: On 1/14/21 7:27 PM, ddcovery wrote: On Thursday, 14 January 2021 at 20:23:08 UTC, Steven Schveighoffer wrote: You could kinda automate it like: struct NullCheck(T) {    private T* _val;    auto opDispatch(string mem)()

Re: Open question: what code pattern you use usually for null safety problem

2021-01-15 Thread ddcovery via Digitalmars-d-learn
On Thursday, 14 January 2021 at 18:24:44 UTC, ddcovery wrote: I know there is other threads about null safety and the "possible" ways to support this in D and so on. This is only an open question to know what code patterns you usually use to solve this situation in D I'm writing a

Re: Open question: what code pattern you use usually for null safety problem

2021-01-14 Thread ddcovery via Digitalmars-d-learn
On Thursday, 14 January 2021 at 20:35:49 UTC, Dennis wrote: On Thursday, 14 January 2021 at 18:24:44 UTC, ddcovery wrote: If it's not a bother, I'd like to know how you usually approach it Usually I don't deal with null because my functions get primitive types, slices, or structs. `ref`

Re: Open question: what code pattern you use usually for null safety problem

2021-01-14 Thread ddcovery via Digitalmars-d-learn
On Thursday, 14 January 2021 at 20:23:08 UTC, Steven Schveighoffer wrote: You could kinda automate it like: struct NullCheck(T) { private T* _val; auto opDispatch(string mem)() if (__traits(hasMember, T, mem)) { alias Ret = typeof(() { return __traits(getMember, *_val, mem);

Re: Anything in D to avoid check for null everywhere?

2021-01-14 Thread ddcovery via Digitalmars-d-learn
On Thursday, 14 January 2021 at 21:49:41 UTC, Christian Köstlin wrote: ... Did you have a look at https://code.dlang.org/packages/optional? Especially https://aliak00.github.io/optional/optional/oc/oc.html might go in the right direction. Kind regards, Christian Thats nice!!! I was

Re: Open question: what code pattern you use usually for null safety problem

2021-01-14 Thread ddcovery via Digitalmars-d-learn
On Thursday, 14 January 2021 at 19:24:54 UTC, Adam D. Ruppe wrote: On Thursday, 14 January 2021 at 18:24:44 UTC, ddcovery wrote: This is only an open question to know what code patterns you usually use to solve this situation in D: I'm almost never in this situation except for reading things

Open question: what code pattern you use usually for null safety problem

2021-01-14 Thread ddcovery via Digitalmars-d-learn
I know there is other threads about null safety and the "possible" ways to support this in D and so on. This is only an open question to know what code patterns you usually use to solve this situation in D: if(person.father.father.name == "Peter") doSomething(); if(person.father.age > 80

Re: Why many programmers don't like GC?

2021-01-14 Thread ddcovery via Digitalmars-d-learn
On Thursday, 14 January 2021 at 10:28:13 UTC, Basile B. wrote: On Wednesday, 13 January 2021 at 18:58:56 UTC, Marcone wrote: I've always heard programmers complain about Garbage Collector GC. But I never understood why they complain. What's bad about GC? Semi serious answer: In the domain

Re: Anything in D to avoid check for null everywhere?

2021-01-13 Thread ddcovery via Digitalmars-d-learn
On Tuesday, 12 January 2021 at 21:37:11 UTC, Jack wrote: I was looking for a way to avoid null checks everywhere. I was checking the Null object pattern, or use something like enforce pattern, or even if I could make a new operator and implement something like C#'s .? operator, that Java was

Re: Anything in D to avoid check for null everywhere?

2021-01-13 Thread ddcovery via Digitalmars-d-learn
On Wednesday, 13 January 2021 at 09:02:37 UTC, ddcovery wrote: Find more details here: https://run.dlang.io/gist/392c06e745d1a35df71084ce4d29fed7 Ups... it seems that the link is not working (it is the first time I try to generate a dalng/gist link... I'm not sure if this can really be

Re: Anything in D to avoid check for null everywhere?

2021-01-13 Thread ddcovery via Digitalmars-d-learn
On Tuesday, 12 January 2021 at 21:37:11 UTC, Jack wrote: I was looking for a way to avoid null checks everywhere. I was checking the Null object pattern, or use something like enforce pattern, or even if I could make a new operator and implement something like C#'s .? operator, that Java was

Re: closures + struct: Error: forward reference to inferred return type of function call

2020-12-15 Thread ddcovery via Digitalmars-d-learn
On Tuesday, 15 December 2020 at 19:53:33 UTC, Q. Schroll wrote: On Monday, 14 December 2020 at 14:39:14 UTC, ddcovery wrote: On Monday, 14 December 2020 at 12:22:26 UTC, ddcovery wrote: int opCmp(Number other){ return _value - other.value; }; Correction: bool opEquals(Number

Re: closures + struct: Error: forward reference to inferred return type of function call

2020-12-14 Thread ddcovery via Digitalmars-d-learn
On Monday, 14 December 2020 at 12:22:26 UTC, ddcovery wrote: int opCmp(Number other){ return _value - other.value; }; Correction: bool opEquals(Number other){ return _value == other.value; };

closures + struct: Error: forward reference to inferred return type of function call

2020-12-14 Thread ddcovery via Digitalmars-d-learn
In this example, I try to use D Voldemore (fantastic) functionallity to implement a pattern usually used in javascript. Basically, a function closure represents the state, and the methods to access this state are returned in the form of union (union has not state itself). void main(){

Re: Dude about ~ array concatenation performance

2020-12-02 Thread ddcovery via Digitalmars-d-learn
On Wednesday, 2 December 2020 at 06:31:49 UTC, H. S. Teoh wrote: On Tue, Dec 01, 2020 at 10:49:55PM +, ddcovery via Digitalmars-d-learn wrote: Yesterday I really shocked when, comparing one algorithm written in javascript and the equivalent in D, javascript performed better

Re: Doubts about the performance of array concatenation

2020-12-01 Thread ddcovery via Digitalmars-d-learn
On Tuesday, 1 December 2020 at 23:43:31 UTC, Max Haughton wrote: On Tuesday, 1 December 2020 at 22:49:55 UTC, ddcovery wrote: Yesterday I really shocked when, comparing one algorithm written in javascript and the equivalent in D, javascript performed better!!! [...] Use ldc, rdmd can

Re: Doubts about the performance of array concatenation

2020-12-01 Thread ddcovery via Digitalmars-d-learn
On Tuesday, 1 December 2020 at 22:49:55 UTC, ddcovery wrote: Yesterday I really shocked when, comparing one algorithm written in javascript and the equivalent in D, javascript performed better!!! [...] Sorry about title (may be "doubt" :-/ )

Dude about ~ array concatenation performance

2020-12-01 Thread ddcovery via Digitalmars-d-learn
Yesterday I really shocked when, comparing one algorithm written in javascript and the equivalent in D, javascript performed better!!! The idea is to translate the "3 lines sort" in haskell to Javascript and D (with the limitations of each language). This is not a quick sort test, but a

Re: lambda recursion

2020-11-28 Thread ddcovery via Digitalmars-d-learn
On Friday, 27 November 2020 at 20:53:37 UTC, Ali Çehreli wrote: This has been done with the Y-combinator, where the lambda refers to itself as 'self': https://github.com/gecko0307/atrium/blob/master/dlib/functional/combinators.d There has been been other discussions on it on these forums.

Re: lambda recursion

2020-11-27 Thread ddcovery via Digitalmars-d-learn
On Friday, 27 November 2020 at 16:40:43 UTC, ddcovery wrote: ... * Can the lambda be transformed to a template (using T instead "int") but avoiding function/return syntax? This is an example using function template qs(T){ T[] qs( T[] items ){ return items.length==0 ?

lambda recursion

2020-11-27 Thread ddcovery via Digitalmars-d-learn
I want to express in D the known Haskell qsort 3 lines code (it is not a quick sort, but an example of how functional programming is expressive). This is the "javascript" version I use as reference: const sorted = ( [pivot, …others] ) => pivot===void 0 ? [ ] : [ … sorted(

Re: Article about Ranges

2020-11-25 Thread ddcovery via Digitalmars-d-learn
On Wednesday, 25 November 2020 at 12:28:20 UTC, Paul Backus wrote: Maybe this is the one you're thinking of? https://www.informit.com/articles/article.aspx?p=1407357 Ye, it is. Thank you very much Paul.

Article about Ranges

2020-11-25 Thread ddcovery via Digitalmars-d-learn
Months ago I read an Andrei article explaining why Ranges (comparing with C++). I remember article introduction included a python "false" quick-sort algorithm. I'm really interested in a more detailed read of the article, but I can't find it. If some one can post the link :-) Thank you

Re: vibe.d / experience / feedback

2020-10-11 Thread ddcovery via Digitalmars-d-learn
On Sunday, 11 October 2020 at 11:56:29 UTC, Robert M. Münch wrote: Well, for us it's getting more and more clear, that a decision what to use in the future will be based on less and less technical aspects. The interesting thing about Go is, that their main focus is thinking from an

Re: question on dub and postgresql

2020-10-08 Thread ddcovery via Digitalmars-d-learn
On Wednesday, 7 October 2020 at 19:15:42 UTC, aberba wrote: It seems the D ecosystem is not immediately obvious to some people. Dub, compilers, and IDEs are recurring issues. and debbuging (particularly inspection)

Re: vibe.d / experience / feedback

2020-10-06 Thread ddcovery via Digitalmars-d-learn
On Thursday, 1 October 2020 at 06:32:23 UTC, Robert M. Münch wrote: Hi, we are currently using vibe.d for a prototype and I want to post some experiences. I know one shouldn't only address the problems but provide some solutions. However, our current use-case is that we want to get a job

Re: assert format of a string before a mixin

2020-09-27 Thread ddcovery via Digitalmars-d-learn
On Sunday, 27 September 2020 at 21:41:25 UTC, Adam D. Ruppe wrote: On Sunday, 27 September 2020 at 21:38:43 UTC, ddcovery wrote: i.e. checking this Regex expression `^[a-zA-Z_]*[a-zA-Z0-9_]*[a-zA-Z][a-zA-Z0-9_]*$` Is there any way to check a regular expression at compile time? Not really

assert format of a string before a mixin

2020-09-27 Thread ddcovery via Digitalmars-d-learn
I have a "variation" of "unaryFun" that I name "unaryProp" that, basically, doesn't require to specify "a." at the beginning of the expression. template unaryProp(alias propName) { static assert(is(typeof(propName) : string), "Sorry, propName must be an string"); auto

Re: Templates and unaryFun!

2020-09-24 Thread ddcovery via Digitalmars-d-learn
I think I will dedicate tonight one or two hours to understand the first two proposals :-D. On Thursday, 24 September 2020 at 13:28:25 UTC, WebFreak001 wrote: [...] Alternatively a lot easier would be to just return auto and do: auto dt(alias fun, T)(Dot!T t){ return t.dot(t =>

Re: Templates and unaryFun!

2020-09-24 Thread ddcovery via Digitalmars-d-learn
On Thursday, 24 September 2020 at 14:15:01 UTC, ddcovery wrote: [...] I think I will dedicate tonight one or two hours to understand the first two proposals :-D. [...] Not necessary, really simple and well explained WebFreak001!!!

Templates and unaryFun!

2020-09-24 Thread ddcovery via Digitalmars-d-learn
Last week, in general forum someone introduced the possibility to implement the .? operator in D: https://forum.dlang.org/thread/blnjoaleswqnaojou...@forum.dlang.org I decided to implement a simple solution with a funciontal syntax: string fatherName =

Re: vibe.d and my first web service

2020-08-21 Thread ddcovery via Digitalmars-d-learn
On Friday, 21 August 2020 at 08:48:34 UTC, ddcovery wrote: On Thursday, 20 August 2020 at 21:36:04 UTC, Andre Pany wrote: [...] Thanks a lot Andre, I opened immediately the issues to receive some feedback: [...] EDIT: 23 days ago new vibe.d (0.9.0) was released... Testing with it memory

Re: vibe.d and my first web service

2020-08-21 Thread ddcovery via Digitalmars-d-learn
On Thursday, 20 August 2020 at 21:36:04 UTC, Andre Pany wrote: On Thursday, 20 August 2020 at 18:13:46 UTC, ddcovery wrote: On Monday, 17 August 2020 at 15:45:05 UTC, aberba wrote: [...] After 18 years following DLang, and some disagrees about productivity lacks at the beggining (no IDE,

Re: vibe.d and my first web service

2020-08-20 Thread ddcovery via Digitalmars-d-learn
"After 18 years following DLang," its not well expressed...may be "at first Dlang stages, after 2 years following its evolution, and ..."

Re: vibe.d and my first web service

2020-08-20 Thread ddcovery via Digitalmars-d-learn
On Monday, 17 August 2020 at 15:45:05 UTC, aberba wrote: On Thursday, 13 August 2020 at 09:54:06 UTC, Mr. Backup wrote: On Wednesday, 12 August 2020 at 13:46:06 UTC, James Blachly wrote: Unfortunately the problem still occurs with Vibe.d 0.9.0 IMO **this is the single most important problem