On Wednesday, 7 January 2015 at 16:45:11 UTC, Tobias Pankrath
wrote:
On Wednesday, 7 January 2015 at 16:23:38 UTC, John Colvin wrote:
On Wednesday, 7 January 2015 at 16:15:49 UTC, Tobias Pankrath
wrote:
http://dpaste.dzfl.pl/3bbdecfefa5c
I'm not sure about some of that. Bad casts w.r.t.
immutability etc.
How about:
http://dpaste.dzfl.pl/706ab2db9ce1
I would keep the encryption inside a template to prevent
users from assigning it to a variable without triggering CTFE.
Why would that be a problem?
Because the plain text will be in the object file.
http://dpaste.dzfl.pl/95b17fff42c6
Take a look at the object file and you will find “Sailor Moon”
in it - which is what we wanted to avoid in the first place.
I'd prefer the API that prevents something like that.
Ah yes.
Nonetheless - if you possibly can - don't use casts to/from
immutable, it's so easy to be in undefined-behaviour-land and not
even notice. In this case it's a textbook use of pure to avoid it.
Also, I presume you are aware of the parametrised enum/alias
syntax?
enum encrypt(string s) = foo(s);