This is the mail archive of the kawa@sourceware.org mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Default Namespace


Volkan YAZICI wrote:
Is it possible to change the default namespace?

It is not possible in Kawa Scheme (though it is possible when using the Kawa implementation of XQuery).

(It is possible to change the package of a module with the -P flag.)

Moreover, what's the
default namespace if there isn't defined/used any?

The empty or blank namespace.


Consider I define a
namespace via below command.

(define-namespace comm-bridge "http://rd.foocorp.com/comm-bridge";)

Do I have to to explicitly specify the namespace each time? For
instance,

  (define (comm-bridge:trace-channel channel-matches? log-package)
    ...)

Yes.


BTW, this could be a trivial question but would anybody mind making a
brief explanation of the differences between a Java package and a Kawa
namespace?

It is a little confusing ...


A namespace is a way to use compound names, with a name "local" to the
namespace.  A namespace-prefix is a short way to reference a name.
You can use two different prefixes to refer to the same namespace.
Namespaces aren't hierarchical.  They're orthogonal to Java packages:
All the classes (named or implicit) in the same source file are
normally in the same Java package.  (You can override this, but
I don't recommend it.)

For example, in mod1.scm:

(define-namespace xx "XXX")
(define-namespace yy "YYY")
(define (xx:foo x) "XXX:foo called")
(define (yy:foo x) "YYY:foo called")

Another module can do:

(require <mod1>)
(define-namespace xx "YYY") ;; Notice swap
(define-namespace yy "XXX")
(list (xx:foo) (yy:foo))
==> ("YYY:foo called" "XXX:foo called")

A source of confusion is that colon is also used for a
more general "get named component of something" operation.  I.e.:
  FOO:NAME
means get the NAME component of FOO.  FOO can be a namespace
or namespace alias, but it can also be a package name, a
class name, or object.  See:
http://www.gnu.org/software/kawa/PathExpressions.html
Hence, you can can alias a package name to a namespace prefix,
using define-alias.

This all needs to be documented better.  I'm working on it!
--
	--Per Bothner
per@bothner.com   http://per.bothner.com/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]