Jump to page: 1 2 3
Thread overview
Advent of D
Mar 06, 2018
David Gileadi
Mar 06, 2018
Joakim
Mar 06, 2018
Adam D. Ruppe
Mar 07, 2018
Mike Parker
Mar 07, 2018
Mike Parker
Mar 07, 2018
Mike Parker
Mar 08, 2018
Ali Çehreli
Mar 06, 2018
Patrick Schluter
Mar 07, 2018
Andrea Fontana
Mar 06, 2018
JN
Mar 07, 2018
Russel Winder
Mar 09, 2018
Russel Winder
March 06, 2018
I wrote a blog post about working on Advent of Code in D. You can read it here:

http://jordi.inversethought.com/blog/advent-of-d/
March 06, 2018
On 3/6/18 11:09 AM, Jordi Gutiérrez Hermoso wrote:
> I wrote a blog post about working on Advent of Code in D. You can read it here:
> 
> http://jordi.inversethought.com/blog/advent-of-d/

I really enjoyed this. Thank you!
March 06, 2018
On Tuesday, 6 March 2018 at 18:09:21 UTC, Jordi Gutiérrez Hermoso wrote:
> I wrote a blog post about working on Advent of Code in D. You can read it here:
>
> http://jordi.inversethought.com/blog/advent-of-d/

What's with the mammoth D blog posts lately? Nice write-up, worth sharing on reddit/HN.
March 06, 2018
On Tuesday, 6 March 2018 at 18:09:21 UTC, Jordi Gutiérrez Hermoso wrote:
> I wrote a blog post about working on Advent of Code in D. You can read it here:
>
> http://jordi.inversethought.com/blog/advent-of-d/

Really nice, thank you.
March 06, 2018
On 3/6/18 1:09 PM, Jordi Gutiérrez Hermoso wrote:
> I wrote a blog post about working on Advent of Code in D. You can read it here:
> 
> http://jordi.inversethought.com/blog/advent-of-d/

I'm enjoying this.

One thing jumped out at me: static does not mean execute at compile time (exactly), it really means allocate this data in thread-local storage.

What triggers the compile-time execution is the fact that static *initializers* need to be decided at compile time.

So while it is executing the regex building at compile time in your example, there are other ways to do it, and in this case, I'd prefer using an enum. You can also use ctRegex.

The drawback of using static is that it keeps its value between function calls:

int bar() { return 42; }

void foo()
{
   static x = bar();
   x += 5;
   writeln(x);
}

void main()
{
   foo(); // 47
   foo(); // 52
}

So it may not be what you are looking for.

Whereas if you use:

void foo()
{
    enum x = bar();
    writeln(x + 5);
}

it will always write the same answer (and not allocate global space for it).

BTW, that tour page needs updating, it has a few errors in it.

-Steve
March 06, 2018
On Tuesday, 6 March 2018 at 18:09:21 UTC, Jordi Gutiérrez Hermoso wrote:
> I wrote a blog post about working on Advent of Code in D. You can read it here:
>
> http://jordi.inversethought.com/blog/advent-of-d/

on Day 8, I think the original "verbose" code is better in the end. Mixin at least for me makes it a bit less clear on what exactly is going on. On the other hand the latter version is probably easier to maintain and more copy-paste-error-proof.

March 06, 2018
On Tuesday, 6 March 2018 at 20:09:58 UTC, Joakim wrote:
> Nice write-up, worth sharing on reddit/HN.

Thanks. I tried posting it to HN, but it didn't pick up. If several of you try posting it too, it might pick up.

Posting to Reddit is easier, but I don't have a recognisable account on Reddit to post it from.

I did post it to Lobsters, though:

https://lobste.rs/s/b4qki7/advent_d
March 06, 2018
On Tuesday, 6 March 2018 at 21:03:47 UTC, JN wrote:
> On Tuesday, 6 March 2018 at 18:09:21 UTC, Jordi Gutiérrez Hermoso wrote:
>> I wrote a blog post about working on Advent of Code in D. You can read it here:
>>
>> http://jordi.inversethought.com/blog/advent-of-d/
>
> on Day 8, I think the original "verbose" code is better in the end. Mixin at least for me makes it a bit less clear on what exactly is going on. On the other hand the latter version is probably easier to maintain and more copy-paste-error-proof.

Yeah, it's mostly the C&P that I wanted to get rid of. I do wish the static foreach had worked, though! It's odd that you can't have compile-time associative arrays.

March 06, 2018
On Tuesday, 6 March 2018 at 20:37:34 UTC, Steven Schveighoffer wrote:
> On 3/6/18 1:09 PM, Jordi Gutiérrez Hermoso wrote:
>> I wrote a blog post about working on Advent of Code in D. You can read it here:
>> 
>> http://jordi.inversethought.com/blog/advent-of-d/
>
> I'm enjoying this.
>
> One thing jumped out at me: static does not mean execute at compile time (exactly), it really means allocate this data in thread-local storage.

Thanks for the explanation. I forgot about using enum instead. I think I've only briefly encountered it before. I'm aware of the global storage of static in this context. I like that it's the same keyword for static foreach; that's kind of what I was thinking when I wrote that just adding a static can result in compile-time execution.

> BTW, that tour page needs updating, it has a few errors in it.

You mean the Dlang tour? I've been meaning for a while to be able to generate a url to its Gems section but I've never managed to untangle its Vibe.d structure enough to do so.

March 06, 2018
On Tuesday, 6 March 2018 at 21:09:06 UTC, Jordi Gutiérrez Hermoso wrote:
> I did post it to Lobsters, though:

This is random but I have been thinking about asking for a lobsters invite... can you hook me up?
« First   ‹ Prev
1 2 3