Multiple return values

Andrew Wiley wiley.andrew.j at gmail.com
Thu Jan 5 01:03:47 PST 2012


On Thu, Jan 5, 2012 at 2:47 AM, F i L <witte2008 at gmail.com> wrote:
> Jacob Carlborg wrote:
>>
>> C#, Java and similar language doesn't support free functions like D does.
>> Then they have to resort to "hacks" like static methods, i.e.
>> Console.WriteLine.
>
>
> D's free functions and simple module design are definitely points in it's
> favor. However that wasn't really my point. I was saying that from an
> non-C/C++/D perspective, "Console.WriteLine()" makes more immediate sense
> than "std.writeln()" albeit only marginally. Both Java and C# use a less
> cryptic naming convention in their standard libraries which I think helps
> when learning a language. For instance, "std.container" makes me think of a
> cup, while "System.Collections" makes me think of a bundle. It's probably
> just me, but for awhile I thought D didn't have a standard linked list
> structure because I kept looking in std.array for it.
>

You're pointing out two completely different things here. C#
PascalCases methods and D camelCases them. That's a completely
seperate issue from the actual names.
std.writeln() is incorrect, you would just use writeln(), which looks
perfectly sane if you're used to seeing free functions. It will look
strange initially if you're from a Java/C# background, but it's a free
function because conceptually it *should* be a free function. If you
want to force yourself to qualify your code with namespaces, use
static imports and write std.stdio.writeln().
As for the names, you'll find they relate more to C and C++ libraries
than to Java and C#, which I would argue is a good thing because the
design ideals are closer to C and C++.


More information about the Digitalmars-d mailing list