Re: Specifying callbacks for behaviours extending gen_server

Fernando Benavides <[email protected]>
Newsgroups gmane.comp.lang.erlang.general
Message-ID <CA+yhPj6KRSEQtDM8Mz+HKmf_MLsoStWd0VqfyWYpRLBSBYUB_A@mail.gmail.com>
What if you only specify your own callbacks and let your implementors use...

-behavior(your behavior).
-behavior(gen_server).

?

On Tue, 23 Feb 2021 at 16:15 Brett Hemes <[email protected]> wrote:

> I am designing a behaviour that extends gen_server and thus I want all of
> gen_server’s callback specification in addition to some additional ones on
> top as part of the extension.  In the past I have favored using the
> `-callback` attribute as recommended in the documentation but then I saw
> someone recommend the following when extending gen_server
>
>
>
> > behaviour_info(Type) -> gen_server:behaviour_info(Type).
>
>
>
> I tried combining the two approaches but such is not allowed (which makes
> sense).  I believe my options are to append my callbacks to gen_server’s
> list using `behaviour_info` or to copy gen_server’s callback specifications
> from the OTP source.  Copy-pasting code just feels wrong...  how bad is it
> to use `behaviour_info` over `-callback`?  And am I taking the right
> approach?
>
>
>
> Thanks,
>
> Brett
>
-- 
Sent from Gmail Mobile by Brujo Benavides
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.