Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to make package names case insensitive

2 views
Skip to first unread message

Sharad

unread,
Apr 3, 2007, 8:37:40 AM4/3/07
to
Hi

I need my package names to be case insensitive, i.e., if my package is
foo
package require foo
package require foO
package require fOo
package require fOO
package require Foo
package require FoO
package require FOo
package require FOO

all should point to the same package. I do not want to calculate and
copy-paste all possible variations because it becomes troublesome when
the package name is long.

Any ides on this.

Thanks in advance.

Regards
Sharad

Andreas Leitgeb

unread,
Apr 3, 2007, 9:22:14 AM4/3/07
to
Sharad <shara...@gmail.com> wrote:
> I need my package names to be case insensitive,
> i.e., if my package is foo
> package require foo
> package require foO
> package require fOo
> [...should all find "foo"...]

While I don't understand why anyone would want to do that,
you can perhaps work with [package unknown] and attempt
to do the mapping yourself.

Alternatively, you could override the command package, and
have it try the original name and - upon failure of that -
retry with [string tolower ...].

But still: what sense does it make?

Larry W. Virden

unread,
Apr 3, 2007, 10:21:27 AM4/3/07
to
On Apr 3, 9:22 am, Andreas Leitgeb <a...@gamma.logic.tuwien.ac.at>
wrote:

> Sharad <sharad1...@gmail.com> wrote:
> > I need my package names to be case insensitive,

> While I don't understand why anyone would want to do that,

While the OP's example did seem, to me, quite extreme, I have to admit
that I've longed for Tcl to provide case insensitive behavior for
package require, since I can never remember whether it is TclX, Tclx,
tclx, tclX, or whatever. I have the same desire for the man command,
so that I can look up the string for the package. And of course, not
all package developers create a man page using the package name (and
in tclx's case, the man page is called TclX and the package is
Tclx ... sigh)

Bryan Oakley

unread,
Apr 3, 2007, 10:42:14 AM4/3/07
to
Andreas Leitgeb wrote:
> Sharad <shara...@gmail.com> wrote:
>> I need my package names to be case insensitive,
>> i.e., if my package is foo
>> package require foo
>> package require foO
>> package require fOo
>> [...should all find "foo"...]
>
> While I don't understand why anyone would want to do that,

Boy, I can.

package require Tcl
package require tile
package require BWidget

There are three variations among three of the most popular packages
there are.

If the package mechanism was case-insensitive the world would be a
better place. Really -- has there ever been a problem that was solved by
case-sensitive package names?

--
Bryan Oakley
http://www.tclscripting.com

Uwe Klein

unread,
Apr 3, 2007, 10:40:08 AM4/3/07
to
package related namespaces don't make it easier either:

BLT -> blt::*

uwe

Don Porter

unread,
Apr 3, 2007, 10:51:56 AM4/3/07
to
Bryan Oakley wrote:
> If the package mechanism was case-insensitive the world would be a
> better place. Really -- has there ever been a problem that was solved by
> case-sensitive package names?

Case-sensitive package names supports the convention that packages
meant for wide distribution ought to have all lowercase names, while
packages developed for internal "in-house" use ought to include at
least one upper case character. If this convention is followed one
can have confidence that their in-house work will not conflict with
any package they choose to retrieve and use.

A nice idea, but while it's been recommended for at least a decade,
folks continue to distribute packages with WackyCaps names and worse,
and no, not all of them have the excuse of being grandfathered in.

If we'd hit the grandfathers 10 years ago, perhaps fewer folks would
have followed their unconventional example.

--
| Don Porter Mathematical and Computational Sciences Division |
| donald...@nist.gov Information Technology Laboratory |
| http://math.nist.gov/~DPorter/ NIST |
|______________________________________________________________________|

Don Porter

unread,
Apr 3, 2007, 10:55:28 AM4/3/07
to
Uwe Klein wrote:
> package related namespaces don't make it easier either:
>
> BLT -> blt::*

And there again, the Style Guide conventions for more than 10 years
have said Don't Do That. But folks don't follow conventions, they
copy and modify working examples, and when those examples predate the
convention and never adapt to it, we get what we have.

Uwe Klein

unread,
Apr 3, 2007, 11:16:27 AM4/3/07
to
Don Porter wrote:
> Bryan Oakley wrote:
>
>> If the package mechanism was case-insensitive the world would be a
>> better place. Really -- has there ever been a problem that was solved
>> by case-sensitive package names?
>
>
> Case-sensitive package names supports the convention that packages
> meant for wide distribution ought to have all lowercase names, while
> packages developed for internal "in-house" use ought to include at
> least one upper case character. If this convention is followed one
> can have confidence that their in-house work will not conflict with
> any package they choose to retrieve and use.
>
Then
Tclx is for inHouse use only and
BLT should never see the daylight ;-)

uwe

Bryan Oakley

unread,
Apr 3, 2007, 11:59:56 AM4/3/07
to
Don Porter wrote:
> Bryan Oakley wrote:
>> If the package mechanism was case-insensitive the world would be a
>> better place. Really -- has there ever been a problem that was solved
>> by case-sensitive package names?
>
> Case-sensitive package names supports the convention that packages
> meant for wide distribution ought to have all lowercase names, while
> packages developed for internal "in-house" use ought to include at
> least one upper case character.

Interesting. That's the first time I've heard of that convention. Or,
maybe I heard it 10 years ago and thought "that doesn't apply to *me*" :-)

That's certainly a reasonable use for case-sensitive package names.

I guess Tk and Tcl are for internal use only then? :-)

Andreas Leitgeb

