Re: Templates - Numeric Types only

2009-08-06 Thread Andrei Alexandrescu
Jarrett Billingsley wrote: On Fri, Aug 7, 2009 at 12:54 AM, Andrei Alexandrescu wrote: Jarrett Billingsley wrote: On Thu, Aug 6, 2009 at 9:53 PM, Andrei Alexandrescu wrote: Jarrett Billingsley wrote: On Thu, Aug 6, 2009 at 9:19 PM, Andrei Alexandrescu wrote: Kevin wrote: Hi, simple Question

Re: proposed syntax change

2009-08-06 Thread Robert Jacques
On Thu, 06 Aug 2009 15:10:27 -0700, Jarrett Billingsley wrote: On Thu, Aug 6, 2009 at 6:02 PM, Robert Jacques wrote: int a = 5 / 2; // compiler knows to use integer division No, it doesn't. (i.e. Welcome to the limitations of a context-free grammar) The right hand of the expression has

Re: Templates - Numeric Types only

2009-08-06 Thread Jarrett Billingsley
On Fri, Aug 7, 2009 at 12:54 AM, Andrei Alexandrescu wrote: > Jarrett Billingsley wrote: >> >> On Thu, Aug 6, 2009 at 9:53 PM, Andrei >> Alexandrescu wrote: >>> >>> Jarrett Billingsley wrote: On Thu, Aug 6, 2009 at 9:19 PM, Andrei Alexandrescu wrote: > > Kevin wrote: >> >

Re: Templates - Numeric Types only

2009-08-06 Thread Andrei Alexandrescu
Jarrett Billingsley wrote: On Thu, Aug 6, 2009 at 9:53 PM, Andrei Alexandrescu wrote: Jarrett Billingsley wrote: On Thu, Aug 6, 2009 at 9:19 PM, Andrei Alexandrescu wrote: Kevin wrote: Hi, simple Question: Is it possible to allow just numeric types in templates? For example to create a Vector

New Property Article on Wiki4D

2009-08-06 Thread Chad J
I've written a new property article on Wiki4D. I've tried to gather information about properties that has been scattered about in many news group discussions and bring it all together in that one place. http://prowiki.org/wiki4d/wiki.cgi?DocComments/Property I hope this will help people become m

Re: Templates - Numeric Types only

2009-08-06 Thread Jarrett Billingsley
On Thu, Aug 6, 2009 at 9:53 PM, Andrei Alexandrescu wrote: > Jarrett Billingsley wrote: >> >> On Thu, Aug 6, 2009 at 9:19 PM, Andrei >> Alexandrescu wrote: >>> >>> Kevin wrote: Hi, simple Question: Is it possible to allow just numeric types in templates? For example to crea

Re: Global operator overloading?

2009-08-06 Thread Jeremie Pelletier
Andrei Alexandrescu Wrote: > Jeremie Pelletier wrote: > > Are there any plans to have global operator overloading in D? > > > > It would be terribly useful with ranges, since std.array already define > > range primitives for arrays, I tried to implement array primitives to > > ranges the same w

Re: Templates - Numeric Types only

2009-08-06 Thread Andrei Alexandrescu
Jarrett Billingsley wrote: On Thu, Aug 6, 2009 at 9:19 PM, Andrei Alexandrescu wrote: Kevin wrote: Hi, simple Question: Is it possible to allow just numeric types in templates? For example to create a Vector Class like this: class Vector(T:"numeric" = float, int size = 4) Thanks, Kevin impor

Re: Global operator overloading?

