Re: First class lazy Interval

2009-02-27 Thread Rainer Deyke
Bill Baxter wrote: > 4..$ > 4u..$ > etc? Aside from the inconsistent meaning of $, you still can't have an inclusive range [a, b], where 'a' and 'b' are not only known at runtime, without treating 'b == int.max' as a special case. -- Rainer Deyke - rain...@eldwood.com

Re: First class lazy Interval

2009-02-27 Thread Bill Baxter
On Sat, Feb 28, 2009 at 1:02 PM, Daniel Keep wrote: > > Yes, a..b is very nice. It's also a bad syntax for intervals. As Don > keeps pointing out, you can't have an interval that includes int.max > with that syntax. > 4..$ 4u..$ etc? --bb

Re: First class lazy Interval

2009-02-27 Thread Michel Fortin
On 2009-02-27 23:02:30 -0500, Daniel Keep said: On the whole, I think the use cases for this sort of syntax are just far too few and specialised to warrant syntax for them, especially when the syntax proposed is very restrictive. Especially when you can do it in a library without too much effo

Re: First class lazy Interval

2009-02-27 Thread Jesse Phillips
On Sat, 28 Feb 2009 02:33:15 +1100, Daniel Keep wrote: > Andrei Alexandrescu wrote: >> Daniel Keep wrote: >>> I don't think this should be in the language... it just feels like >>> there isn't enough use for it. Especially not when you can implement >>> it as a library. >>> >>> As proof, I've att

Re: First class lazy Interval

2009-02-27 Thread Daniel Keep
Michel Fortin wrote: > On 2009-02-27 09:47:30 -0500, Daniel Keep > said: > >>> assert(index in 0.._size); >> >> I don't think this should be in the language... it just feels like there >> isn't enough use for it. Especially not when you can implement it as a >> library. > > Well, if a..b simpl

Re: Resizable Arrays?

2009-02-27 Thread dsimcha
== Quote from dsimcha (dsim...@yahoo.com)'s article > == Quote from Jason House (jason.james.ho...@gmail.com)'s article > > Are there any good reasons to allow built in arrays to be resizable? > > There's already plenty of empirical evidence that building arrays by > > appending > is incredibly sl

Re: First class lazy Interval

2009-02-27 Thread Michel Fortin
On 2009-02-27 09:47:30 -0500, Daniel Keep said: assert(index in 0.._size); I don't think this should be in the language... it just feels like there isn't enough use for it. Especially not when you can implement it as a library. Well, if a..b simply maps to an interval type in the standard

Re: First class lazy Interval

2009-02-27 Thread Michel Fortin
On 2009-02-27 08:44:31 -0500, Andrei Alexandrescu said: Michel Fortin wrote: On 2009-02-27 04:43:46 -0500, bearophile said: D2 supports the interval syntax in the foreach: foreach (i; 1..1000) {...} Such intervals are useful in a very large number of situations. So, with the new Range supp

Re: Resizable Arrays?

2009-02-27 Thread dsimcha
== Quote from Jason House (jason.james.ho...@gmail.com)'s article > Are there any good reasons to allow built in arrays to be resizable? > There's already plenty of empirical evidence that building arrays by appending is incredibly slow. > There are also bugs in bugzilla where resizing arrays after

Re: Resizable Arrays?

2009-02-27 Thread Stewart Gordon
Jason House wrote: Are there any good reasons to allow built in arrays to be resizable? http://www.digitalmars.com/d/2.0/builtin.html There's already plenty of empirical evidence that building arrays by appending is incredibly slow. You need to really get into programming in D and explore

Re: Resizable Arrays?

2009-02-27 Thread Denis Koroskin
On Sat, 28 Feb 2009 04:27:52 +0300, Jason House wrote: BCS Wrote: Reply to tim, > Theres nothing stopping you from having all your arrays static in D. I > think your crazy :) > I think the thought is that arrays can have dynamic length but can't be changed after allocation. Right. Len

Re: dmd platform support - poll

2009-02-27 Thread Christopher Wright
Jarrett Billingsley wrote: On Fri, Feb 27, 2009 at 4:19 AM, bearophile wrote: suresh: In my ideal world (dream :) ) 'gdc' would have been the main line for development and getting it to run on all the above mentioned platforms would be easy. Also take a look at LDC: http://www.dsource.org/pr

Re: Resizable Arrays?

2009-02-27 Thread Jason House
BCS Wrote: > Reply to tim, > > > Theres nothing stopping you from having all your arrays static in D. I > > think your crazy :) > > > > I think the thought is that arrays can have dynamic length but can't be > changed > after allocation. Right. Length is fixed until (re)allication. > star

