Re: packages revisited
- From: budden <budden-lisp@xxxxxxx>
- Date: Fri, 3 Apr 2009 14:14:11 -0700 (PDT)
Hi Tim!
I'm pretty sure that things like parsingdates and times are *not* the sort of thing
you want to add to the general CL reader.
I see no reason for not doing that. Tokens
like 2009.04.04:23:59:59 are senseless in CL,
why don't give them a sense? Of course, parsing
any hairy date representation like Monday,14,205 BC
is out of the scope of general reader, but having
a simple default seem to be reasonable. I'm short
in a resources now, but I really need to input and
output dates to/from SQL for my current work.
Frankly, I see no difference between integer
and a date. Both are primitive and practically
important data types and I see no reason why
there is a syntax for integers and there is no
syntax for date/time in a high-level language.
Meanwhile, I've finally came to conclusion that
it is impossible for me to understand True Lispers
and vice versa. I even have admitted that and this
does not hurt me anymore. So let me avoid further
debate :)
My answer to that is that, if there are clashes,
I always want to end up in the debugger (or somewhere
equivalent), because it always indicates a problem
with the code which I will need to think about.
In SQL, you have error only when you trying to use
clashing symbols, but not at the time when the conflict
becomes possible. When you join two tables with the same
fields, you may have no clash report. E.g.
create table foo (id int, name char(1));
create table bar (id int, short_name char(5));
select name from foo,bar;
In a last statement, between "select" and "from"
we have a temporarily merged namespace with all
fields from foo and bar.
You can refer to 'name' as it does not clash.
But you can't refer to id w/o qualifier:
select id from foo,bar /* error */
You can do
select foo.id from foo.bar /* no error */
This behavior is practical, I'm using it for
14 years in SQL and I see no contradiction with any
aspect of CL standard which would prevent using it
in CL.
The only thing we need is to allow multiple arguments
for in-package form:
(in-package :a-package :cl :other-library-package)
When reader meets unqualified symbol name, it looks for
it in every package we are "in". If there is an internal
symbol with that name in :a-package, or external symbol
with that name in &rest, and there is only one symbol
of that kind, it is used.
If there is no such symbol, it is interned to :a-package
Otherwise (more than one), error occurs.
So, for all clashing symbols, error would occur at the
time symbol name is about to be interned, not at the
time when in-package form is evaluated.
Advantages:
- if you don't use symbol a-package::foo clashing
with cl:foo, you need not care if it clashes.
Just use non-clashing a-package::bar and cl:quux
- if you use foo, you get to debugger as you wish
- a-package need not import symbols from cl-user.
So, a-package can be kept very small.
For a practical use, IDEs need to be changed a bit
too. Otherwise symbol completion won't work. So, while
I am able to redefine in-package form as I need, I
won't do that as I use some closed-source
IDE I'm unable to modify.
merge-packages-and-reexport suffice, it
requires no change to CL and it doesn't
harm completion.
Pascal uses similar clash resolution policy, but
clashing symbols do not report a error. First of
clashing symbols is used instead. This policy is
sometimes reasonable too. In fact, I'm using it
most frequently in merge-packages-and-reexport but
it is even harder to admit for True Lispers.
Also I've developed a tool which intercepts
attempts to intern one of listed symbol names to
a wrong package (other than package listed for that
symbol name). This tool is implementation-depended,
but it helped me a lot to refactor my code and
reorganize my packages layout.
I have already written about all that before and
noone understood me. I have no resources for proving
that this is more convinient than CL standard package
behaviour. I just use my merge-packages-and-reexport
in my code rather massively and I found that this is
really convinient and useful. Much more convinient
than other package handling techniques I've tried
before or that I read about. I'm not going to appeal
to anyone to follow me, but I will use this approach
until I stop using CL at all.
.
- Follow-Ups:
- Re: packages revisited
- From: Tamas K Papp
- Re: packages revisited
- From: Thomas A. Russ
- Re: packages revisited
- From: budden
- Re: packages revisited
- References:
- Re: packages revisited
- From: budden
- Re: packages revisited
- From: Thomas A. Russ
- Re: packages revisited
- From: Tim Bradshaw
- Re: packages revisited
- Prev by Date: Re: macro design question -- delimiting the arguments with keywords
- Next by Date: Re: macro design question -- delimiting the arguments with keywords
- Previous by thread: Re: packages revisited
- Next by thread: Re: packages revisited
- Index(es):
Relevant Pages
|