FAQ
implementing generics
https://github.com/anlhord/go/commit/1eef19b08a793e8d8e83eb2114d9e77ef72bfc92

  so i've got this toy.go in my repo

https://github.com/anlhord/generic/blob/master/toy/toy.go

I get

./toy.go:95: cannot use &a (type **[]int) as type *generic.Container in
argument to Init
./toy.go:96: cannot use &a (type **[]int) as type *generic.Container in
argument to Destroy
./toy.go:97: cannot use &b (type **[]byte) as type *generic.Container in
argument to Init
./toy.go:98: cannot use &b (type **[]byte) as type *generic.Container in
argument to Destroy
./toy.go:99: cannot use &c (type **interface {}) as type *generic.Container
in argument to Init
./toy.go:100: cannot use &c (type **interface {}) as type
*generic.Container in argument to Destroy
./toy.go:106: cannot use &a (type **[]int) as type *generic.Container in
argument to At


now I want to break the type safety and to cast **[]int and **interface{}
to my *generic.Container type.

looked at ./cmd/gc/typecheck.c , seems fairly complex.

please give me some advice
thanks

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

Search Discussions

  • Anlhord at Dec 18, 2014 at 4:17 pm
    the modified go with generics is here:
    https://github.com/anlhord/go/tree/generics

    the tests live here:
    https://github.com/anlhord/untypedslice

    next i'm planning to fix the todo's in tests.
    i'm need assistance from someone who undestands src/cmd/gc

    I need to add a Type to the node.
    Need to generate the correct stuff for the reflect.c to work.
    Also need to fix typecheck.c


    On Monday, December 15, 2014 6:50:09 PM UTC+1, anl...@gmail.com wrote:

    implementing generics

    https://github.com/anlhord/go/commit/1eef19b08a793e8d8e83eb2114d9e77ef72bfc92

    so i've got this toy.go in my repo

    https://github.com/anlhord/generic/blob/master/toy/toy.go

    I get

    ./toy.go:95: cannot use &a (type **[]int) as type *generic.Container in
    argument to Init
    ./toy.go:96: cannot use &a (type **[]int) as type *generic.Container in
    argument to Destroy
    ./toy.go:97: cannot use &b (type **[]byte) as type *generic.Container in
    argument to Init
    ./toy.go:98: cannot use &b (type **[]byte) as type *generic.Container in
    argument to Destroy
    ./toy.go:99: cannot use &c (type **interface {}) as type
    *generic.Container in argument to Init
    ./toy.go:100: cannot use &c (type **interface {}) as type
    *generic.Container in argument to Destroy
    ./toy.go:106: cannot use &a (type **[]int) as type *generic.Container in
    argument to At


    now I want to break the type safety and to cast **[]int and **interface{}
    to my *generic.Container type.

    looked at ./cmd/gc/typecheck.c , seems fairly complex.

    please give me some advice
    thanks
    --
    You received this message because you are subscribed to the Google Groups "golang-dev" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Alan Donovan at Dec 18, 2014 at 5:39 pm

    On 15 December 2014 at 12:50, wrote:
    please give me some advice
    Can you explain what you're trying to do?

    --
    You received this message because you are subscribed to the Google Groups "golang-dev" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Anlhord at Dec 19, 2014 at 1:38 am
    hello. sure.

    I've added the [] type to the go compiler. I call it untyped slice.

    long term "idea" is to use this object as a building block for a full
    generics.

    currently I'm trying to use this in simple programs and get them to compile.

    i want the type checker to automatically determine the type of element.
    this will allow short slice declaration:

    foo := []{1,2,3}
    bar := []{"aa","bb"}

    what do you think

    long term goal is to get the triple() function to work:
      https://github.com/anlhord/untypedslice/blob/master/t2.go

    its a test function that should work for slice of any type.

    I also need every advice about how go/src/cmd/gc/ works, how to debug it
    how the lex.c works
    how typechecking works etc.. basically everything there is. I'm new to
    compiler programming.

    thank you.
    On Thursday, December 18, 2014 6:39:56 PM UTC+1, Alan Donovan wrote:
    On 15 December 2014 at 12:50, <anl...@gmail.com <javascript:>> wrote:

    please give me some advice
    Can you explain what you're trying to do?

    --
    You received this message because you are subscribed to the Google Groups "golang-dev" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Robert Griesemer at Dec 19, 2014 at 1:58 am
    Hi anlhord;

    Thanks for the info on your project. It's always fun to hack/extend an
    existing language and experiment with new features.

    That said, since the Go the language is frozen (besides consistency or
    security fixes), and thus no language changes will be made in the
    foreseeable future, experiments like this are better announced/discussed on
    the golang-nuts mailing list.

    golang-dev should be used for planned, active library and systems
    development. Thanks.

    - gri

    On Thu, Dec 18, 2014 at 5:38 PM, wrote:


    hello. sure.

    I've added the [] type to the go compiler. I call it untyped slice.

    long term "idea" is to use this object as a building block for a full
    generics.

    currently I'm trying to use this in simple programs and get them to
    compile.

    i want the type checker to automatically determine the type of element.
    this will allow short slice declaration:

    foo := []{1,2,3}
    bar := []{"aa","bb"}

    what do you think

    long term goal is to get the triple() function to work:
    https://github.com/anlhord/untypedslice/blob/master/t2.go

    its a test function that should work for slice of any type.

    I also need every advice about how go/src/cmd/gc/
    <https://goto.google.com/src/cmd/gc/> works, how to debug it how the
    lex.c works
    how typechecking works etc.. basically everything there is. I'm new to
    compiler programming.

    thank you.
    On Thursday, December 18, 2014 6:39:56 PM UTC+1, Alan Donovan wrote:
    On 15 December 2014 at 12:50, wrote:

    please give me some advice
    Can you explain what you're trying to do?

    --
    You received this message because you are subscribed to the Google Groups
    "golang-dev" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to golang-dev+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
    --
    You received this message because you are subscribed to the Google Groups "golang-dev" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Anlhord at Dec 19, 2014 at 2:12 am

    On Friday, December 19, 2014 2:58:21 AM UTC+1, gri wrote:
    Hi anlhord;

    Thanks for the info on your project. It's always fun to hack/extend an
    existing language and experiment with new features.

    That said, since the Go the language is frozen (besides consistency or
    security fixes), and thus no language changes will be made in the
    foreseeable future, experiments like this are better announced/discussed on
    the golang-nuts mailing list.
    I disagree. I feel this is relevant since I read that code is planned to
    being rewritten from C anyway.

    golang-dev should be used for planned, active library and systems
    development. Thanks.

    - gri

    On Thu, Dec 18, 2014 at 5:38 PM, <anl...@gmail.com <javascript:>> wrote:


    hello. sure.

    I've added the [] type to the go compiler. I call it untyped slice.

    long term "idea" is to use this object as a building block for a full
    generics.

    currently I'm trying to use this in simple programs and get them to
    compile.

    i want the type checker to automatically determine the type of element.
    this will allow short slice declaration:

    foo := []{1,2,3}
    bar := []{"aa","bb"}

    what do you think

    long term goal is to get the triple() function to work:
    https://github.com/anlhord/untypedslice/blob/master/t2.go

    its a test function that should work for slice of any type.

    I also need every advice about how go/src/cmd/gc/
    <https://goto.google.com/src/cmd/gc/> works, how to debug it how the
    lex.c works
    how typechecking works etc.. basically everything there is. I'm new to
    compiler programming.

    thank you.
    On Thursday, December 18, 2014 6:39:56 PM UTC+1, Alan Donovan wrote:
    On 15 December 2014 at 12:50, wrote:

    please give me some advice
    Can you explain what you're trying to do?

    --
    You received this message because you are subscribed to the Google Groups
    "golang-dev" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to golang-dev+...@googlegroups.com <javascript:>.
    For more options, visit https://groups.google.com/d/optout.
    --
    You received this message because you are subscribed to the Google Groups "golang-dev" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Brad Fitzpatrick at Dec 19, 2014 at 2:14 am

    On Fri, Dec 19, 2014 at 1:12 PM, wrote:

    On Friday, December 19, 2014 2:58:21 AM UTC+1, gri wrote:

    Hi anlhord;

    Thanks for the info on your project. It's always fun to hack/extend an
    existing language and experiment with new features.

    That said, since the Go the language is frozen (besides consistency or
    security fixes), and thus no language changes will be made in the
    foreseeable future, experiments like this are better announced/discussed on
    the golang-nuts mailing list.
    I disagree. I feel this is relevant since I read that code is planned to
    being rewritten from C anyway.
    We have Go compilers in C, C++, and Go.

    What language the Go compilers are written in doesn't mean we have to
    change the Go language.

    Please move this discussion to golang-nuts. It's a distraction on
    golang-dev because nobody here is planning on working on this, especially
    with such a lack of complete proposal.

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

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-dev @
categoriesgo
postedDec 15, '14 at 6:05p
activeDec 19, '14 at 2:14a
posts7
users4
websitegolang.org

People

Translate

site design / logo © 2021 Grokbase