Review of Jose Armando Garcia Sancio's std.log

Steven Schveighoffer schveiguy at yahoo.com
Mon Mar 12 04:57:10 PDT 2012


On Mon, 12 Mar 2012 01:26:54 -0400, Jose Armando Garcia  
<jsancio at gmail.com> wrote:

> On Wed, Mar 7, 2012 at 6:39 AM, Steven Schveighoffer
> <schveiguy at yahoo.com> wrote:
>> On Wed, 07 Mar 2012 07:09:17 -0500, Steven Schveighoffer
>> <schveiguy at yahoo.com> wrote:
>>>
>>> What is wrong with
>>>
>>> import std.log;
>>> log.info("cool");
>>
>>
>> alternatively:
>>
>> log_info("cool");
>> linfo("cool");
>> lginfo("cool");
>>
>> There are so many choices besides just "info."  We should use something
>> else.
>>
>
> Lets flip the question. Why are you against:
>
> import log = std.log;

I'm against having a requirement (or at least a strong suggestion) to  
import std.log in a certain way other than import std.log.  There are a  
couple problems with this:

1. Almost all code examples in modules use import modulename;  They don't  
have some documentation that says "you should probably import modulename  
by import modulename = modulename".  For an example of this, see  
http://www.dsource.org/projects/tango/docs/stable/tango.io.Path.html
2. With no guarantees that everyone will use "log" as the symbol (or even  
use the symbol), you potentially have several files using std.log under  
different symbols.  For example, someone might prefer "logger" or "lg".   
This just makes things more confusing than is necessary.

I'm not actually against using this technique, I'm just against making it  
standard practice.  I feel using a naming scheme which eliminates having  
to use this trick to be able to keep your existing names and/or use these  
common names as members would foster more uniform code and usage.  That's  
all.

Yes, this is a form of bikeshedding, but it's one of those things that  
will be difficult to change later.  Even just changing the names of the  
functions which log to something less common, like I stated above, could  
be worth a lot.

I won't vote against the lib if this is my only objection, but I do think  
it's important.  If others don't, well, I guess we'll see what happens.  I  
likely will be using import log = std.log whenever I use it.

-Steve


More information about the Digitalmars-d mailing list