Re: Good examples of value types

2015-05-07 Thread via Digitalmars-d
On Thursday, 7 May 2015 at 02:09:34 UTC, Freddy wrote: It doesn't matter whether they are by value or by ref but by value usually has performance increases(especially considering you can by a value type by ref in D if you need to). Yep, this is very much true, but on x86 the register size is

Re: Good examples of value types

2015-05-07 Thread Russel Winder via Digitalmars-d
On Thu, 2015-05-07 at 07:36 -0700, Andrei Alexandrescu via Digitalmars-d wrote: […] Reference types don't compose nicely that way. In a language with valye types, the juxtaposition of two items (value or reference) is a va;ue. In Java, it's a reference (so you need to allocate a new object

Re: Good examples of value types

2015-05-07 Thread Nikolay via Digitalmars-d
java.lang.String It is big problem in java. You have pointer to String object with fields: hashCode and chars array (UTF-16). But every array is object itself. So it is pointer to object again. There is pointer compression option in x64 JVM (it uses 32 bits per pointer), but in any way it is

Re: Good examples of value types

2015-05-07 Thread Andrei Alexandrescu via Digitalmars-d
On 5/7/15 12:29 PM, Russel Winder via Digitalmars-d wrote: On Thu, 2015-05-07 at 07:36 -0700, Andrei Alexandrescu via Digitalmars-d wrote: […] Reference types don't compose nicely that way. In a language with valye types, the juxtaposition of two items (value or reference) is a va;ue. In Java,

Re: Good examples of value types

2015-05-07 Thread Andrei Alexandrescu via Digitalmars-d
On 5/7/15 4:15 AM, Dejan Lekic wrote: On Tuesday, 5 May 2015 at 20:40:59 UTC, Luís Marques wrote: Hi, For a comparison with the Java language, I'm trying to come up with some good examples of custom types that should be value types (but that must be ref types in Java). I think the most obvious

Re: Good examples of value types

2015-05-07 Thread Dejan Lekic via Digitalmars-d
On Tuesday, 5 May 2015 at 20:40:59 UTC, Luís Marques wrote: Hi, For a comparison with the Java language, I'm trying to come up with some good examples of custom types that should be value types (but that must be ref types in Java). I think the most obvious ones are numeric types. So BigNum,

Re: Good examples of value types

2015-05-06 Thread Russel Winder via Digitalmars-d
On Wed, 2015-05-06 at 02:07 +, deadalnix via Digitalmars-d wrote: […] Let me tell you an actual war story of mine. I think you need to date the story, and say with GC was being used. We have this program that is computationally intensive written in java. Somewhere in the core of the

Re: Good examples of value types

2015-05-06 Thread Dominikus Dittes Scherkl via Digitalmars-d
On Wednesday, 6 May 2015 at 02:07:40 UTC, deadalnix wrote: Problem is, all these entries needs to be value types (we are in java) Maybe you meant reference types here?

Re: Good examples of value types

2015-05-06 Thread deadalnix via Digitalmars-d
On Wednesday, 6 May 2015 at 09:20:50 UTC, Russel Winder wrote: On Wed, 2015-05-06 at 02:07 +, deadalnix via Digitalmars-d wrote: […] Let me tell you an actual war story of mine. I think you need to date the story, and say with GC was being used. It is relatively recent (a little

Re: Good examples of value types

2015-05-06 Thread Justin Whear via Digitalmars-d
On Wed, 06 May 2015 16:54:46 +, Luís Marques wrote: * Regular expressions - I have no idea what you have in mind for this one; even after looking at std.regex... I meant both patterns and matches/captures. * Tokens - On the one hand, I think this could be an excellent example, since it's

Re: Good examples of value types

2015-05-06 Thread deadalnix via Digitalmars-d
On Wednesday, 6 May 2015 at 18:28:28 UTC, Luís Marques wrote: On Wednesday, 6 May 2015 at 18:05:57 UTC, deadalnix wrote: Without going into the details, we had entries in a DB, counting in the millions in the working set. Some of them where hammered heavily, most of them were only needed an

Re: Good examples of value types

2015-05-06 Thread via Digitalmars-d
On Wednesday, 6 May 2015 at 18:05:57 UTC, deadalnix wrote: Without going into the details, we had entries in a DB, counting in the millions in the working set. Some of them where hammered heavily, most of them were only needed an handful of time. Problem is, there was no way upfront to know

Re: Good examples of value types

2015-05-06 Thread via Digitalmars-d
On Wednesday, 6 May 2015 at 02:07:40 UTC, deadalnix wrote: Let me tell you an actual war story of mine. We have this program that is computationally intensive written in java. Somewhere in the core of the program, we have a LRU cache, with some entries sticking in there, and most entry

Re: Good examples of value types

2015-05-06 Thread amiga via Digitalmars-d
On Wednesday, 6 May 2015 at 02:07:40 UTC, deadalnix wrote: On Tuesday, 5 May 2015 at 20:40:59 UTC, Luís Marques wrote: Hi, For a comparison with the Java language, I'm trying to come up with some good examples of custom types that should be value types (but that must be ref types in Java). I

Re: Good examples of value types

2015-05-06 Thread deadalnix via Digitalmars-d
On Wednesday, 6 May 2015 at 17:01:05 UTC, Luís Marques wrote: That's sounds like a great story! What kind of values were you caching? Without going into the details, we had entries in a DB, counting in the millions in the working set. Some of them where hammered heavily, most of them were

Re: Good examples of value types

2015-05-06 Thread deadalnix via Digitalmars-d
On Wednesday, 6 May 2015 at 08:50:19 UTC, Dominikus Dittes Scherkl wrote: On Wednesday, 6 May 2015 at 02:07:40 UTC, deadalnix wrote: Problem is, all these entries needs to be value types (we are in java) Maybe you meant reference types here? Yes, sorry for the confusion.

Re: Good examples of value types

2015-05-06 Thread via Digitalmars-d
On Tuesday, 5 May 2015 at 21:04:22 UTC, Justin Whear wrote: Dates, times, durations, regular expressions, tokens, lazy generators, digests, vectors, really any type that provides a interpretation/behavior wrapper around one or more trivially copyable types. That's a very nice list, thank

Re: Good examples of value types

2015-05-06 Thread Freddy via Digitalmars-d
On Tuesday, 5 May 2015 at 20:40:59 UTC, Luís Marques wrote: Hi, For a comparison with the Java language, I'm trying to come up with some good examples of custom types that should be value types (but that must be ref types in Java). I think the most obvious ones are numeric types. So BigNum,

Re: Good examples of value types

2015-05-05 Thread deadalnix via Digitalmars-d
On Tuesday, 5 May 2015 at 20:40:59 UTC, Luís Marques wrote: Hi, For a comparison with the Java language, I'm trying to come up with some good examples of custom types that should be value types (but that must be ref types in Java). I think the most obvious ones are numeric types. So BigNum,

Good examples of value types

2015-05-05 Thread via Digitalmars-d
Hi, For a comparison with the Java language, I'm trying to come up with some good examples of custom types that should be value types (but that must be ref types in Java). I think the most obvious ones are numeric types. So BigNum, MyNum, etc. are good examples because programmers are used

Re: Good examples of value types

2015-05-05 Thread Justin Whear via Digitalmars-d
On Tue, 05 May 2015 20:40:58 +, Luís Marques wrote: could you come up with some type that would really benefit from being a value type but that isn't numeric (or otherwise similar)? Dates, times, durations, regular expressions, tokens, lazy generators, digests, vectors, really any type