Re: Resizable Arrays?

2009-02-27 Thread BCS
Reply to tim, Theres nothing stopping you from having all your arrays static in D. I think your crazy :) I think the thought is that arrays can have dynamic length but can't be changed after allocation. starting with: int[] arr = new int[15]; assigning to length arr.length = 30; would

Re: Resizable Arrays?

2009-02-27 Thread Tim M
On Sat, 28 Feb 2009 12:55:44 +1300, Jason House wrote: Are there any good reasons to allow built in arrays to be resizable? There's already plenty of empirical evidence that building arrays by appending is incredibly slow. There are also bugs in bugzilla where resizing arrays after assig

Resizable Arrays?

2009-02-27 Thread Jason House
Are there any good reasons to allow built in arrays to be resizable? There's already plenty of empirical evidence that building arrays by appending is incredibly slow. There are also bugs in bugzilla where resizing arrays after assigning one array to another violates type safety. Those bugs can

Re: Inlining Virtual Functions

2009-02-27 Thread bearophile
dsimcha: > Under what circumstances is this actually true? At the moment I think that spec is pure theory for DMD, even if it's worded to almost sound as the compiler already works like that :-) >As far as I can tell, there is no way DMD could know about the whole class >hierarchy when genera

Inlining Virtual Functions

2009-02-27 Thread dsimcha
According to the spec: "Virtual functions are functions that are called indirectly through a function pointer table, called a vtbl[], rather than directly. All non-static non-private non-template member functions are virtual. This may sound inefficient, but since the D compiler knows all of the cl

Re: First class lazy Interval

