object namespaces

object namespaces

Post by Ken Alverso » Tue, 05 Feb 2002 11:05:35



I'm betting this has been discussed before, but I can't find the right set
of words to look it up in google groups, so here goes.  If the issue has
been beat to death, please just point me at the discussion to read, thanks!

Is there a reason we can't use an object name in place of a type name to
access typedefs and/or static fields of the type?  Asking by example, why
hasn't this been made valid:

foo::iterator i = find(foo.begin(),foo.end(),bar);

instead of the current:

vector<int>::iterator i = find(foo.begin(),foo.end(),bar);

If the type of foo ever changes, the second version breaks but the first
wouldn't.  I know the break is trivial to fix, and I know typedef's can
mitigate the problem, but even then if foo changed to a different typedef
the code would break.  The first version would tightly bind the iterator
type to the type of the container, which as far as I can tell would be a
good thing.  Short of an automatic type specifier, this solves the problem
in a pretty logical way that looks like it would be (relatively) simple to
implement.  Is it:

- Planned for the next revision!
- Solves a problem that isn't worth solving?
- Not high enough priority?
- Seriously flawed in some manner?

Ken

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]

[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]

 
 
 

object namespaces

Post by Olaf Krzikall » Tue, 05 Feb 2002 21:34:21


Hi,


> Is there a reason we can't use an object name in place of a type name to
> access typedefs and/or static fields of the type?  Asking by example, why
> hasn't this been made valid:

I have asked myself about this point several times, too. In fact, if you
treat a typedef inside a class similiar to a static member, there seems
no reason to not allow things like

v.iterator i = v.begin();

I guess, the next standard will contain several ways to compute a type
from an expression. This one could be useful.

Best regards,
Olaf Krzikalla

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]

[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]

 
 
 

object namespaces

Post by Daveed Vandevoor » Wed, 06 Feb 2002 03:53:44



> I'm betting this has been discussed before, but I can't find the right set
> of words to look it up in google groups, so here goes.  If the issue has
> been beat to death, please just point me at the discussion to read, thanks!

> Is there a reason we can't use an object name in place of a type name to
> access typedefs and/or static fields of the type?  Asking by example, why
> hasn't this been made valid:

> foo::iterator i = find(foo.begin(),foo.end(),bar);

> instead of the current:

> vector<int>::iterator i = find(foo.begin(),foo.end(),bar);

I suspect this would add a considerable amount of complexity to
the expression-vs-declaration dismabiguation rules.  Would you
also allow long expressions in place of foo?  Are expressions
evaluated when used as such?

I think the typeof operator is more promising an extension for
this sort of stuff:

        typeof(foo)::iterator i = ...

No need to guess whether you're dealing with the beginning of a
declaration, or just an expression.

        Daveed

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]

[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]

 
 
 

object namespaces

Post by Michiel Salte » Wed, 06 Feb 2002 06:31:51



> Is there a reason we can't use an object name in place of a type name to
> access typedefs and/or static fields of the type?  Asking by example, why
> hasn't this been made valid:

> foo::iterator i = find(foo.begin(),foo.end(),bar);

> instead of the current:

> vector<int>::iterator i = find(foo.begin(),foo.end(),bar);

[SNIP]

Quote:> Short of an automatic type specifier, this solves the problem
> in a pretty logical way that looks like it would be (relatively) simple to
> implement.  Is it:

> - Planned for the next revision!
> - Solves a problem that isn't worth solving?
> - Not high enough priority?
> - Seriously flawed in some manner?

It's a more restricted alternative to

typeof(foo)::iterator i = //...

__typeof() is an (experimental?) extension of GCC, and
possibly other compilers. It can be used in more situations.
If introduced for these situations, it takes away or diminishes
most of the advantages of your solutions, IMO.

Regards,
--
Michiel Salters

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]

[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]

 
 
 

object namespaces

