[Zope3-dev] interface conventions: default=_RAISE_ERROR
Tres Seaver
tseaver@zope.com
11 May 2002 19:21:12 -0400
On Fri, 2002-05-10 at 20:19, Gary Poster wrote:
> On Friday 10 May 2002 07:54 pm, Steve Alexander wrote:
> > Gary Poster wrote:
> > > Instead, my suggestion is to place
> > > _RAISE_ERROR=Object()
> >
> > It needs to be object(), not Object()
>
> heh. I knew that. Been writing in other languages lately. Sorry.
>
> > > in the __init__ of the Interfaces package. An interface that wants to
> > > use the default marker would simply
> > > from Interface import Interface, _RAISE_ERROR
> > > and implementations could import from their interfaces or from the
> > > original declaration in the Interface package.
> >
> > I really wouldn't bother. It saves very little typing, adds to the
> > complexity of finding out what things really mean, adds another
> > dependency, and saves a few hundred bytes at most per runtime.
>
> I disagree that it adds to complexity in
> readability. The dependency is upon the Interface package, upon which an
> interface (and any component) is dependent upon anyway.
>
> But the savings in both typing and efficiency are minimal, agreed. So why
> bother?
>
> My argument is for gracefulness, and perhaps for some small reduction in
> fragility. I think it is clunky, for instance, for the placeful component
> architecture functions to have to check for their own default marker
> interface and then translate their default marker interface to the particular
> service default marker interface, if found. If you do not agree with my
> suggestion, the placeful component architecture functions have to import the
> individual markers for each of the services at the top of the module, the
> coder has to make sure that the correct service marker is substituted for the
> placeful CA marker, and all of a suden you are talking about a lot of fluff
> code that just swaps some objects around. Why?
I would say that clients should *never* explicitly pass the "faux"
default argument ('_marker', or whatever) into a function which uses it
to declare such a semantic; the whole point of it is to signal what
happens when nothing is passed! If its name is '_RAISE_ERROR', then
it should raise without calling any other underlying function at all,
obviating the need to propagate it.
Tres.
--
===============================================================
Tres Seaver tseaver@zope.com
Zope Corporation "Zope Dealers" http://www.zope.com