Jump to page: 1 2
Thread overview
Idioms for the D programming language
Feb 11, 2021
Walter Bright
Feb 12, 2021
H. S. Teoh
Feb 12, 2021
Guillaume Piolat
Feb 12, 2021
Imperatorn
Feb 12, 2021
Guillaume Piolat
Feb 12, 2021
Guillaume Piolat
Feb 13, 2021
TheGag96
Feb 12, 2021
James Lu
Feb 12, 2021
Walter Bright
Feb 12, 2021
Guillaume Piolat
Feb 13, 2021
James Lu
Feb 14, 2021
Walter Bright
Feb 13, 2021
James Lu
Feb 12, 2021
Imperatorn
Feb 13, 2021
James Lu
Feb 13, 2021
Imperatorn
Feb 14, 2021
James Lu
Feb 14, 2021
Bruce Carneal
February 11, 2021
Now #5 on the front page of https://news.ycombinator.com/news

The page being discussed:

https://p0nce.github.io/d-idioms/

and on reddit:

https://www.reddit.com/r/programming/comments/lhssjp/idioms_for_the_d_programming_language/
February 11, 2021
On Thu, Feb 11, 2021 at 12:12:36PM -0800, Walter Bright via Digitalmars-d-announce wrote: [...]
> https://p0nce.github.io/d-idioms/

Not bad, but it seems to be missing some of the newer idioms. Like the templated static this trick for transparently encoding compile-time information at runtime.  For example:

	import std.regex;
	void main(string[] args) {
		foreach (arg; args) {
			if (arg.match(Re!`some.*regex(pattern)+`)) {
				... // do something
			}
		}
	}

	template Re(string reStr) {
		Regex!char re;
		static struct Impl {
			static this() {
				re = regex(reStr);
			}
		}
		string Re() { return re; }
	}

The Re template captures the regex string at compile-time and injects it into Impl's static this(), which compiles the regex at program startup at runtime, then the eponymous function Re() simply returns the precompiled value.

The result:
- Regexes are automatically picked up at compile-time;
- But expensive compile-time generation of the regex (which consumes
  lots of compiler memory and slows down compilation) is skipped;
- Compilation of the regex happens only once upon program startup and
  cached, and thereafter is a simple global variable lookup.
- Multiple occurrences of the Re template with the same regex is
  automatically merged (because it's the same instantiation of the
  template).

D features used:
- compile-time string parameters
- static this()
- eponymous templates
- reuse of template instantiations that have the same arguments


[...]
> https://www.reddit.com/r/programming/comments/lhssjp/idioms_for_the_d_programming_language/

There doesn't appear to be any discussion happening here.


T

-- 
If it breaks, you get to keep both pieces. -- Software disclaimer notice
February 12, 2021
On Thursday, 11 February 2021 at 20:12:36 UTC, Walter Bright wrote:
> Now #5 on the front page of https://news.ycombinator.com/news

I've gotten Dlang to the frontpage of HN 3 other times:


Specification for the D Programming Language https://news.ycombinator.com/item?id=21993208
D 2.0.93.0 https://news.ycombinator.com/item?id=23859448
Ask HN: Why do you use Rust, when D is available? https://news.ycombinator.com/item?id=23494490

If you have any particularly interesting and specific pages on D, feel free to send them to me, so I can post them to HN at the optimal time. (Furthermore, if you authored it, you should a comment that explains why you made it and offering to answer questions– I have found this can turn a regular post into a frontpage post.)
February 12, 2021
On Thursday, 11 February 2021 at 20:12:36 UTC, Walter Bright wrote:
> Now #5 on the front page of https://news.ycombinator.com/news
>
> The page being discussed:
>
> https://p0nce.github.io/d-idioms/
>
> and on reddit:
>
> https://www.reddit.com/r/programming/comments/lhssjp/idioms_for_the_d_programming_language/

đź‘Ť
February 12, 2021
On 2/11/2021 5:53 PM, James Lu wrote:
> On Thursday, 11 February 2021 at 20:12:36 UTC, Walter Bright wrote:
>> Now #5 on the front page of https://news.ycombinator.com/news
> 
> I've gotten Dlang to the frontpage of HN 3 other times:
> 
> 
> Specification for the D Programming Language https://news.ycombinator.com/item?id=21993208
> D 2.0.93.0 https://news.ycombinator.com/item?id=23859448
> Ask HN: Why do you use Rust, when D is available? https://news.ycombinator.com/item?id=23494490

Thank you!

> If you have any particularly interesting and specific pages on D, feel free to send them to me, so I can post them to HN at the optimal time. (Furthermore, if you authored it, you should a comment that explains why you made it and offering to answer questions– I have found this can turn a regular post into a frontpage post.)

Yes, having the author do an AMA is very productive.
February 12, 2021
On Friday, 12 February 2021 at 00:26:09 UTC, H. S. Teoh wrote:
> On Thu, Feb 11, 2021 at 12:12:36PM -0800, Walter Bright via Digitalmars-d-announce wrote: [...]
>> https://p0nce.github.io/d-idioms/
>
> Not bad, but it seems to be missing some of the newer idioms.

It's because I lack the time to update it. It was always a page to let _me_ understand the language better, and then I got to a point where I wasn't following the D development enough.

February 12, 2021
On Friday, 12 February 2021 at 11:19:26 UTC, Guillaume Piolat wrote:
> On Friday, 12 February 2021 at 00:26:09 UTC, H. S. Teoh wrote:
>> On Thu, Feb 11, 2021 at 12:12:36PM -0800, Walter Bright via Digitalmars-d-announce wrote: [...]
>>> https://p0nce.github.io/d-idioms/
>>
>> Not bad, but it seems to be missing some of the newer idioms.
>
> It's because I lack the time to update it. It was always a page to let _me_ understand the language better, and then I got to a point where I wasn't following the D development enough.

For someone coming to D today, would you say most of the content there is still valid?

Thanks
February 12, 2021
On Friday, 12 February 2021 at 11:44:31 UTC, Imperatorn wrote:
> On Friday, 12 February 2021 at 11:19:26 UTC, Guillaume Piolat wrote:
>> On Friday, 12 February 2021 at 00:26:09 UTC, H. S. Teoh wrote:
>>> On Thu, Feb 11, 2021 at 12:12:36PM -0800, Walter Bright via Digitalmars-d-announce wrote: [...]
>>>> https://p0nce.github.io/d-idioms/
>>>
>>> Not bad, but it seems to be missing some of the newer idioms.
>>
>> It's because I lack the time to update it. It was always a page to let _me_ understand the language better, and then I got to a point where I wasn't following the D development enough.
>
> For someone coming to D today, would you say most of the content there is still valid?
>
> Thanks

It's mostly valid, but it lacks about fifty new articles that would need to be added.
February 12, 2021
On Friday, 12 February 2021 at 12:25:32 UTC, Guillaume Piolat wrote:
>
> It's mostly valid, but it lacks about fifty new articles that would need to be added.

Also keep in mind it's not a structured learning resource, it was all about emphasizing this or that particular and rarely needed aspect of D and edge cases. Which I think a few of us have been fond of at one point.
February 12, 2021
On Friday, 12 February 2021 at 08:31:13 UTC, Walter Bright wrote:
>
> Yes, having the author do an AMA is very productive.

I'm literally busy writing D!
« First   ‹ Prev
1 2