Post by Ken Alverso » Thu, 07 Feb 2002 05:46:16



Quote:

> It's a more restricted alternative to

> typeof(foo)::iterator i = //...

I didn't even think of that...it's a little wordier, but it does make a lot
of sense.  Thanks to those who responded!

Ken

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]

[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]

 
 
 

object namespaces

Post by Dave Harr » Fri, 08 Feb 2002 05:58:26



Quote:> > typeof(foo)::iterator i = //...

> I didn't even think of that...it's a little wordier, but it does make a
> lot of sense.

Some people have suggested supporting this use of typeof explicitly,
either with a new keyword (eg "let") or by adopting an existing one (eg
"auto").

    let i = find(foo.begin(),foo.end(),bar);
    auto i = find(foo.begin(),foo.end(),bar);

This avoids the need to repeat the expression whose type we want, a
redundancy that makes maintainance harder. It is also much shorter and
simpler, and it more directly expresses what we want to say.

Personally I think C++ would be more fun to work with if it had either of
these, as well as typeof.

  Dave Harris, Nottingham, UK | "Weave a circle round him thrice,

                              |  For he on honey dew hath fed
 http://www.bhresearch.co.uk/ |   And drunk the milk of Paradise."

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]

[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]

 
 
 

object namespaces

Post by Ken Alverso » Sat, 09 Feb 2002 03:20:46




> > > typeof(foo)::iterator i = //...

> > I didn't even think of that...it's a little wordier, but it does make a
> > lot of sense.

> Some people have suggested supporting this use of typeof explicitly,
> either with a new keyword (eg "let") or by adopting an existing one (eg
> "auto").

>     let i = find(foo.begin(),foo.end(),bar);
>     auto i = find(foo.begin(),foo.end(),bar);

I like it!  I hope it or some variant thereof makes it in.

Ken

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]

[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]

 
 
 

1. Shell Namespace : How to create a namespace like "My Computer"

Hello From Paris

For a very high secured project, I need to create a Shell Namespace like
"My Computer". The main idea is to not allow the user to reach any devices
(A to Z), but, the user will access to some other folders where the path
is unknown for them. For example, the left pane of the explorer should
look like :

Desktop
 + My Computer
   + Local Private Storage
   + Remote Private Storage
   + Remote Public Storage
   + Floppy Disk
   + CD-ROM
 + Recycler Bin
 + (Other namespaces)

So when the user click on "Local Private Storage", the file showed in the
right pane are located on "C:\Users\JohnDoe", and when the user click on
"Remote Private Storage", the file showed in the right pane are located
on "Z:\Users\JohnDoe", and so on.

A solution have been tested : A namespace with the IShellFolder interface.
All methods (BindToObject, GetUIOfObject, ...) are forwarded to an
IShellFolder interface created with the following code :

    SHGetDesktopFolder(&pDesktopFolder)
    pDesktopFolder->ParseDisplayName(..., wsFolderPath, ... , ppidlFolder,
...)
    pDesktopFolder->BindToObject(*ppidlFolder, ... , IID_IShellFolder,
ppFolder)

With the explorer view, the namespace works fine on the left pane. But in
the
right pane, since a double click is done on one the folders, the explorer is
stopped without any exception.

I'm looking for someone how have already done such shell namespace ?

Thanks a lot

F.GARCIA

2. Question: Programming the wd8003e Ethernet adaptor

3. Root shell namespace and Nonroot namespace.

4. how can I set up a PPP dial-in connection in Win 95?

5. Namespaces: IE4's Address Bar blank for my namespace.

6. ADS Programming

7. Enums in namespaces v/s classes in namespaces.

8. Having difficulty printing reports.

9. Global namespace vs. base class namespace

10. Namespace Maintenance, Parent Namespace?

11. namespaces in XML and namespaces in C++

12. namespace aliases and extension-namespace-definition

13. Namespace extension to override CD-ROM drive object?