2009-08-06 Thread Andrei Alexandrescu
Jeremie Pelletier wrote: Are there any plans to have global operator overloading in D? It would be terribly useful with ranges, since std.array already define range primitives for arrays, I tried to implement array primitives to ranges the same way, ie: --- bool opEquals(T, U)(T t, U, u) if(i

Global operator overloading?

2009-08-06 Thread Jeremie Pelletier
Are there any plans to have global operator overloading in D? It would be terribly useful with ranges, since std.array already define range primitives for arrays, I tried to implement array primitives to ranges the same way, ie: --- bool opEquals(T, U)(T t, U, u) if(isInputRange!T && isInputRan

Re: Templates - Numeric Types only

2009-08-06 Thread Jarrett Billingsley
On Thu, Aug 6, 2009 at 9:19 PM, Andrei Alexandrescu wrote: > Kevin wrote: >> >> Hi, >> simple Question: >> Is it possible to allow just numeric types in templates? >> For example to create a Vector Class like this: >> >> class Vector(T:"numeric" = float, int size = 4) >> >> Thanks, >> Kevin > > imp

Re: Templates - Numeric Types only

2009-08-06 Thread Andrei Alexandrescu
Kevin wrote: Hi, simple Question: Is it possible to allow just numeric types in templates? For example to create a Vector Class like this: class Vector(T:"numeric" = float, int size = 4) Thanks, Kevin import std.traits; class Vector(T, int size = 4) if (isNumeric!T) { ... } Andrei

Templates - Numeric Types only

2009-08-06 Thread Kevin
Hi, simple Question: Is it possible to allow just numeric types in templates? For example to create a Vector Class like this: class Vector(T:"numeric" = float, int size = 4) Thanks, Kevin

Re: proposed syntax change

2009-08-06 Thread Marianne Gagnon
Paul D. Anderson Wrote: > I was browsing the Python spec yesterday and came across this interesting and > useful syntax: > > "/" (one slash) means floating point division, e.g. 5/2 = 2.5 even though 5 > and 2 are integers > > "//" (two slashes) means integer (floor) division, e.g. 5.0//2.0 = 2

Re: Properties and Copy Constructors

2009-08-06 Thread Sergey Gromov
Thu, 06 Aug 2009 18:08:00 -0400, Chad J wrote: > [snip] > > The jist is that you have some value type like a Matrix or BigInt that > might actually have memory allocated to it. It is a value type though, > so whenever it is copied, any memory allocated to it needs to also be > copied and new mem

Re: proposed syntax change

2009-08-06 Thread Jarrett Billingsley
On Thu, Aug 6, 2009 at 6:02 PM, Robert Jacques wrote: >> int a = 5 / 2; // compiler knows to use integer division > > No, it doesn't. (i.e. Welcome to the limitations of a context-free grammar) > The right hand of the expression has to be evaluated before the left, or > otherwise function overload

Re: proposed syntax change

2009-08-06 Thread Moritz Warning
On Thu, 06 Aug 2009 15:06:49 -0400, Paul D. Anderson wrote: > I was browsing the Python spec yesterday and came across this > interesting and useful syntax: > > "/" (one slash) means floating point division, e.g. 5/2 = 2.5 even > though 5 and 2 are integers > > "//" (two slashes) means integer (

Properties and Copy Constructors

2009-08-06 Thread Chad J
So I dug up Andrei's thread that mentioned something about properties that hasn't been discussed as of recent: expensive copy semantics. The thread is here: http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D&article_id=82621 The jist is that you have some value type like a

Re: proposed syntax change

2009-08-06 Thread Robert Jacques
On Thu, 06 Aug 2009 13:34:21 -0700, Yigal Chripun wrote: Ary Borenszweig wrote: Adam D. Ruppe wrote: On Thu, Aug 06, 2009 at 03:06:49PM -0400, Paul D. Anderson wrote: Oh wait...I think "//" is used elsewhere. Is this a joke? No. When porting C, C++, Java or C# code just search "//" and

Re: final switch usage

2009-08-06 Thread ponce
In fact final switch can be an improved computed GOTO :)

Re: proposed syntax change

2009-08-06 Thread ponce
Same for me, it breaks compatibility with C. Also, i found the ocaml floating point operators (./ .+ .- .*) painful when i had to use them.

Re: array slicing policy (and Range implementation)

2009-08-06 Thread HOSOKAWA Kenchi
Tim M Wrote: > I think Andrei has mostly worked out the fundamentals of ranges and it > is probably done by treating exisiting views as immutable. > > To conclude it works if you can guarantee that you can have all views > remain valid after any changes to the data block they point too as they >

Re: proposed syntax change

2009-08-06 Thread Paul D. Anderson
Adam D. Ruppe Wrote: > On Thu, Aug 06, 2009 at 04:48:40PM -0400, Paul D. Anderson wrote: > > Two words: "whoosh!" > > > I have a hard enough time telling if someone is serious or not in real life; > it is even harder in plain text :S > > -- > Adam D. Ruppe > http://arsdnet.net Sorry -- I'd

Re: proposed syntax change

2009-08-06 Thread language_fan
Thu, 06 Aug 2009 17:06:40 -0300, Ary Borenszweig thusly wrote: > Of course I think using "//" for something else is a disaster. The -- token may look too functional to many of us. I am pretty sure that a great deal of D users would choose a buggy, badly optimizing compiler and an incomplete spe

Re: proposed syntax change

2009-08-06 Thread Paul D. Anderson
Robert Fraser Wrote: > Paul D. Anderson wrote: > > I was browsing the Python spec yesterday and came across this interesting > > and useful syntax: > > > > "/" (one slash) means floating point division, e.g. 5/2 = 2.5 even though 5 > > and 2 are integers > > > > "//" (two slashes) means intege

Re: Searching the digitalmars.com/d website

2009-08-06 Thread language_fan
Fri, 07 Aug 2009 04:46:37 +1000, Daniel Keep thusly wrote: > Search: (o) the whole site (o) D1 (o) D1 (spec) (o) D1 (phobos) (o) D2 > (o) D2 (spec) (o) D2 (phobos) (o) Newsgroups (o) Newsgroups (D-only) (o) > Newsgroups (D-only, but not including D.bugs) (o) Pages that include > changes between D1

Re: proposed syntax change

2009-08-06 Thread Adam D. Ruppe
On Thu, Aug 06, 2009 at 04:48:40PM -0400, Paul D. Anderson wrote: > Two words: "whoosh!" > I have a hard enough time telling if someone is serious or not in real life; it is even harder in plain text :S -- Adam D. Ruppe http://arsdnet.net

Re: proposed syntax change

2009-08-06 Thread Paul D. Anderson
Adam D. Ruppe Wrote: > On Thu, Aug 06, 2009 at 04:35:41PM -0300, Ary Borenszweig wrote: > > No. When porting C, C++, Java or C# code just search "//" and replace it > > with "--". > > Problem with this is old habit. I find myself annoyed with languages that > don't accept // comments just becaus

Re: proposed syntax change

2009-08-06 Thread Yigal Chripun
Ary Borenszweig wrote: Adam D. Ruppe wrote: On Thu, Aug 06, 2009 at 03:06:49PM -0400, Paul D. Anderson wrote: Oh wait...I think "//" is used elsewhere. Is this a joke? No. When porting C, C++, Java or C# code just search "//" and replace it with "--". Oh wait... I think "--" is used else

Re: proposed syntax change

2009-08-06 Thread Robert Fraser
Paul D. Anderson wrote: I was browsing the Python spec yesterday and came across this interesting and useful syntax: "/" (one slash) means floating point division, e.g. 5/2 = 2.5 even though 5 and 2 are integers "//" (two slashes) means integer (floor) division, e.g. 5.0//2.0 = 2.0 even thou

Re: proposed syntax change

2009-08-06 Thread Ary Borenszweig
Adam D. Ruppe wrote: On Thu, Aug 06, 2009 at 04:35:41PM -0300, Ary Borenszweig wrote: No. When porting C, C++, Java or C# code just search "//" and replace it with "--". Problem with this is old habit. I find myself annoyed with languages that don't accept // comments just because I'm so used

Re: proposed syntax change

2009-08-06 Thread Jarrett Billingsley
On Thu, Aug 6, 2009 at 3:06 PM, Paul D. Anderson wrote: > I was browsing the Python spec yesterday and came across this interesting and > useful syntax: > > "/" (one slash) means floating point division, e.g. 5/2 = 2.5 even though 5 > and 2 are integers > > "//" (two slashes) means integer (floor

Re: proposed syntax change

2009-08-06 Thread Adam D. Ruppe
On Thu, Aug 06, 2009 at 04:35:41PM -0300, Ary Borenszweig wrote: > No. When porting C, C++, Java or C# code just search "//" and replace it > with "--". Problem with this is old habit. I find myself annoyed with languages that don't accept // comments just because I'm so used to typing them that

Re: proposed syntax change

2009-08-06 Thread Ary Borenszweig
Adam D. Ruppe wrote: On Thu, Aug 06, 2009 at 03:06:49PM -0400, Paul D. Anderson wrote: Oh wait...I think "//" is used elsewhere. Is this a joke? No. When porting C, C++, Java or C# code just search "//" and replace it with "--". Oh wait... I think "--" is used elsewhere.

Re: proposed syntax change

2009-08-06 Thread Michiel Helvensteijn
Paul D. Anderson wrote: > I was browsing the Python spec yesterday and came across this interesting > and useful syntax: > > "/" (one slash) means floating point division, e.g. 5/2 = 2.5 even though > 5 and 2 are integers > > "//" (two slashes) means integer (floor) division, e.g. 5.0//2.0 = 2.0

Re: proposed syntax change

2009-08-06 Thread bearophile
Paul D. Anderson: > Oh wait...I think "//" is used elsewhere. Well, we could still use it but > mark it as a breaking change. Then users could simply remove all previous > uses of "//" from their code. If they REALLY need to retain the old "//" > functionality we could replace it with a new symb

Re: proposed syntax change

2009-08-06 Thread Adam D. Ruppe
On Thu, Aug 06, 2009 at 03:06:49PM -0400, Paul D. Anderson wrote: > Oh wait...I think "//" is used elsewhere. Is this a joke? -- Adam D. Ruppe http://arsdnet.net

proposed syntax change

2009-08-06 Thread Paul D. Anderson
I was browsing the Python spec yesterday and came across this interesting and useful syntax: "/" (one slash) means floating point division, e.g. 5/2 = 2.5 even though 5 and 2 are integers "//" (two slashes) means integer (floor) division, e.g. 5.0//2.0 = 2.0 even though 5.0 and 2.0 are floats.

Re: Searching the digitalmars.com/d website

2009-08-06 Thread Daniel Keep
Andrei Alexandrescu wrote: > Ary Borenszweig wrote: >> ... >> >> That's great. :) >> >> Now it would be greater to put a radio button below the search box: >> >> Search: (o) the whole site (o) the spec >> >> or something like that, because it's really, really useful. > > Search: (o) the whole s

Re: Searching the digitalmars.com/d website

2009-08-06 Thread Walter Bright
Walter Bright wrote: I just tried it. I only get results from urls that start with http://www.digitalmars.com/d/2.0 Here is the google search url it generated: http://www.google.com/search?q=pure+functions&domains=www.digitalmars.com&sitesearch=www.digitalmars.com%2Fd%2F2.0&sourceid=google-sea

Re: Searching the digitalmars.com/d website

2009-08-06 Thread Walter Bright
Ary Borenszweig wrote: Sorry for brining this topic again, but there's something that really worries me (not that I cannot sleep at night, but...) Take this page: http://www.digitalmars.com/d/2.0/function.html There are some big headers there: "pure functions", "nothrow functions", "ref fun

Re: Usability of latest DMD 1.x

2009-08-06 Thread Lars Ivar Igesund
Walter Bright Wrote: > All releases are sent to Lars before going out so the Tango team can let > me know if I broke something. I haven't heard any word that it has. I did however send word that I didn't have time to test it this time around :)

Re: Searching the digitalmars.com/d website

2009-08-06 Thread Andrei Alexandrescu
Ary Borenszweig wrote: Daniel Keep escribió: Chad J wrote: Walter Bright wrote: Ary Borenszweig wrote: Strange: now my previous searches work (well, most of them). What could have happened? Sometimes google gives erratic behavior if part of their farm goes down. Any chance we can get a sear

final switch usage

2009-08-06 Thread #ponce
For the low-level programmer, sometimes you must use switch because virtual functions are more expensive (cache usage...) and pointers to functions too. The problem is that even if the optimizer turn the switch into a jump-table, it has generally no clue about whether the value will be in the ri

Re: array slicing policy

2009-08-06 Thread Tim M
On Thu, 06 Aug 2009 04:13:07 -0400 HOSOKAWA Kenchi wrote: > Hello, > > > D's array slicing is basically "an array means to specify a subarray > of it. Static arrays are the same as in C but I prefer to think of dynamic arrays as a handy GC'd block of memory that comes with a free view and any

Re: Usability of latest DMD 1.x

2009-08-06 Thread Bill Baxter
On Thu, Aug 6, 2009 at 6:07 AM, Jarrett Billingsley wrote: > On Thu, Aug 6, 2009 at 9:04 AM, Bill Baxter wrote: >> On Wed, Aug 5, 2009 at 9:52 PM, Nick Sabalausky wrote: >>> "Bill Baxter" wrote in message >>> news:mailman.291.1249531861.14071.digitalmar...@puremagic.com... I just tried to upgr

Re: Usability of latest DMD 1.x

2009-08-06 Thread Jarrett Billingsley
On Thu, Aug 6, 2009 at 9:04 AM, Bill Baxter wrote: > On Wed, Aug 5, 2009 at 9:52 PM, Nick Sabalausky wrote: >> "Bill Baxter" wrote in message >> news:mailman.291.1249531861.14071.digitalmar...@puremagic.com... >>>I just tried to upgrade my DMD from 1.041 to 1.046 and things aren't >>> working so w

Re: Usability of latest DMD 1.x

2009-08-06 Thread Jarrett Billingsley
On Thu, Aug 6, 2009 at 1:46 AM, Walter Bright wrote: > All releases are sent to Lars before going out so the Tango team can let me > know if I broke something. I haven't heard any word that it has. > I'm kind of surprised that http://d.puremagic.com/issues/show_bug.cgi?id=3167 wasn't caught then.

Re: Usability of latest DMD 1.x

2009-08-06 Thread Bill Baxter
On Wed, Aug 5, 2009 at 9:52 PM, Nick Sabalausky wrote: > "Bill Baxter" wrote in message > news:mailman.291.1249531861.14071.digitalmar...@puremagic.com... >>I just tried to upgrade my DMD from 1.041 to 1.046 and things aren't >> working so well. >> I see Tango is still based off 1.041 too.  So hav

Re: Searching the digitalmars.com/d website

2009-08-06 Thread Ary Borenszweig
Daniel Keep escribió: Chad J wrote: Walter Bright wrote: Ary Borenszweig wrote: Strange: now my previous searches work (well, most of them). What could have happened? Sometimes google gives erratic behavior if part of their farm goes down. Any chance we can get a search that /only/ searches

Re: Triggers

2009-08-06 Thread Sjoerd van Leent
Jeremie Pelletier Wrote: > Sjoerd van Leent Wrote: > > > OK, to make matters worse. > > > > As I was reading so many things about properties, keywords and a bunch of > > other interesting things, perhaps triggers. > > > > Triggers are, in my opinion, functions that act as delegates, and are >

array slicing policy

2009-08-06 Thread HOSOKAWA Kenchi
Hello, D's array slicing is basically "an array means to specify a subarray of it. An array slice does not copy the data, it is only another reference to it." This definition, however, is easily violated by instance reallocation such as changing its length: int[] a = [0, 1, 2]; int[] b = a[0..