Named arguments via struct initialization in functions
Idan Arye via Digitalmars-d
digitalmars-d at puremagic.com
Wed Mar 9 12:27:51 PST 2016
On Wednesday, 9 March 2016 at 13:39:57 UTC, Martin Tschierschke
wrote:
> On Wednesday, 9 March 2016 at 12:55:16 UTC, Idan Arye wrote:
> [...]
>>> [...]
>
>
>> [...]
> Thats true.
>> [...]
> Yes.Ok.
> What I like about the :symbol notation is, that a string witch
> is used
> only to distinguish between different objects in an Hash / AA
> has a complete different
> purpose than a string used to be displayed for the user.
>
> I think that
> writeln("Name", a[:name]); is easier to read, than
> writeln("Name", a["name"]);
>
> especially if the structures are getting bigger, or you are in
> a vibe.d jade template string where you would have to use
> additional quoting to write:
>
> a(href="a[\"url\"]") a["link_text"]
>
> a(href="a[:url]") a[:link_text]
>
> May be I should get rid of this by using a struct for my mysql
> results to display?
> (=> a.url and a.link_text )
>
> Just my 2 Cents :-)
If nested strings is what's bothering you, you can always use
backticks. Or opDispatch(though I don't recommend it, as it tends
to screw up compilation errors). But these won't let you have
fields with different types, and since Voldemort types are so
easy in D you are probably better off with structs.
More information about the Digitalmars-d
mailing list