Re: pbr vs multiple returns
- Posted by Jason Gade <jaygade at yahoo.com> Jan 11, 2007
- 553 views
Chris Bensler wrote: > > Matt Lewis wrote: > > > > Jason Gade wrote: > > > > > > The routine specification tells the user whether the parameter is modified > > > or > > > not. Nothing should be "unexpected". However most routines would not be > > > written > > > to use PBR and probably even fewer library routines. > > > > It might even make sense to make the caller specify pbr, so that both > > the caller and the callee have to agree. That way it's explicit that > > you're allowing and expecting it to change. > > > > Matt > > I would definitely agree that PBR shoud be defined by both the callee and > caller. > I'm not very convinced that PBR is nessecary though. > > Other than convenience and a slight improvement to readability (which is > debatable > IMO), can someone please explain how PBR would be useful compared to multiple > return values? It aint clicking for me. Optimization? Yes, for optimization. If you have medium to large-size sequences (or structures if we get them) that you have to manipulate it is better to modify them directly instead of constantly making copies. Right now the only workaround is to use a global sequence and that is probably just as bad. -- "Any programming problem can be solved by adding a level of indirection." --anonymous "Any performance problem can be solved by removing a level of indirection." --M. Haertel "Premature optimization is the root of all evil in programming." --C.A.R. Hoare j.