On Tue, Jun 11, 2013 at 11:22 AM, Jakob Ovrum <span dir="ltr"><<a href="mailto:jakobovrum@gmail.com" target="_blank">jakobovrum@gmail.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On Tuesday, 11 June 2013 at 13:13:56 UTC, Daniel Murphy wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Also, compress is a ridiculously general name for a function.<br>
</blockquote>
<br></div>
We have module-level functions called "copy" (multiple), "read", "write", "map", etc. already, and it's not a bad thing!<br>
<br>
It's OK because the full name is not "compress", but "std.compression.lz77.<u></u>compress". This way, how specific the code wants to be depends on the user and the particular use-case, instead of one-size-fits-all alternatives like "lz77Compress". There's no redundancy in the name yet we still have the option to be pin-point specific (e.g. static import), and yes, we still get to use UFCS!<br>

<br>
To eliminate the UFCS problem - which doesn't happen very often (how often do you want to use two different compression algorithms in the same unit?), we can (must?) use renamed symbols when importing.<br></blockquote>
<div><br></div><div>I have found a better way to do that: see <a href="http://forum.dlang.org/post/mailman.1002.1370829729.13711.digitalmars-d-learn@puremagic.com">http://forum.dlang.org/post/mailman.1002.1370829729.13711.digitalmars-d-learn@puremagic.com</a></div>
<div>subject: 'best way to handle UFCS with ambiguous names: using std.typetuple.Alias!'</div><div>syntax: 'arg1.Alias!(std.file.write).arg2'* </div><div>see related discussion for reasoning. I'd like to push this as standard way to deal with ambiguities.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Since any example using multiple "compress" functions would be contrived, I'll use an existing conflict - the case of "copy".<br>
<br>
The following program backs up the specified files and writes a nicely formatted message to stdout (OK, so a tiny bit contrived):<br>
----<br>
void main(string[] args)<br>
{<br>
        import std.algorithm : chain, copy, joiner;<br>
        import std.array : empty;<br>
        import std.file : fileCopy = copy; // `fileCopy` is std.file.copy<br>
        import std.stdio : stdout;<br>
<br>
        auto fileNames = args[1 .. $];<br>
<br>
        foreach(fileName; fileNames)<br>
                fileName.fileCopy(fileName ~ ".bak");<br>
<br>
        if(!fileNames.empty)<br>
                "Backed up the following files: "<br>
                        .chain(fileNames.joiner(", "))<br>
                        .copy(stdout.<u></u>lockingTextWriter());<br>
}<br>
----<br>
<br>
By eliminating redundancies from symbol names, we empower the user, and the module system offers all the tools necessary to solve conflicts in a variety of ways.<br>
</blockquote></div><br><div><br></div><div><br></div>