unread,
Apr 3, 2007, 12:58:59 PM4/3/07
to
Bryan Oakley <oak...@bardo.clearlight.com> wrote:
> Andreas Leitgeb wrote:
>> Sharad <shara...@gmail.com> wrote:
>>> I need my package names to be case insensitive,
>>> i.e., if my package is foo
>>> package require foo
>>> package require foO
>>> package require fOo
>>> [...should all find "foo"...]
>> While I don't understand why anyone would want to do that,
> Boy, I can.
> package require Tcl
> package require tile
> package require BWidget

In my understanding of the OP, it was all about packages that
the OP wrote him/herself, so if he/she creates a package with
wacky capitalization, it's him/her to suffer him/herself.

I agree that the capitalization of certain pre-existing and *common*
packages is a problem in itself, that might even justify making
package names case-insensitive. But one's *own* packages ???
As if one hadn't control over those...

Hemang Lavana

unread,
Apr 3, 2007, 1:31:00 PM4/3/07
to
Wouldn't it make sense to remove this restriction now so that it doesn't
matter whether a package is loaded using "package require BWidget" or
"package require bwidget". Package authors can continue to create
packages with whacky names but at the least the end users would not be
subject to this confusion. Moreover, with introduction of Tcl Modules,
some bit of case-insensitive requirement has already crept in. See the
following excerpt from TIP 189 (http://www.tcl.tk/cgi-bin/tct/tip/189.html):

Given the above we allow the names for packages in Tcl modules to
have mixed-case, but also require that there are no collisions when
comparing names in a case-insensitive manner. In other words, if a
package 'Foo' is deployed in the form of a Tcl Module, packages like
'foo', 'fOo', etc. are not allowed anymore.

So I think it is time to make the [package require] loading
case-insensitive. Unless there are packages out there where foo and Foo
have completely different features (which is highly unlikely but you
never know), I suspect that making package names case-insensitive is not
going to have any backwards compatibility issues.

Hemang.

Donald Arseneau

unread,
Apr 3, 2007, 2:57:29 PM4/3/07
to
Hemang Lavana <hla...@cisco.com> writes:

> Bryan Oakley wrote:
> > Andreas Leitgeb wrote:
> >> Sharad <shara...@gmail.com> wrote:
> >>> I need my package names to be case insensitive,
> >

> Wouldn't it make sense to remove this restriction now so that it doesn't
> matter whether a package is loaded using "package require BWidget" or
> "package require bwidget".

Moreover, the existing case-sensitivity is a temptation for
people to create packaes like "bWidget". It's what the
layers call an attractive nuisance.

--DA

Donal K. Fellows

unread,
Apr 4, 2007, 6:38:48 AM4/4/07
to
Bryan Oakley wrote:
> I guess Tk and Tcl are for internal use only then? :-)

Well, I keep around nice whisky for internal use only too...

Donal.

Larry W. Virden

unread,
Apr 4, 2007, 7:26:47 AM4/4/07
to
On Apr 3, 10:55 am, Don Porter <d...@nist.gov> wrote:

> But folks don't follow conventions, they
> copy and modify working examples, and when those examples predate the
> convention and never adapt to it, we get what we have.

Everyone who is frustrated with this topic should pick an extension
and contact a maintainer and point them to this thread, asking them to
follow the style guide conventions.

http://209.85.165.104/search?q=cache:ehzR5PjSxBgJ:www.tcl.tk/doc/styleGuide.pdf+tcl+style+guide&hl=en&ct=clnk&cd=1&gl=us
is an HTML version of the style guide. See section 3 for the naming
recommendations.

suchenwi

unread,
Apr 4, 2007, 7:34:20 AM4/4/07
to
If a package comes with a man page (it should), the case quirks may be
annoying, but aren't really a problem IMO:

...
SYNOPSIS
package require WhatEver ?0.1?
...
"If it's documented, it's a feature" :^)

Larry W. Virden

unread,
Apr 4, 2007, 11:50:46 AM4/4/07
to
On Apr 4, 7:34 am, "suchenwi" <richard.suchenwirth-

Only if you can figure out the man page to look it up. However, it
would be better to follow the style guidelines so that the developer
need not guess or go hunting, given that at least one (and probably
more) common extension doesn't even come with man pages (BWidgets...)

Joe English

unread,
Apr 4, 2007, 8:09:06 PM4/4/07
to
Bryan Oakley wrote:
>Andreas Leitgeb wrote:
>> While I don't understand why anyone would want to do that,
>
>Boy, I can.
>
>package require Tcl
>package require tile

Which will become "package require Ttk" in 8.5, sigh ...


>package require BWidget
>
>There are three variations among three of the most popular packages
>there are.
>
>If the package mechanism was case-insensitive the world would be a
>better place. Really -- has there ever been a problem that was solved by
>case-sensitive package names?

One that I can think of:

Since every release of tcllib tends to include multiple new modules,
but it (mostly) follows the official guideline that package names
are all-lowercase, applications can avoid future nameclashes by
using Titlecase for "private" packages.


--Joe English

Sharad

unread,
Apr 5, 2007, 8:06:59 AM4/5/07
to
Any ideas on the original question.
Assuming that is my requirement - what options do I have, if at all ?

Regards
Sharad

Andreas Leitgeb

unread,
Apr 5, 2007, 11:02:51 AM4/5/07
to
Sharad <shara...@gmail.com> wrote:
> Any ideas on the original question.
> Assuming that is my requirement - what options do I have, if at all ?

My suggestion is to re-read the thread and find the
couple of postings where your question is indeed addressed.

If you don't understand the particular answer, followup on that.

0 new messages