[R-sig-DB] Add a "dbSendUpdate" function to DBI?

Prof Brian Ripley r|p|ey @end|ng |rom @t@t@@ox@@c@uk
Fri Sep 5 08:40:19 CEST 2014


On 04/09/2014 22:22, Paul Gilbert wrote:
>
>
> On 09/04/2014 03:15 PM, Hadley Wickham wrote:
>>> It is the "If the API" part that I worry about. For example
>>>
>>>> success(warning("warn"))
>>> Warning message:
>>> In doTryCatch(return(expr), name, parentenv, handler) : warn
>>>> is.logical(success(warning("warn")))
>>> [1] FALSE
>>> Warning message:
>>> In doTryCatch(return(expr), name, parentenv, handler) : warn
>>>>
>>>
>>> So then every package writer trying to build on DBI has to write a
>>> wrapper
>>> that anticipates the exceptions that may be thrown. This becomes even
>>> more
>>> difficult when different db drivers, different OSes, and different
>>> servers
>>> are involved.
>>
>> I'm not sure I follow, because we hadn't talked about warnings. I
>> would not expect that DBI backends to through warnings instead of
>> errors.
>
> Well, in my experience my programs usually fail for the reasons I don't
> expect rather than the ones I do expect. I guess that is mainly why I
> like a function that returns a logical, I know what to expect.
>
>>
>>> Given the philosophical constraint I think I would generally prefer the
>>> function that is guaranteed to return a logical. The other wrapper is
>>> easy
>>> to write too.
>>
>> But it's fundamentally more dangerous. If all modification functions
>> return TRUE or FALSE and you don't explicit check the return value, it
>> is extremely easy to create invalid code. The same is not true for
>> errors.
>
> If I understand your logic correctly, you would recommend using
> library() rather than require() when one of them is necessary in a
> function? Or rather, you would not provide require(), only library()? (I
> always use require(), and check the return value.) It is, of course,

You are wrong: see 
http://cran.r-project.org/doc/manuals/r-patched/R-exts.html#Suggested-packages

Code in functions should not change the search path, and it does not 
achieve what most people seem to think it does.

-- 
Brian D. Ripley,                  ripley using stats.ox.ac.uk
Emeritus Professor of Applied Statistics, University of Oxford
1 South Parks Road, Oxford OX1 3TG, UK




More information about the R-sig-DB mailing list