2009-02-27 Thread Andrei Alexandrescu
bearophile wrote: As an alternative syntax may be: foreach (i; 1:10) {...} foreach (i; 10 : 1 : -1) {...} foreach (i; 0.0 : 10.5 : 0.5) {...} I have an idea - we define a contextual keyword "iota" that helps us specify from, to, and stride. Then we can write: foreach (i; iota(0.0, 10.5, 0.5

Re: primitive vector types

2009-02-27 Thread Fawzi Mohamed
On 2009-02-23 14:48:50 +0100, Chad J said: Don wrote: So it looks to me as though with the minimal language changes, we could get almost complete SIMD support, with excellent syntax. enum { x=0, y=1, z=2, w=3 } float[4] foo; foo[x] = 42; foo[y] = foo[x]; // etc foo[] = [foo[y],foo[x],foo[y

Re: First class lazy Interval

2009-02-27 Thread bearophile
Don: >How do you specify a uint range that includes uint.max?< The interval I was talking about may generate integers only (it may be possible to generate longs and chars too if you give it long/char extrema, but I am not sure this is a good idea). >This is a perfect example of what Andrei re

Re: First class lazy Interval

2009-02-27 Thread Sean Reque
I think Ruby is a good example of a good way to implement intervals. Ruby exposes them as a class object, so that you can instantiate them as Range.new(min,max), and a Range object iterable and can easily be converted to an array. It also supports inclusion testing. The only thing it doesn't do

Re: dmd platform support - poll

2009-02-27 Thread Jarrett Billingsley
On Fri, Feb 27, 2009 at 4:19 AM, bearophile wrote: > suresh: >> In my ideal world (dream :) ) 'gdc' would have been the main line for >> development >> and getting it to run on all the above mentioned platforms would be easy. > > Also take a look at LDC: > http://www.dsource.org/projects/ldc > Th

Re: dmd platform support - poll

2009-02-27 Thread Jarrett Billingsley
On Fri, Feb 27, 2009 at 4:01 AM, suresh wrote: > Hi Walter, > > I am embedded systems programmer. I crave to use D when I have to use C/C++. > > I would like to see dmd support cross-compilation for ARM(9) family. Downs has gotten GDC to work on ARM at least to an extent. He was using it to make

Re: First class lazy Interval

2009-02-27 Thread Daniel Keep
Andrei Alexandrescu wrote: > Daniel Keep wrote: >> I don't think this should be in the language... it just feels like there >> isn't enough use for it. Especially not when you can implement it as a >> library. >> >> As proof, I've attached an implementation of an integral interval. >> Here's a s

Re: First class lazy Interval

2009-02-27 Thread Andrei Alexandrescu
Daniel Keep wrote: I don't think this should be in the language... it just feels like there isn't enough use for it. Especially not when you can implement it as a library. As proof, I've attached an implementation of an integral interval. Here's a sample of usage (the program prints this if you

Re: First class lazy Interval

2009-02-27 Thread Daniel Keep
Denis Koroskin wrote: > On Fri, 27 Feb 2009 16:44:31 +0300, Andrei Alexandrescu > wrote: >> I'm having trouble understanding what's wrong with the good old data >> types and functions. >> >> Andrei > > The syntax. One may want to reuse 0..100 syntax to generate random number: > auto x = random(0.

Re: First class lazy Interval

2009-02-27 Thread Don
Denis Koroskin wrote: On Fri, 27 Feb 2009 16:44:31 +0300, Andrei Alexandrescu wrote: Michel Fortin wrote: On 2009-02-27 04:43:46 -0500, bearophile said: D2 supports the interval syntax in the foreach: foreach (i; 1..1000) {...} Such intervals are useful in a very large number of situati

Re: First class lazy Interval

2009-02-27 Thread Don
bearophile wrote: D2 supports the interval syntax in the foreach: foreach (i; 1..1000) {...} Such intervals are useful in a very large number of situations. So, with the new Range support, it may be useful to allow the interval syntax to be used in other contexts as well. So x..y may become a

Re: First class lazy Interval

2009-02-27 Thread Denis Koroskin
On Fri, 27 Feb 2009 16:44:31 +0300, Andrei Alexandrescu wrote: Michel Fortin wrote: On 2009-02-27 04:43:46 -0500, bearophile said: D2 supports the interval syntax in the foreach: foreach (i; 1..1000) {...} Such intervals are useful in a very large number of situations. So, with the ne

Re: First class lazy Interval

2009-02-27 Thread Andrei Alexandrescu
Michel Fortin wrote: On 2009-02-27 04:43:46 -0500, bearophile said: D2 supports the interval syntax in the foreach: foreach (i; 1..1000) {...} Such intervals are useful in a very large number of situations. So, with the new Range support, it may be useful to allow the interval syntax to be

Re: First class lazy Interval

2009-02-27 Thread Lutger
bearophile wrote: > Michel Fortin: ... >> Perhaps we could make 3 dots mean an inclusive interval (including the >> second value in the interval), and 2 dots an exclusive one (excluding >> the second value). > > Ruby follows your idea, but for the eye it's easy to miss the extra dot, so I don'

Re: First class lazy Interval

2009-02-27 Thread bearophile
Michel Fortin: > In the D/Objective-C bridge, I've defined the NSRange struct (a Cocoa > type representing an integer interval) so it can be created by typing > NSRange[start..end] in adition to the traditional NSMakeRange(start, > length). It's better than nothing, but even better would be the

Re: First class lazy Interval

2009-02-27 Thread Michel Fortin
On 2009-02-27 04:43:46 -0500, bearophile said: D2 supports the interval syntax in the foreach: foreach (i; 1..1000) {...} Such intervals are useful in a very large number of situations. So, with the new Range support, it may be useful to allow the interval syntax to be used in other contexts

Re: First class lazy Interval

2009-02-27 Thread bearophile
bearophile: > For the compiler that's syntax sugar of (a>0 && a<10). I meant: (a >= 0 && a < 10)

First class lazy Interval

2009-02-27 Thread bearophile
D2 supports the interval syntax in the foreach: foreach (i; 1..1000) {...} Such intervals are useful in a very large number of situations. So, with the new Range support, it may be useful to allow the interval syntax to be used in other contexts as well. So x..y may become a first-class lazy int

Re: dmd platform support - poll

2009-02-27 Thread bearophile
suresh: > In my ideal world (dream :) ) 'gdc' would have been the main line for > development > and getting it to run on all the above mentioned platforms would be easy. Also take a look at LDC: http://www.dsource.org/projects/ldc The backend doesn't support exceptions on Windows (the Linux64 and

Re: dmd platform support - poll

2009-02-27 Thread suresh
Hi Walter, I am embedded systems programmer. I crave to use D when I have to use C/C++. I would like to see dmd support cross-compilation for ARM(9) family. In my ideal world (dream :) ) 'gdc' would have been the main line for development and getting it to run on all the above mentioned platfor

Re: Inline Functions

2009-02-27 Thread TomD
Walter Bright Wrote: > Sergey Gromov wrote: [...] > > Heh, thanks! I hope my opus really worths mentioning. > > I think it is. Shouldn't things like these maybe be included under the "Tech Tips" on digitalmars.com or so? Ciao TomD