Menu

#15 policy on convenience functions

design_question
open
nobody
wheat core (23)
5
2004-02-11
2004-01-11
No

The code is inconsistent about when it provides
convenience functions and when not.

For example: The core functionality of getting an object
from a path would entail something like this:

pt::string contextString = "/library/render/context";
Path contextPath(contextString);
ObjectPointer contextOp = NameSpace::path(contextPath);

But the programmer really wants to write just:

ObjectPointer contextOp = NameSpace::path("/library/
render/context");

or perhaps even:

ObjectPointer contextOp("/library/render/context");

To achieve this, the code could rely on a combination of
C++ automatic conversions and convenience functions.

Possible converisons are:
pt::string::string(const char*);
Path::Path(const char*);
Path::Path(const pt::string&);
ObjectPointer::ObjectPointer(const char*);
ObjectPointer::ObjectPointer(const pt::string&);
ObjectPointer::ObjectPointer(const Path&);

Possible convenience functions are:
NameSpace::path(const char*);
NameSpace::path(const pt::string&);

Remember that C++ will only apply one user supplied
conversion function per argument...

This needs some thought and I'm not sure what the right
answer is.

Discussion

  • Mark Lentczner

    Mark Lentczner - 2004-01-12
    • labels: --> wheat core
     
  • Mark Lentczner

    Mark Lentczner - 2004-02-11
    • milestone: --> 375469
     
  • Mark Lentczner

    Mark Lentczner - 2004-02-11
    • milestone: 375469 --> design_question
     

Log in to post a comment.