FAQ
Hello,

Since I started working with go, I tried to program without generics. Now,
I see the go authors implemented a custom stack for the Node struct in
https://code.google.com/p/go/source/browse/html/node.go?repo=net

What's the guideline of Go authors, re-implementing the stack (and other
data structures) for each type, or define it once for interface{} and use
that one?

Thank you,
Laurent Debacker

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Kyle Lemons at Aug 31, 2013 at 3:59 pm
    The guidance is to do whatever's best for your program. If you use a lot
    of a particular datastructure with a lot of different types and don't mind
    the extra cycles and the potential for runtime panics, you can make an
    interface{} version. Specializing it for a few types is generally pretty
    easy, though, and you don't lose any performance. That being said, stacks
    are trivial to do with slices, and don't really even require a special type
    (same with queues): see
    SliceTricks<https://code.google.com/p/go-wiki/wiki/SliceTricks>
    .

    On Sat, Aug 31, 2013 at 12:41 AM, Laurent Debacker wrote:

    Hello,

    Since I started working with go, I tried to program without generics. Now,
    I see the go authors implemented a custom stack for the Node struct in
    https://code.google.com/p/go/source/browse/html/node.go?repo=net

    What's the guideline of Go authors, re-implementing the stack (and other
    data structures) for each type, or define it once for interface{} and use
    that one?

    Thank you,
    Laurent Debacker

    --
    You received this message because you are subscribed to the Google Groups
    "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedAug 31, '13 at 7:41a
activeAug 31, '13 at 3:59p
posts2
users2
websitegolang.org

2 users in discussion

Laurent Debacker: 1 post Kyle Lemons: 1 post

People

Translate

site design / logo © 2022 Grokbase