Tuesday, July 21, 2009

Shino

Not the glaze and not one of the anime characters or other people listed on Wikipedia - but the musician.

This is a great album. I love his voice.

I'm a fan.

Saturday, July 18, 2009

Perl's sitecustomize.pl

Perl has an option to run sitecustomize.pl very early and regardless of what program is running.

The Configure option to enable this is -Dusesitecustomize. See the INSTALL documentation that comes with the perl source for a brief description. It is not enabled by default.

See perlrun for a brief description of how to prevent execution of this script, if it has been enabled. This P5P thread describes how it works.

ActiveState perl may have this option enabled. It did, but I don't know if it does currently.

Another option is to create a configuration module and use this module when running perl. For example, if you create CONF.pm you can invoke your program as: perl -MCONF program.pl. Alternatively, you can set the environment variable PERL5OPT to include "-MCONF", but note that this option may be processed too late if you are using other -M options on the command line.

Friday, July 10, 2009

Of vim, view and swap files

The view command should run vim in read-only mode. In this mode, vim should not use a swap file. But sometimes, if I am editing a file and open the same file with view in another window, vim complains that the swap file already exists. What's going on?

It turns out that vim does not always run without a swap file when in read only mode. If the file is large enough that more memory than maxmem or maxmemtot is required then a swap file is used even in read-only mode.

On my system (CentOS 5.3 with 2GB RAM) both maxmem and maxmemtot default to 252KB. Many of the source files I edit are larger than this and, therefore, swap files are used even in read-only mode.

By setting maxmem and maxmemtot to something larger, swap files can be avoided for larger files. For example, in your .vimrc file you can add:

set maxmem=1024
set maxmemtot=1024

Tuesday, July 7, 2009

Standards, Open and Otherwise

I was reading the Wikipedia page on Open Standards. There certainly are a lot of definitions, and this is only one source. No doubt there are many other definitions. One might conclude that the phrase is only a vague suggestion.

What we need is a standard definition of what an open standard is, so we can all agree to it, and, since it would be too ironic otherwise, I guess that should be an open standard definition of what an open standard is.

Before worrying about what an open standard is, it might be good to determine what a standard is. This is no easier. Wikipedia has a long disambiguation page for "standard". The Free Dictionary has a page of definitions for "standard". There are all sorts of possibilities.

Perhaps we should begin with something basic like: "I think, therefore I am". If we can derive meanings for standard and open standard from this, maybe we can get everyone to agree. The problem with this approach is that, it seems, no one has gotten beyond thinking, which may or may not prove that they are, at least to themselves: but nothing else has yet been derived to general satisfaction.

This doesn't leave much alternative other than providing a definition of the phrase with each use. So, if you see the terms standard or open standard used, don't make any assumptions about what they mean, get a definition of them from the user: this is the only way to know what the user means.

"Open" is sexy. "Open" is good. "Open" is in. "Open" rocks. Lately, marketing types do their best to associate "open" with whatever they are marketing. An "open standard" may simply be a standard that the promoter wants you to believe is good, sexy and in. Just as there are too many lawyers, there are too many marketers who have dedicated their lives to abusing language to subvert your decision making. Don't be sucked in. Read the fine print.

My education and work experience are in engineering and IT. My interest in "standards" is in the context of qualifying things that will be used. Thus the definitions of "standard" that are most relevant to me, from those on the Free Dictionary page, are:
An acknowledged measure of comparison for quantitative or qualitative value; a criterion
and
An object that under specified conditions defines, represents, or records the magnitude of a unit.
and
Something, such as a practice or a product, that is widely recognized or employed, especially because of its excellence.
and
A degree or level of requirement, excellence, or attainment.
Actually, one of their most appealing (to me) definitions isn't in the definition section - it is in the description of the synonyms of "standard":
a point of reference against which individuals are compared and evaluated
And, similarly, in the thesaurus section:
a basis for comparison; a reference point against which other things can be evaluated

When I think of a "standard", this is what I am thinking of.

To be of any use, a standard must be available to the person who is doing the comparison and evaluation. It doesn't have to be available to anyone else, though it may be. When procuring computers, I might define my own standards against which I will compare and evaluate all the candidate systems. I might do this very privately, without letting anyone know what my standards are. Or I might publish my standards in an RFP which I might make available to prospective system vendors subject to a non-disclosure agreement. Or I might publish my standards so that they are available to prospective vendors or others without restrictions on reproduction or use.

Sometimes, two or more otherwise independent entities might agree to a common standard in order to achieve some consistency or compatibility. Many "standards" are published with the intent that others will use them. "Standards organizations" are organizations that specialize in producing such standards. Such organizations may do nothing else other than produce "standards".

Standards may be published to be available to some group of entities. Access to the standard may be very restricted (e.g. I assume Coca Cola has a standard recipe that is available only to its manufacturers around the world - a closely guarded secret never to be disclosed to Pepsi) or unrestricted. Access to a published standard may be subject to entering into an agreement which limits rights to access, use or refer to the standard. The lawyers of proprietors and the law makers have developed diverse means for extracting value from property.

So, what might an "open" standard be?

In contrast, consider what a "proprietary" standard might be. Perhaps the definition of an "open" standard should preclude the promotion or promulgation of any proprietary interest. Proprietary interests are protected and promoted by means which are generally restrictive and compulsive: not what I think of as "open", generally.

In conclusion, my definition of an "open standard" is:

a standard which is not constrained by and does not incorporate, promote or promulgate any proprietary interest.

There is a problem with this definition: in most countries any published standard will be subject to copyright which establishes an unavoidable proprietary interest in the publication and unavoidable proprietary constraints on use of the publication. Therefore there is no such thing as a published standard which is not constrained by proprietary interest, at least not until years later when the copyright expires. So, maybe this definition should be amended to:

a published standard: which is not subject to copyright, or in which the copyright owner explicitly grants permission for anyone to reproduce and use the published standard without fee, royalty or other compensation, and which does not otherwise incorporate, promote or promulgate any proprietary interest.

Friday, July 3, 2009

Little Programming Advice

I didn't, at first, understand the point of Urlich Drepper's article Little Programming Advice, because I didn't see where the conflict was between the variable length array and the alloca allocation. But then, I got it...

The conflict arrises because both variable length arrays and alloca allocations are stack based: the stack is extended to make the required space, but variable length arrays are supposed to be limited to the block they are defined in which alloca allocations are supposed to persist until the subroutine they are made in is exited.

The sample code is:

{
char arr[strlen(s)];
fill_in(arr, s);
s = strdupa(arr);
}


When the block containing the variable length array definition is entered the stack is extended to make space for the array. Presumably (the article doesn't say) this allocation is removed from the stack when the block is exited (it could also be that it is removed when the block is re-entered and when the subroutine is exited). The conflict arises when alloca is used to allocate another block on the stack because the alloca allocation must persist to the end of the subroutine. As the alloca allocation is above the variable length array allocation on the stack, the variable length array allocation can't be freed until after the alloca allocation is freed and this can't happen before the subroutine is exited. A new allocation could be made for the variable length array on every entry to the block, but then these would accumulate, which isn't supposed to happen.

Labels