anybody working on OpenCL bindings?

2009-09-28 Thread Trass3r
Is anybody already working on OpenCL bindings now that Nvidia finally released a public OpenCL driver?

Half-open versus closed ranges, was Re: Interesting GCC extensions

2009-09-28 Thread Rainer Deyke
Adam D. Ruppe wrote: > I think this makes D's syntax superior. We can say a[0..$] where > gcc would have to use the more annoying a[0...$-1]. > (pretending the $ worked of course) Although I generally prefer half-open ranges over closed ranges, both have their advantages and disadvantages. Advant

Re: Null references redux

2009-09-28 Thread Yigal Chripun
On 29/09/2009 00:31, Nick Sabalausky wrote: "Yigal Chripun" wrote in message news:h9r37i$tg...@digitalmars.com... These aren't just marginal performance gains, they can easily be up to 15-30% improvements, sometimes 50% and more. If this is too complex or the risk is too high for you then do

Re: Null references redux

2009-09-28 Thread Derek Parnell
On Mon, 28 Sep 2009 19:27:03 -0500, Andrei Alexandrescu wrote: > language_fan wrote: >> >> int min; >> >> foreach(int value; list) >> if (value < min) min = value; >> >> Oops, you forgot to define a flag variable or initialize to int.min > > You mean int.max :o). if (list.length ==

Re: Interesting GCC extensions

2009-09-28 Thread Adam D. Ruppe
On Mon, Sep 28, 2009 at 09:04:27PM -0600, Rainer Deyke wrote: > > int[101] a; > > a[0..9] = 1; > > a[10..99] = 2; > > a[100] = 3; > > This leaves elements 9 and 99 uninitialized. I assume the gcc version > does not. That makes sense. I copied it literally without thinking. Easy e

Re: Null references redux

2009-09-28 Thread Rainer Deyke
Jesse Phillips wrote: > Yeah, it was brought to my attention that "type safety" by a friend > could be another form. bearophile also brings up a good example. > I think that is what Walter is getting at, you're not dealing with > memory that is correct, when this happens the program should halt

Re: Interesting GCC extensions

2009-09-28 Thread Rainer Deyke
Adam D. Ruppe wrote: > Trying it, I see it doesn't actually work in initialization, but you > can do it after the fact easily enough: > > int[101] a; > a[0..9] = 1; > a[10..99] = 2; > a[100] = 3; This leaves elements 9 and 99 uninitialized. I assume the gcc version does n

Re: Null references redux

2009-09-28 Thread Jeremie Pelletier
Andrei Alexandrescu wrote: language_fan wrote: Mon, 28 Sep 2009 15:35:07 -0400, Jesse Phillips thusly wrote: language_fan Wrote: Now if you really want to throw some sticks into the spokes, you would say that if the program crashes due to a null pointer, it is still likely that the programme

Re: Null references redux + Cyclone

2009-09-28 Thread Walter Bright
Andrei Alexandrescu wrote: Thanks for posting these interesting numbers. I seem to recall that interface dispach in D does a linear search in the interfaces list, so you may want to repeat your tests with a variable number of interfaces, and a variable position of the interface being used. No

Re: Null references redux

2009-09-28 Thread Andrei Alexandrescu
language_fan wrote: Mon, 28 Sep 2009 15:35:07 -0400, Jesse Phillips thusly wrote: language_fan Wrote: Now if you really want to throw some sticks into the spokes, you would say that if the program crashes due to a null pointer, it is still likely that the programmer will just initialize/set t

Re: Null references redux + Cyclone

2009-09-28 Thread Michel Fortin
On 2009-09-28 15:36:05 -0400, bearophile said: Compiled with DMD the running time seems about unchanged. I have no idea why. Maybe some of you can tell me. If I recall correctly, implementing an interface adds a variable to an class which contains a pointer to that interface's vtable implem

Re: Null references redux

2009-09-28 Thread Jesse Phillips
On Mon, 28 Sep 2009 16:01:10 -0400, Steven Schveighoffer wrote: > On Mon, 28 Sep 2009 15:35:07 -0400, Jesse Phillips > wrote: > >> language_fan Wrote: >> >>> Have you ever used functional languages? When you develop in Haskell >>> or SML, how often you feel there is a good change something will

Re: Null references redux

2009-09-28 Thread Adam Burton
I don't know if what I am about to rant about has already been discussed and I haven't noticed, but sometimes I feel like sticking my opinions in and this seems to be one of them times :-) so bare with me and we'll see if I am a crazy man blabbing on about crap or not :-). language_fan wrote:

