package::(...) syntax

For a long time, Allegro CL has allowed a syntax like this:

foo::(bar baz quux)

The "foo::" prefix reads the subsequent sexp as though the current package was the "foo" package.

SBCL 1.0.55 introduced support for this syntax as well. I've started to use it more and more, because I sometimes enter stuff like this at the REPL:

(ql-dist:ensure-installed (ql-dist:system "foo"))

Now I can use this:

ql-dist::(ensure-installed (system "foo"))

It saves me the trouble of inheriting or importing symbols, or switching packages, for simple one-off stuff in the REPL. I don't use it in source files — I don't feel like being that gratuitiously unportable.

Thanks to Nikodemus Siivola for adding this capability to SBCL.

Tags:

Comments

Symbolics too

Neat, I like this feature. I think the Symbolics had it too. I didn't use it all that often, but it's handy when you do need it. So, if every symbol is exported, can you do pkg:(....)?

Re: Symbolics too

No, it only works with :: regardless of export status.

Write a CDR!

The syntax is very useful. Not only, if memory does not fail me, ANSI reserves the ::: separator for other package reader related issues.

My proposal: write a CDR to specify it in an implementation dependent way (just don't look at me: I have my hands full).

MA