Quoting Bakul Shah (2019-01-02 03:07:14) > On Tue, 01 Jan 2019 22:56:06 -0800 Ian Lance Taylor <i...@golang.org> wrote: > > On Tue, Jan 1, 2019 at 6:42 PM Bakul Shah <ba...@bitblocks.com> wrote: > > > > > > On Tue, 01 Jan 2019 03:34:34 -0800 =?UTF-8?B?5LyK6Jek5ZKM5Lmf?= > > > <kazya.ito.dr...@gmail.com> wrote: > > > > > > > > What are the reasonable reasons to use pointers? Are pointers neseccary? > > > > > > Pointers are not necessary as a programming language feature > > > but are necessary in implementing a programming language. As > > > an example, Scheme doesn't have pointers. > > > > Scheme doesn't have pointers in the same sense that Java doesn't have > > pointers: in both Scheme and Java all non-primitive types are > > represented using pointers. So while it's true that the languages > > don't have pointers, you still have to understand that you are always > > dealing with reference types. > > True but I'd rather keep pointers seperate from shared state. > There are other languages such as k that do pass compound > objects by value. Thus in k > > x:1 2 3 4 > f:{[v]v[1]:5} // similar to (define (f v) (vector-set! v 1 5)) > f x > > does *not* modify x. [It does this by using copy-on-write]
Immutability also makes the abstraction less leaky; If you never mutate (and ignore nils) then the difference between: struct { int x; Foo y } and: struct { int x; Foo *y } May have performance implications, but is ultimately an implementation detail. A compiler could even attempt to optimize based on e.g. the size of Foo. -- 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+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.