Re: Null references redux

2009-09-28 Thread language_fan
Mon, 28 Sep 2009 20:17:54 -0400, Nick Sabalausky thusly wrote: > "language_fan" wrote in message > news:h9relp$1eb...@digitalmars.com... >> Mon, 28 Sep 2009 22:33:26 +, language_fan thusly wrote: >> >>> Value types can be incorrectly initialized and nobody notices. E.g. >>> >>> int min; >>>

Re: opApply ref and "const" iterators

2009-09-28 Thread Denis Koroskin
On Tue, 29 Sep 2009 02:58:01 +0400, gzp wrote: Hello, Iám new to D so i might be all wrong. Given the code: Hello and welcome to the D world! class Foo { int opApply( int delegate(ref real) dg ) {...} //A. int opApply( int delegate(real) dg ) {...} // B, } ... Foo

Re: Null references redux

2009-09-28 Thread Nick Sabalausky
"language_fan" wrote in message news:h9relp$1eb...@digitalmars.com... > Mon, 28 Sep 2009 22:33:26 +, language_fan thusly wrote: > >> Value types can be incorrectly initialized and nobody notices. E.g. >> >> int min; >> >> foreach(int value; list) >> if (value < min) min = value; > >>

Re: opApply ref and "const" iterators

2009-09-28 Thread Jarrett Billingsley
On Mon, Sep 28, 2009 at 6:58 PM, gzp wrote: > Hello, > > Iám new to D so i might be all wrong. Given the code: > > class Foo { >        int opApply( int delegate(ref real) dg ) {...} //A. >        int opApply( int delegate(real) dg ) {...} // B, > } > > ... >        Foo foo = new Foo; >        for

opApply ref and "const" iterators

2009-09-28 Thread gzp
Hello, Iám new to D so i might be all wrong. Given the code: class Foo { int opApply( int delegate(ref real) dg ) {...} //A. int opApply( int delegate(real) dg ) {...} // B, } ... Foo foo = new Foo; foreach( a; foo ) {...} // 1. foreach( ref a; foo ) {..

Re: Null references redux

2009-09-28 Thread language_fan
Mon, 28 Sep 2009 22:33:26 +, language_fan thusly wrote: > Value types can be incorrectly initialized and nobody notices. E.g. > > int min; > > foreach(int value; list) > if (value < min) min = value; > Now I can tell you, in functional languages there is no other way. All > initiali

Re: Null references redux

2009-09-28 Thread language_fan
Mon, 28 Sep 2009 15:35:07 -0400, Jesse Phillips thusly wrote: > language_fan Wrote: > >> > Now if you really want to throw some sticks into the spokes, you >> > would say that if the program crashes due to a null pointer, it is >> > still likely that the programmer will just initialize/set the va

Re: Null references redux

2009-09-28 Thread bearophile
Yigal Chripun: >Have you ever heard of Stalin (i'm not talking about the dictator)?< Stalin accepts only a certain subset of Scheme, you can't use some of the nicest things. And while ShedSkin is slow, Stalin is really slow, so slow that compiling largish programs becomes not handy (I think tim

Re: Interesting GCC extensions

2009-09-28 Thread Lutger
Lutger wrote: > bearophile wrote: > >> Lutger: >> >>> We don't need an extension for this! Look: >>> >>> template Eval(string exp) >>> { >>> enum Eval = mixin(exp); >>> } >>> >>> template IsConstant(string exp) >>> { >>> enum IsConstant = __traits(compiles, Eval!exp); >>> } >> >> >>

Re: Null references redux

2009-09-28 Thread Nick Sabalausky
"Yigal Chripun" wrote in message news:h9r37i$tg...@digitalmars.com... > >> >> These aren't just marginal performance gains, they can easily be up to >> 15-30% improvements, sometimes 50% and more. If this is too complex or >> the risk is too high for you then don't use a systems language :) > > y

Re: Interesting GCC extensions

2009-09-28 Thread Lutger
bearophile wrote: > Lutger: > >> We don't need an extension for this! Look: >> >> template Eval(string exp) >> { >> enum Eval = mixin(exp); >> } >> >> template IsConstant(string exp) >> { >> enum IsConstant = __traits(compiles, Eval!exp); >> } > > > From what I see I think your code i

Re: OT: Management of Coders (was: Null references redux)

2009-09-28 Thread language_fan
Mon, 28 Sep 2009 20:34:44 +, BCS thusly wrote: > Hello Manfred_Nowak, > >> BCS wrote: >> >> [...] >> >>> I wouldn't want to hire a programer that *habitually* (and >>> unnecessarily) hacks past a feature designed to prevent bugs. >>> >> In the short time of an interview its not possible to

Re: Null references redux + Cyclone

2009-09-28 Thread Nick Sabalausky
"bearophile" wrote in message news:h9qo0l$75...@digitalmars.com... > > But beside normal C unions that I don't want to remove from C, it can be > also useful to have safe automatic tagged unions of Cyclone. They are > safer and give just a little less performance compared to C unions. In D > t

Re: Interesting GCC extensions

2009-09-28 Thread language_fan
Mon, 28 Sep 2009 13:27:13 -0400, Steven Schveighoffer thusly wrote: > On Mon, 28 Sep 2009 12:58:57 -0400, bearophile > wrote: > >> Jarrett Billingsley: >> >>> Which do you want? Do you want new features, or do you want things to >>> be fixed?< >> >> The ideas shown in that post are low priority,

Re: Null references redux

2009-09-28 Thread Nick Sabalausky
"Jeremie Pelletier" wrote in message news:h9q1pn$1po...@digitalmars.com... > Nick Sabalausky wrote: >> >> Unions are nothing more than an alternate syntax for a reinterpret cast. >> And it's an arguably worse syntax because unlike casts, uses of it are >> indistinguishable from normal safe code

Re: opEquals and the Non-Virtual Interface idiom

2009-09-28 Thread Andrei Alexandrescu
Justin Johansson wrote: Andrei Alexandrescu Wrote: It turns out this is a great example for NVI. In D, we could and should do the following: class Object { // Implement this private bool opEqualsImpl(Object rhs) { return false; } // Use this final bool opEqual

Re: Interesting GCC extensions

2009-09-28 Thread Adam D. Ruppe
On Mon, Sep 28, 2009 at 03:45:16PM -0400, bearophile wrote: > Adam D. Ruppe: > > > Triple points can be used for initializations too: > > > int widths[] = { [0 ... 9] = 1, [10 ... 99] = 2, [100] = 3 }; > > > > D's slicing can already do this I believe. > > How? Trying it, I see it doesn't actual

Re: OT: Management of Coders (was: Null references redux)

2009-09-28 Thread BCS
Hello Manfred_Nowak, BCS wrote: [...] I wouldn't want to hire a programer that *habitually* (and unnecessarily) hacks past a feature designed to prevent bugs. In the short time of an interview its not possible to test for habits (or necessarity) to hack past a feature designed to provent bu

Re: Interesting GCC extensions

2009-09-28 Thread bearophile
Lutger: > We don't need an extension for this! Look: > > template Eval(string exp) > { > enum Eval = mixin(exp); > } > > template IsConstant(string exp) > { > enum IsConstant = __traits(compiles, Eval!exp); > } >From what I see I think your code is useless for my purposes: // D2 code

Re: Null references redux

2009-09-28 Thread Steven Schveighoffer
On Mon, 28 Sep 2009 15:35:07 -0400, Jesse Phillips wrote: language_fan Wrote: Have you ever used functional languages? When you develop in Haskell or SML, how often you feel there is a good change something will be initialized to the wrong value? Can you show some statistics that show how u

Re: Interesting GCC extensions

2009-09-28 Thread bearophile
Adam D. Ruppe: > > Triple points can be used for initializations too: > > int widths[] = { [0 ... 9] = 1, [10 ... 99] = 2, [100] = 3 }; > > D's slicing can already do this I believe. How? Bye, bearophile

Re: Null references redux

2009-09-28 Thread Yigal Chripun
On 28/09/2009 15:28, Jeremie Pelletier wrote: here's a type-safe alternative note: untested struct Vec3F { float[3] v; alias v[0] x; alias v[1] y; alias v[2] z; } D provides alignment control for structs, why do we need to have a separate union construct if it is just a special case of struct

Re: Null references redux + Cyclone

2009-09-28 Thread bearophile
Christopher Wright: > > Certainly agreed on virtual calls: on my machine, I timed a simple > > example as executing 65 interface calls per microsecond, 85 virtual > > calls per microsecond, and 210 non-member function calls per > > microsecond. So you should almost never worry about the cost of

Re: Null references redux

2009-09-28 Thread Jesse Phillips
language_fan Wrote: > > Now if you really want to throw some sticks into the spokes, you would > > say that if the program crashes due to a null pointer, it is still > > likely that the programmer will just initialize/set the value to a > > "default" that still isn't valid just to get the program

Re: opEquals and the Non-Virtual Interface idiom

2009-09-28 Thread Justin Johansson
Andrei Alexandrescu Wrote: > It turns out this is a great example for NVI. In D, we could and should > do the following: > > class Object { > // Implement this > private bool opEqualsImpl(Object rhs) { > return false; > } > // Use this > final bool opEquals(Objec

Re: Null references redux

2009-09-28 Thread Jesse Phillips
Rainer Deyke Wrote: > You could argue that assigned a 'B' to a variable that is declared to > hold an 'A' is already a memory safety violation. Yeah, it was brought to my attention that "type safety" by a friend could be another form. bearophile also brings up a good example. >If so, then the

Re: Interesting GCC extensions

2009-09-28 Thread Adam D. Ruppe
On Mon, Sep 28, 2009 at 12:35:05PM -0400, bearophile wrote: > Beside the known ones, like computed gotos and __builtin_expect(), GCC has > other less known extensions, you can find some of them here: > http://www.ibm.com/developerworks/linux/library/l-gcc-hacks/ I remember this page... did you po

Re: Null references redux + Cyclone

2009-09-28 Thread Andrei Alexandrescu
Christopher Wright wrote: bearophile wrote: Jeremie Pelletier: Again, that's a lazy view on programming. High level constructs are useful to isolate small and simple algorithms which are implemented at low level. Software is inherently multi-scale. Probably in 90-95% of the code of a progra

Re: Interesting GCC extensions

2009-09-28 Thread Jarrett Billingsley
On Mon, Sep 28, 2009 at 1:27 PM, Steven Schveighoffer wrote: > On Mon, 28 Sep 2009 12:58:57 -0400, bearophile > wrote: > >> Jarrett Billingsley: >> >>> Which do you want? Do you want new features, or do you want things to be >>> fixed?< >> >> The ideas shown in that post are low priority, so they

Re: Interesting GCC extensions

2009-09-28 Thread Steven Schveighoffer
On Mon, 28 Sep 2009 12:58:57 -0400, bearophile wrote: Jarrett Billingsley: Which do you want? Do you want new features, or do you want things to be fixed?< The ideas shown in that post are low priority, so they can wait. But things can be planned for the future too, you can start thi

Re: Interesting GCC extensions

2009-09-28 Thread Lutger
bearophile wrote: > Beside the known ones, like computed gotos and __builtin_expect(), GCC has > other less known extensions, you can find some of them here: > http://www.ibm.com/developerworks/linux/library/l-gcc-hacks/ > > They are used by Linux. If D wants to be a system language, such small >

Re: Null references redux + Cyclone

2009-09-28 Thread Christopher Wright
bearophile wrote: Jeremie Pelletier: Again, that's a lazy view on programming. High level constructs are useful to isolate small and simple algorithms which are implemented at low level. Software is inherently multi-scale. Probably in 90-95% of the code of a program micro-optimizations aren'

Re: Interesting GCC extensions

2009-09-28 Thread bearophile
Jarrett Billingsley: >Which do you want? Do you want new features, or do you want things to be >fixed?< The ideas shown in that post are low priority, so they can wait. But things can be planned for the future too, you can start thinking/planning about them even years before they are implement

Re: Interesting GCC extensions

2009-09-28 Thread Jarrett Billingsley
On Mon, Sep 28, 2009 at 12:35 PM, bearophile wrote: > Beside the known ones, like computed gotos and __builtin_expect(), GCC has > other less known extensions, you can find some of them here: > http://www.ibm.com/developerworks/linux/library/l-gcc-hacks/ > > They are used by Linux. If D wants to

Re: Null references redux

2009-09-28 Thread bearophile
Jari-Matti M.: > It depends on the boolean representation. I see no reason why a built-in > feature should be slower than some bitwise logic operation in user code. > After all, the set of operations the language provides for the user is a > subset of all possible operations the language implem

Interesting GCC extensions

2009-09-28 Thread bearophile
Beside the known ones, like computed gotos and __builtin_expect(), GCC has other less known extensions, you can find some of them here: http://www.ibm.com/developerworks/linux/library/l-gcc-hacks/ They are used by Linux. If D wants to be a system language, such small things may be useful if you

Re: Null references redux + Cyclone

2009-09-28 Thread bearophile
Jeremie Pelletier: > Not always true. I agree, I'm using D also because it offers unions. Sometimes they are useful. But beside normal C unions that I don't want to remove from C, it can be also useful to have safe automatic tagged unions of Cyclone. They are safer and give just a little less

Re: Null references redux

2009-09-28 Thread Lionello Lunesu
On 28-9-2009 18:09, Jeremie Pelletier wrote: Max Samukha wrote: Lionello Lunesu wrote: On 27-9-2009 9:20, Walter Bright wrote: language_fan wrote: The idea behind non-nullable types and other contracts is to catch these errors on compile time. Sure, the code is a bit harder to write, but it

Re: Null references redux

2009-09-28 Thread Jeremie Pelletier
Yigal Chripun wrote: On 28/09/2009 12:05, Jeremie Pelletier wrote: Nick Sabalausky wrote: "Jeremie Pelletier" wrote in message news:h9mmre$1i8...@digitalmars.com... Ary Borenszweig wrote: Object is not-nullable, Object? (or whatever syntax you like) is nullable. So that line is a compile-tim

Re: Null references redux

2009-09-28 Thread Yigal Chripun
On 28/09/2009 12:05, Jeremie Pelletier wrote: Nick Sabalausky wrote: "Jeremie Pelletier" wrote in message news:h9mmre$1i8...@digitalmars.com... Ary Borenszweig wrote: Object is not-nullable, Object? (or whatever syntax you like) is nullable. So that line is a compile-time error: you can't cas

OT: Management of Coders (was: Null references redux)

2009-09-28 Thread Manfred_Nowak
BCS wrote: [...] > I wouldn't want to hire a programer that *habitually* (and > unnecessarily) hacks past a feature designed to prevent bugs. In the short time of an interview its not possible to test for habits (or necessarity) to hack past a feature designed to provent bugs. Therefore the onl

Re: Null references redux

2009-09-28 Thread Jari-Matti Mäkelä
Jeremie Pelletier wrote: > Jari-Matti Mäkelä wrote: >> Jeremie Pelletier wrote: >> >>> Nick Sabalausky wrote: union A { int foo; float bar; } >>> Yet it's the only way I know of to do bitwise logic on floating points >>> in D to extract the exponent, sign and mantissa for

Re: Null references redux

2009-09-28 Thread Jeremie Pelletier
Jari-Matti Mäkelä wrote: Jeremie Pelletier wrote: Nick Sabalausky wrote: union A { int foo; float bar; } Yet it's the only way I know of to do bitwise logic on floating points in D to extract the exponent, sign and mantissa for example. You could add built-in methods for those operations t

Re: Null references redux

2009-09-28 Thread Jari-Matti Mäkelä
Jeremie Pelletier wrote: > Nick Sabalausky wrote: >> union A { >> int foo; >> float bar; >> } >> > > Yet it's the only way I know of to do bitwise logic on floating points > in D to extract the exponent, sign and mantissa for example. You could add built-in methods for those operations to the f

Re: Null references redux

2009-09-28 Thread Jeremie Pelletier
Max Samukha wrote: Lionello Lunesu wrote: On 27-9-2009 9:20, Walter Bright wrote: language_fan wrote: The idea behind non-nullable types and other contracts is to catch these errors on compile time. Sure, the code is a bit harder to write, but it is safe and never segfaults. The idea is to mi

Re: Null references redux

2009-09-28 Thread Jeremie Pelletier
Nick Sabalausky wrote: "Jeremie Pelletier" wrote in message news:h9mmre$1i8...@digitalmars.com... Ary Borenszweig wrote: Object is not-nullable, Object? (or whatever syntax you like) is nullable. So that line is a compile-time error: you can't cast a null to an Object (because Object *can't*

Re: Null references redux

2009-09-28 Thread Max Samukha
Lionello Lunesu wrote: > On 27-9-2009 9:20, Walter Bright wrote: >> language_fan wrote: >>> The idea behind non-nullable types and other contracts is to catch >>> these errors on compile time. Sure, the code is a bit harder to write, >>> but it is safe and never segfaults. The idea is to minimize

Re: Null references redux

2009-09-28 Thread Denis Koroskin
On Mon, 28 Sep 2009 01:31:44 +0400, Jeremie Pelletier wrote: Andrei Alexandrescu wrote: Jeremie Pelletier wrote: Is this Linux specific? what about other *nix systems, like BSD and solaris? Signal handler are standard to most *nix platforms since they're part of the posix C standard li

Re: Null references redux

2009-09-28 Thread Nick Sabalausky
"Jeremie Pelletier" wrote in message news:h9mmre$1i8...@digitalmars.com... > Ary Borenszweig wrote: >> >> Object is not-nullable, Object? (or whatever syntax you like) is >> nullable. So that line is a compile-time error: you can't cast a null to >> an Object (because Object *can't* be null). >