lua-users home
lua-l archive

Re: Defining APIs, best practices.

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Fri, Dec 14, 2012 at 6:33 PM, Coda Highland <chighland@gmail.com> wrote:
> If and only if the function detects the difference between (nil) and
> (). If the function is called enable, and I call it as enable(), I
> would expect it to enable the object -- that is, the same as
> enable(true), not enable(false)! So it's messy.
>
> For this reason I prefer setEnabled(bool) over enable(bool), which
> also means the matching predicate is isEnabled().
about semantics and names:
i'd expect a "enable()" function to always enable. and a
"setEnabled()" to take a flag.
no mess with "enable()==enable(nil)==enable(false)==disable()"
--
Javier

AltStyle によって変換されたページ (->オリジナル) /