www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - News/info on Go and Java

reply bearophile <bearophileHUGS lycos.com> writes:
Found on Reddit:

This looks a lot like D:
http://research.swtch.com/2009/11/go-data-structures.html

New features in Java, some of them look like D:
http://code.joejag.com/2009/new-language-features-in-java-7/

Bye,
bearophile
Nov 24 2009
parent reply "Denis Koroskin" <2korden gmail.com> writes:
On Wed, 25 Nov 2009 03:03:59 +0300, bearophile <bearophileHUGS lycos.com>  
wrote:

 Found on Reddit:

 This looks a lot like D:
 http://research.swtch.com/2009/11/go-data-structures.html

 New features in Java, some of them look like D:
 http://code.joejag.com/2009/new-language-features-in-java-7/

 Bye,
 bearophile
Looks like go has arrays that support slices. Do they support appending? If so, what's their behavior and how do they solve stomping issues?
Nov 25 2009
next sibling parent Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
Denis Koroskin wrote:
 On Wed, 25 Nov 2009 03:03:59 +0300, bearophile 
 <bearophileHUGS lycos.com> wrote:
 
 Found on Reddit:

 This looks a lot like D:
 http://research.swtch.com/2009/11/go-data-structures.html

 New features in Java, some of them look like D:
 http://code.joejag.com/2009/new-language-features-in-java-7/

 Bye,
 bearophile
Looks like go has arrays that support slices. Do they support appending? If so, what's their behavior and how do they solve stomping issues?
There's no built-in means to grow a slice. An example given in "Effective Go" appends to slices without regard to stomping or dissolving sharing: http://golang.org/doc/effective_go.html Slices are obese pointers storing the pointer/length/capacity troika. I think D is in better shape here. Andrei
Nov 25 2009
prev sibling parent reply Sergey Gromov <snake.scaly gmail.com> writes:
Wed, 25 Nov 2009 12:27:59 +0300, Denis Koroskin wrote:

 On Wed, 25 Nov 2009 03:03:59 +0300, bearophile <bearophileHUGS lycos.com>  
 wrote:
 
 This looks a lot like D:
 http://research.swtch.com/2009/11/go-data-structures.html
Looks like go has arrays that support slices. Do they support appending? If so, what's their behavior and how do they solve stomping issues?
Arrays are values and cannot be resized after creation. var array [10]int; Arrays can be sliced like in D: var slice []int = array[5:7]; The length of this slice is len(slice) == 7 - 5 == 2. The *capacity* of this slice is cap(slice) == 10 - 5 == 5. You can slice a slice beyond its length, up to capacity: var slice2 []int = slice[4:5]; Effectively slice is a tail of an array, with optional subdivision into sub-head and sub-tail. There is no array nor slice concatenation, nor any other way to change slice length except slicing.
Nov 26 2009
parent reply bearophile <bearophileHUGS lycos.com> writes:
Sergey Gromov:
     var slice []int = array[5:7];
Is []int better than int[] ? [5:7] is a slice syntax a bit better than [5..7] (and it's used in Python). But in D [5:7] is the literal for an AA... Bye, bearophile
Nov 26 2009
next sibling parent retard <re tard.com.invalid> writes:
Thu, 26 Nov 2009 11:58:23 -0500, bearophile wrote:

 Sergey Gromov:
     var slice []int = array[5:7];
Is []int better than int[] ? [5:7] is a slice syntax a bit better than [5..7] (and it's used in Python). But in D [5:7] is the literal for an AA...
You could change to syntax for AAs to be 5 -> 7 since D doesn't use -> for lambdas :) And even when D starts supporting them, they could use => instead.
Nov 26 2009
prev sibling parent Sergey Gromov <snake.scaly gmail.com> writes:
Thu, 26 Nov 2009 11:58:23 -0500, bearophile wrote:

 Sergey Gromov:
     var slice []int = array[5:7];
Is []int better than int[] ?
Well, try to read aloud int[5][10]. I come up with "Integer, five of them, ten times." While [10][5]int is "Array of ten arrays of integers." It's *much* clearer.
 [5:7] is a slice syntax a bit better than [5..7] (and it's used in
 Python). But in D [5:7] is the literal for an AA... 
In Go, it'd be map[int]int{5:7}.
Nov 26 2009