difference between ::foo::woof and foo::woof? 
Author Message
 difference between ::foo::woof and foo::woof?

I see some code using the leading :: in namespace stuff; other bits and
pieces don't. The man page says that '::' is a synonym for ``''.

So, which is the preferred syntax? Does it make any difference which is
used?

I'm new to namespaces and figure I might as well learn the right habits
in the beginning.

--
   __
  /  )      /         Bob van der Poel

/___/_(_) /_)         http://www.*-*-*.com/ ~bvdpoel



Fri, 08 Nov 2002 03:00:00 GMT  
 difference between ::foo::woof and foo::woof?

Quote:
> I see some code using the leading :: in namespace stuff; other bits and
> pieces don't. The man page says that '::' is a synonym for ``''.

> So, which is the preferred syntax? Does it make any difference which is
> used?

Use preceding :: in all cases where you mean to root it globally.
These two mean different things:
        namespace eval foo { set woof {} }
        namespace eval foo { set ::woof {} }

The same goes for procs and vars.      

--
   Jeffrey Hobbs                     The Tcl Guy
   hobbs at ajubasolutions.com       Ajuba Solutions (ne Scriptics)



Fri, 08 Nov 2002 03:00:00 GMT  
 difference between ::foo::woof and foo::woof?
  Namespaces are like a tree. Use the leading :: to specify a namespace
from the root.
  Think of it like a file system: in this case the separator is the slash
(/) where in namespaces it is ::. As for the leading ::, remember 'ls
some_dir'
is different of 'ls /some_dir', so are 'namespace eval some_ns {...}' and
'namespace eval ::some_ns {...}'.

  Jose' Gabadinho


Quote:
> I see some code using the leading :: in namespace stuff; other bits and
> pieces don't. The man page says that '::' is a synonym for ``''.

> So, which is the preferred syntax? Does it make any difference which is
> used?

> I'm new to namespaces and figure I might as well learn the right habits
> in the beginning.

> --
>    __
>   /  )      /         Bob van der Poel

> /___/_(_) /_)         http://users.uniserve.com/~bvdpoel



Sat, 09 Nov 2002 03:00:00 GMT  
 difference between ::foo::woof and foo::woof?

Quote:

>  Namespaces are like a tree. ...
>  Think of it like a file system: ...

Is there something like "." and ".." for namespaces ?

scnr
--
Hi! I'm a signature virus! Copy me into your signature file to help me spread!
(Note: I'm actually quite an evil virus, so delete all your *.doc files now!)



Sat, 09 Nov 2002 03:00:00 GMT  
 difference between ::foo::woof and foo::woof?
Quote:


> >  Namespaces are like a tree. ...
> >  Think of it like a file system: ...

> Is there something like "." and ".." for namespaces ?

. ~= [namespace current]
.. ~= [namespace parent]
--
Schoene Gruesse/best regards, Richard Suchenwirth - +49-7531-86 2703
RC DT2, Siemens Electrocom, Buecklestr. 1-5, D-78467 Konstanz,Germany
-------------- http://purl.org/thecliff/tcl/wiki//Richard*Suchenwirth
AL:The Analytical Engine worketh not! CB:What version dost thou have?


Sat, 09 Nov 2002 03:00:00 GMT  
 difference between ::foo::woof and foo::woof?
Hi, Bob!

"::" are like slashes in filenames.  Without the leading "::" it's
a relative namespace; with it, it's an absolute namespace.  If you're
referencing it from the global namespace, e.g., your application code,
they are the same.

I always include the leading "::" in library code; it's less likely
to cause obscure errors later on.  In application code, I always
say I *should* use the leading "::", but sometimes I get sloppy.

If you haven't, you might want to look at my Guide to Success
with Namespaces and Packages:\; it's at

     http://www.wjduquette.com/tcl

Will

On Mon, 22 May 2000 15:45:54 -0700, Bob van der Poel

Quote:

>I see some code using the leading :: in namespace stuff; other bits and
>pieces don't. The man page says that '::' is a synonym for ``''.

>So, which is the preferred syntax? Does it make any difference which is
>used?

>I'm new to namespaces and figure I might as well learn the right habits
>in the beginning.

>--
>   __
>  /  )      /         Bob van der Poel

>/___/_(_) /_)         http://users.uniserve.com/~bvdpoel

--------------------------------------------------------------------------

But I speak only    | http://eis.jpl.nasa.gov/~will (JPL Use Only)
for myself.         | It's amazing what you can do with the right tools.


Sat, 09 Nov 2002 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Difference between $foo and [set foo]

2. A use for "foo = foo()"

3. if foo.__class__ == Foo: #in C?

4. foo.py vs. foo.pyc

5. eval $foo - does $foo get bytecompiled?

6. $foo == "" or [llength $foo] == 0

7. Date format from [file atime/mtime foo.foo]

8. Proof, or Woof?

9. 'foo' = #foo -> true or false?

10. %w(foo) v.s. ['foo']

11. "import foo" and "from foo import bar"

12. is (member # :test 'foo) -> :test #'foo optimization allowed?

 

 
Powered by phpBB® Forum Software