Re: null references redux + Looney Tunes

2009-10-10 Thread bearophile
Rainer Deyke: Either I'm missing something, or this system only checks units at runtime (which would make it both slow and unsafe). Boost.Units (C++) checks units at compile time. There is no reason why D could not use the same approach. In F#, compile time checks shown by the IDE too:

Re: null references redux + Looney Tunes

2009-10-05 Thread Andrei Alexandrescu
Justin Johansson wrote: Andrei Alexandrescu Wrote: Nick Sabalausky wrote: Justin Johansson n...@spam.com wrote in message news:haavf1$2gs...@digitalmars.com... It's a difficult challenge to get high performance, readable and maintainable code out of complex number intensive algorithms. Use

Re: null references redux + Looney Tunes

2009-10-05 Thread Nick Sabalausky
Andrei Alexandrescu seewebsiteforem...@erdani.org wrote in message news:hab3r2$2pg...@digitalmars.com... Nick Sabalausky wrote: There's been discussion before (I can't find it now, or remember the name for it) of type systems that allow for proper handling of things like m/s vs. m/(s*s) vs

Re: null references redux + Looney Tunes

2009-10-05 Thread Nick Sabalausky
Andrei Alexandrescu seewebsiteforem...@erdani.org wrote in message news:hac2ku$1nf...@digitalmars.com... Justin Johansson wrote: Now please name five remarkable complex literals. (re, im) ::= (0, 0), (1,0), (0,1), (1,1), (pi/2, 0), (0, pi/2), e_to_the_power_(minus j),

Re: null references redux + Looney Tunes

2009-10-05 Thread Justin Johansson
Andrei Alexandrescu Wrote: Justin Johansson wrote: Andrei Alexandrescu Wrote: Nick Sabalausky wrote: Justin Johansson n...@spam.com wrote in message news:haavf1$2gs...@digitalmars.com... It's a difficult challenge to get high performance, readable and maintainable code out of

Re: null references redux + Looney Tunes

2009-10-05 Thread bearophile
Ary Borenszweig: What are those two methods named in C#? I didn't know about them. They are just named operator true and operator false. What I don't understand is why there are two of them, one of them looks enough to me: http://msdn.microsoft.com/en-us/library/6x6y6z4d%28loband%29.aspx

Re: null references redux + Looney Tunes

2009-10-05 Thread bearophile
Andrei Alexandrescu: We got to stop somewhere. The precise stopping point can be discussed. In the new C++ they have even added some flexibility in such regard: http://stackoverflow.com/questions/237804/user-defined-literals-in-c0x-a-much-needed-addition-or-making-c-even-more-bl Bye,

Re: null references redux + Looney Tunes

2009-10-05 Thread Nick Sabalausky
Justin Johansson n...@spam.com wrote in message news:ha4qpi$189...@digitalmars.com... For the interest of newsgroups readers, I dropped in at the Cafe the other day and the barista had this to say http://cafe.elharo.com/programming/imagine-theres-no-null/ Disclaimer: YMMV Cheers This

Re: null references redux + Looney Tunes

2009-10-05 Thread bearophile
Denis Koroskin: I don't see any reason why if (someComplexNumber) { ... } should be a valid code, it hardly makes any sense for me. In general I think adding a boolean-evaluation standard method to D can be positive and handy and not that bug-prone. But complex numbers are FP, so you usually

Re: null references redux + Looney Tunes

2009-10-05 Thread bearophile
Nick Sabalausky: -- fig A --- open(inFile ~ out ~ inFile.file ~ log); // As many as 4 different errors that could be caught but currently aren't. // (But obviously all would be overridable, of course) // Without such checking, if inFile contained /usr/home/joe/foo/bar.dat, // the

Re: null references redux + Looney Tunes

2009-10-05 Thread bearophile
ranged y = 1000; // Uh, bypasses the setter, no errors writeln(y); // 0? In the last version of DMD it gives an error: ranged y = 1000; temp.d(23): Error: cannot implicitly convert expression (1000) of type int to ranged Better. And opCast may help here. No implicit cast. Bye,

Re: null references redux + Looney Tunes

2009-10-05 Thread Rainer Deyke
bearophile wrote: Scala has a powerful type system that allows to implement such things in a good enough way: http://www.michaelnygard.com/blog/2009/05/units_of_measure_in_scala.html Either I'm missing something, or this system only checks units at runtime (which would make it both slow and

Re: null references redux + Looney Tunes

2009-10-05 Thread language_fan
Mon, 05 Oct 2009 11:41:52 +, language_fan wrote: Mon, 05 Oct 2009 05:29:20 -0600, Rainer Deyke thusly wrote: bearophile wrote: Scala has a powerful type system that allows to implement such things in a good enough way: http://www.michaelnygard.com/blog/2009/05/

Re: null references redux + Looney Tunes

2009-10-05 Thread language_fan
Mon, 05 Oct 2009 05:29:20 -0600, Rainer Deyke thusly wrote: bearophile wrote: Scala has a powerful type system that allows to implement such things in a good enough way: http://www.michaelnygard.com/blog/2009/05/ units_of_measure_in_scala.html Either I'm missing something, or this system

Re: null references redux + Looney Tunes

2009-10-05 Thread Nick Sabalausky
Rainer Deyke rain...@eldwood.com wrote in message news:haclah$33...@digitalmars.com... bearophile wrote: Scala has a powerful type system that allows to implement such things in a good enough way: http://www.michaelnygard.com/blog/2009/05/units_of_measure_in_scala.html Either I'm missing

Re: null references redux + Looney Tunes

2009-10-05 Thread Rainer Deyke
Nick Sabalausky wrote: I've been thinking it might be nice to have both. Compile-time for obvious reasons but then also run-time ones that could do conversions: auto velocity = convert(meter/second)(distance / time); // Actual runtime-conversion I'm pretty sure Boost.Units already does

unit libraries, was Re: null references redux + Looney Tunes

2009-10-05 Thread Rainer Deyke
language_fan wrote: The only problem with these was that there was no way to signal the location of the type error in the client code, it always reported the location of the (static) assert in the library, which is pretty much useless. That's a compiler problem, no? I don't think this is

Re: null references redux + Looney Tunes

2009-10-05 Thread Justin Johansson
Nick Sabalausky Wrote: Justin Johansson n...@spam.com wrote in message news:ha4qpi$189...@digitalmars.com... For the interest of newsgroups readers, I dropped in at the Cafe the other day and the barista had this to say http://cafe.elharo.com/programming/imagine-theres-no-null/

Re: null references redux + Looney Tunes

2009-10-05 Thread Walter Bright
bearophile wrote: Scala has a powerful type system that allows to implement such things in a good enough way: http://www.michaelnygard.com/blog/2009/05/units_of_measure_in_scala.html So does D: === // by Oskar Linde Aug 2006 // This is just a quick

Re: null references redux + Looney Tunes

2009-10-05 Thread Walter Bright
Rainer Deyke wrote: Boost.Units (C++) checks units at compile time. There is no reason why D could not use the same approach. Oskar's code I posted does it at compile time.

Re: null references redux + Looney Tunes

2009-10-05 Thread downs
bearophile wrote: Denis Koroskin: I don't see any reason why if (someComplexNumber) { ... } should be a valid code, it hardly makes any sense for me. In general I think adding a boolean-evaluation standard method to D can be positive and handy and not that bug-prone. But complex

Re: null references redux + Looney Tunes

2009-10-05 Thread bearophile
downs: I'm not buying that. What kind of function would that be? I can't imagine a need for this. I don't know, sorry. But I'd like to have such method to define my collections as false when they are empty, this is really handy. And it may be useful to make nullable values false. Bye,

Re: null references redux + Looney Tunes

2009-10-05 Thread Nick Sabalausky
Justin Johansson n...@spam.com wrote in message news:had7hc$1dc...@digitalmars.com... Nick Sabalausky Wrote: This is gonna sound trivial (and probably is), but it's been bugging the hell out of me: What is the meaning of the + Looney Tunes added to the title of this sub-thread? I don't see

Re: null references redux + Looney Tunes

2009-10-04 Thread language_fan
On Sat, 03 Oct 2009 16:39:29 -0400, Justin Johansson wrote: People might remember that when I picked up D and joined this forum just some 3 or so weeks ago I made mention of being a Scala refugee.*** When asked what I didn't like about Scala I commented about there being too many language

Re: null references redux + Looney Tunes

2009-10-04 Thread Andrei Alexandrescu
language_fan wrote: On Sat, 03 Oct 2009 16:39:29 -0400, Justin Johansson wrote: People might remember that when I picked up D and joined this forum just some 3 or so weeks ago I made mention of being a Scala refugee.*** When asked what I didn't like about Scala I commented about there being

Re: null references redux + Looney Tunes

2009-10-04 Thread Lutger
language_fan wrote: On Sat, 03 Oct 2009 16:39:29 -0400, Justin Johansson wrote: People might remember that when I picked up D and joined this forum just some 3 or so weeks ago I made mention of being a Scala refugee.*** When asked what I didn't like about Scala I commented about there

Re: null references redux + Looney Tunes

2009-10-04 Thread Lutger
Forget to qualify my reply: I don't know Scala so you might as well be right and I do not mean to say that D isn't a complex language.

Re: null references redux + Looney Tunes

2009-10-04 Thread language_fan
On Sun, 04 Oct 2009 11:51:13 +0200, Lutger wrote: How do you think Scala is going to manage to be a popular alternative for Java by requiring its user to read books about lambda calculus? It's not necessary. Often removing extra semicolons and changing the form 'type value' to 'value : type'

Re: null references redux + Looney Tunes

2009-10-04 Thread Jeremie Pelletier
language_fan wrote: On Sun, 04 Oct 2009 04:28:35 -0500, Andrei Alexandrescu wrote: language_fan wrote: On Sat, 03 Oct 2009 16:39:29 -0400, Justin Johansson wrote: People might remember that when I picked up D and joined this forum just some 3 or so weeks ago I made mention of being a Scala

Re: null references redux + Looney Tunes

2009-10-04 Thread Jeremie Pelletier
language_fan wrote: On Sun, 04 Oct 2009 11:51:13 +0200, Lutger wrote: How do you think Scala is going to manage to be a popular alternative for Java by requiring its user to read books about lambda calculus? It's not necessary. Often removing extra semicolons and changing the form 'type

Re: null references redux + Looney Tunes

2009-10-04 Thread Andrei Alexandrescu
language_fan wrote: On Sun, 04 Oct 2009 04:28:35 -0500, Andrei Alexandrescu wrote: language_fan wrote: On Sat, 03 Oct 2009 16:39:29 -0400, Justin Johansson wrote: People might remember that when I picked up D and joined this forum just some 3 or so weeks ago I made mention of being a Scala

Re: null references redux + Looney Tunes

2009-10-04 Thread language_fan
Sun, 04 Oct 2009 11:08:52 -0500, Andrei Alexandrescu thusly wrote: So, you say D lacks built-in first-class sum and product types. Yet Tuple is a product type. In spite of appearances, it's a built-in type, just that it has no literal. Not true. A tuple of tuples, for instance, breaks the

Re: null references redux + Looney Tunes

2009-10-04 Thread Walter Bright
Jeremie Pelletier wrote: language_fan wrote: I admitted that later. Some of the keywords have a strong justification behind them. Others feel irritatingly unnecessary. I would rather have many different specialized keywords than a few keywords with many different meanings. Its *much* easier

Re: null references redux + Looney Tunes

2009-10-04 Thread Walter Bright
Nick Sabalausky wrote: Fair enough. *But*, I really think elegantly simple language design is double-edged sword. In my experience, and I think this is what Jeremie was alluding to, I've found that an elegantly simple language, no matter how well-chosen the primitives are, generally results in

Re: null references redux + Looney Tunes

2009-10-04 Thread Jeremie Pelletier
Walter Bright wrote: Jeremie Pelletier wrote: language_fan wrote: I admitted that later. Some of the keywords have a strong justification behind them. Others feel irritatingly unnecessary. I would rather have many different specialized keywords than a few keywords with many different

Re: null references redux + Looney Tunes

2009-10-04 Thread Walter Bright
Jeremie Pelletier wrote: Walter Bright wrote: Also, the complex and imaginary types will be removed at some point and replaced with a library type; there goes 6 keywords. Why? What's the rationale behind such a move? These types will always be handled the same no matter what library

Re: null references redux + Looney Tunes

2009-10-04 Thread Justin Johansson
Jeremie Pelletier Wrote: Walter Bright wrote: Jeremie Pelletier wrote: language_fan wrote: I admitted that later. Some of the keywords have a strong justification behind them. Others feel irritatingly unnecessary. I would rather have many different specialized keywords than a few

Re: null references redux + Looney Tunes

2009-10-04 Thread Nick Sabalausky
Justin Johansson n...@spam.com wrote in message news:haavf1$2gs...@digitalmars.com... It's a difficult challenge to get high performance, readable and maintainable code out of complex number intensive algorithms. Use of library types for complex numbers has, in my experience been

Re: null references redux + Looney Tunes

2009-10-04 Thread bearophile
Walter Bright: The big reason for moving it to a library type is the user defined type capabilities of D have grown to the point where there is no longer much of any advantage to having it built in. If the compiler/language is now flexible enough to allow the creation of a very good

Re: null references redux + Looney Tunes

2009-10-04 Thread Andrei Alexandrescu
Nick Sabalausky wrote: Justin Johansson n...@spam.com wrote in message news:haavf1$2gs...@digitalmars.com... It's a difficult challenge to get high performance, readable and maintainable code out of complex number intensive algorithms. Use of library types for complex numbers has, in my

Re: null references redux + Looney Tunes

2009-10-04 Thread bearophile
Andrei Alexandrescu: please name five remarkable complex literals. I agree that having a syntax is often not necessary (but it may be handy). Complex literals in a program can be unremarkable too, they can be arguments of complex functions, integration intervals, default values that replace

Re: null references redux + Looney Tunes

2009-10-04 Thread language_fan
Sun, 04 Oct 2009 17:39:50 -0400, Justin Johansson thusly wrote: Nick Sabalausky Wrote: I've also been wondering if it might be a huge benefit for distinguishing between strings that represent a filename vs file content vs file-extention-only vs relative-path+filename, vs absolute-path-only,

Re: null references redux + Looney Tunes

2009-10-04 Thread bearophile
Justin Johansson Wrote: Bingo. I'm sure there would be a huge benefit to be able to distinguish string or any primitive type in such manner without having to invent a Filename class, AbsolutePathName class etc. Can D typedef be used for such purpose? Bye, bearophile

Re: null references redux + Looney Tunes

2009-10-04 Thread Andrei Alexandrescu
bearophile wrote: opIf sounds strange :-) Why don't you like the idea of the implicit conversion to bool followed by the testing of the bool? (someone may have already answered a similar question, please bear with me). Try this: void * p; if (p) {} Then try this: void * p; bool b = p;

Re: null references redux + Looney Tunes

2009-10-04 Thread Justin Johansson
bearophile Wrote: Justin Johansson Wrote: Bingo. I'm sure there would be a huge benefit to be able to distinguish string or any primitive type in such manner without having to invent a Filename class, AbsolutePathName class etc. Can D typedef be used for such purpose? Bye,

Re: null references redux + Looney Tunes

2009-10-04 Thread Jarrett Billingsley
On Sun, Oct 4, 2009 at 5:58 PM, Andrei Alexandrescu seewebsiteforem...@erdani.org wrote: bearophile wrote: opIf sounds strange :-) Why don't you like the idea of the implicit conversion to bool followed by the testing of the bool? (someone may have already answered a similar question, please

Re: null references redux + Looney Tunes

2009-10-04 Thread Justin Johansson
Andrei Alexandrescu Wrote: Nick Sabalausky wrote: Justin Johansson n...@spam.com wrote in message news:haavf1$2gs...@digitalmars.com... It's a difficult challenge to get high performance, readable and maintainable code out of complex number intensive algorithms. Use of library

Re: null references redux + Looney Tunes

2009-10-04 Thread Denis Koroskin
On Mon, 05 Oct 2009 01:03:01 +0400, bearophile bearophileh...@lycos.com wrote: Walter Bright: The big reason for moving it to a library type is the user defined type capabilities of D have grown to the point where there is no longer much of any advantage to having it built in. If the

Re: null references redux + Looney Tunes

2009-10-04 Thread Denis Koroskin
On Mon, 05 Oct 2009 01:47:00 +0400, language_fan f...@bar.com.invalid wrote: Something that came to my mind while reading this: typedefs could also be extended to support contracts just like functions. It is a nice idea! It would make D typedef much more powerful and useful.

Re: null references redux + Looney Tunes

2009-10-04 Thread bearophile
To test my level of ignorance of D2, and to test how structs can be used to implement complex numbers in the std lib I have done few experiments with something simile, subsets of integers. I have found some problems, some of them may come from my ignorance. This is a natural number: import

Re: null references redux + Looney Tunes

2009-10-03 Thread Nick Sabalausky
Jeremie Pelletier jerem...@gmail.com wrote in message news:ha51v1$24p...@digitalmars.com... Justin Johansson wrote: For the interest of newsgroups readers, I dropped in at the Cafe the other day and the barista had this to say http://cafe.elharo.com/programming/imagine-theres-no-null/

Re: null references redux + Looney Tunes

2009-10-03 Thread Jeremie Pelletier
language_fan wrote: Fri, 02 Oct 2009 10:16:05 -0400, Jeremie Pelletier thusly wrote: I expect my $3k computer to not slow down to a crawl because its software is written in a safe way and I like people with older computers to still be able to run my programs without waiting 5 minutes between

Re: null references redux + Looney Tunes

2009-10-03 Thread Jeremie Pelletier
Yigal Chripun wrote: On 02/10/2009 16:16, Jeremie Pelletier wrote: Justin Johansson wrote: For the interest of newsgroups readers, I dropped in at the Cafe the other day and the barista had this to say http://cafe.elharo.com/programming/imagine-theres-no-null/ Disclaimer: YMMV Cheers --

Re: null references redux + Looney Tunes

2009-10-03 Thread Jeremie Pelletier
Nick Sabalausky wrote: Jeremie Pelletier jerem...@gmail.com wrote in message news:ha51v1$24p...@digitalmars.com... Justin Johansson wrote: For the interest of newsgroups readers, I dropped in at the Cafe the other day and the barista had this to say

Re: null references redux + Looney Tunes

2009-10-03 Thread Jeremie Pelletier
language_fan wrote: Fri, 02 Oct 2009 12:38:33 -0500, Andrei Alexandrescu thusly wrote: I'll note two things. For one, Walter is a heck more progressive than his pedigree might lead one to think. He has taken quite some risks with a number of features that made definite steps outside the

Re: null references redux + Looney Tunes

2009-10-03 Thread Jeremie Pelletier
Andrei Alexandrescu wrote: Justin Johansson wrote: For the interest of newsgroups readers, I dropped in at the Cafe the other day and the barista had this to say http://cafe.elharo.com/programming/imagine-theres-no-null/ Disclaimer: YMMV Cheers -- Justin Johansson This article brings up

Re: null references redux + Looney Tunes

2009-10-03 Thread Andrei Alexandrescu
Jeremie Pelletier wrote: Andrei Alexandrescu wrote: Justin Johansson wrote: For the interest of newsgroups readers, I dropped in at the Cafe the other day and the barista had this to say http://cafe.elharo.com/programming/imagine-theres-no-null/ Disclaimer: YMMV Cheers -- Justin Johansson

Re: null references redux + Looney Tunes

2009-10-03 Thread language_fan
On Sat, 03 Oct 2009 10:32:28 -0400, Jeremie Pelletier wrote: I don't believe D is having some features merely to attract attention to it, that's the thing I like best about D; it provides a very large set of tools and let me choose how to use them, instead of enforcing a certain model or

Re: null references redux + Looney Tunes

2009-10-03 Thread Yigal Chripun
On 03/10/2009 16:09, Jeremie Pelletier wrote: I don't think you understood what I meant, seat-belts don't require you to buy a bigger car engine because they don't affect the performance of the car whatsoever. They're also not enforced, the car will run just as fine if you don't wear them. I

Re: null references redux + Looney Tunes

2009-10-03 Thread Jeremie Pelletier
language_fan wrote: On Sat, 03 Oct 2009 10:32:28 -0400, Jeremie Pelletier wrote: I don't believe D is having some features merely to attract attention to it, that's the thing I like best about D; it provides a very large set of tools and let me choose how to use them, instead of enforcing a

Re: null references redux + Looney Tunes

2009-10-03 Thread language_fan
On Sat, 03 Oct 2009 14:35:22 -0400, Jeremie Pelletier wrote: language_fan wrote: On Sat, 03 Oct 2009 10:32:28 -0400, Jeremie Pelletier wrote: I don't believe D is having some features merely to attract attention to it, that's the thing I like best about D; it provides a very large set of

Re: null references redux + Looney Tunes

2009-10-03 Thread Justin Johansson
language_fan Wrote: On Sat, 03 Oct 2009 14:35:22 -0400, Jeremie Pelletier wrote: language_fan wrote: On Sat, 03 Oct 2009 10:32:28 -0400, Jeremie Pelletier wrote: I don't believe D is having some features merely to attract attention to it, that's the thing I like best about D; it

Re: null references redux + Looney Tunes

2009-10-03 Thread Nick Sabalausky
language_fan somewh...@internet.com.invalid wrote in message news:ha87kd$2j3...@digitalmars.com... On Sat, 03 Oct 2009 14:35:22 -0400, Jeremie Pelletier wrote: Think of the english languages, how many words does it have? I would hate to try and express my ideas if I had only 100 words to

Re: null references redux + Looney Tunes

2009-10-02 Thread Justin Johansson
For the interest of newsgroups readers, I dropped in at the Cafe the other day and the barista had this to say http://cafe.elharo.com/programming/imagine-theres-no-null/ Disclaimer: YMMV Cheers -- Justin Johansson

Re: null references redux + Looney Tunes

2009-10-02 Thread Jeremie Pelletier
Justin Johansson wrote: For the interest of newsgroups readers, I dropped in at the Cafe the other day and the barista had this to say http://cafe.elharo.com/programming/imagine-theres-no-null/ Disclaimer: YMMV Cheers -- Justin Johansson Most of the bugs he expose are trivial to debug and

Re: null references redux + Looney Tunes

2009-10-02 Thread Jarrett Billingsley
On Fri, Oct 2, 2009 at 8:13 AM, Justin Johansson n...@spam.com wrote: For the interest of newsgroups readers, I dropped in at the Cafe the other day and the barista had this to say http://cafe.elharo.com/programming/imagine-theres-no-null/ Disclaimer: YMMV Cheers -- Justin Johansson I

Re: null references redux + Looney Tunes

2009-10-02 Thread Andrei Alexandrescu
Justin Johansson wrote: For the interest of newsgroups readers, I dropped in at the Cafe the other day and the barista had this to say http://cafe.elharo.com/programming/imagine-theres-no-null/ Disclaimer: YMMV Cheers -- Justin Johansson This article brings up a very interesting point

Re: null references redux + Looney Tunes

2009-10-02 Thread Yigal Chripun
On 02/10/2009 16:16, Jeremie Pelletier wrote: Justin Johansson wrote: For the interest of newsgroups readers, I dropped in at the Cafe the other day and the barista had this to say http://cafe.elharo.com/programming/imagine-theres-no-null/ Disclaimer: YMMV Cheers -- Justin Johansson Most

Re: null references redux + Looney Tunes

2009-10-02 Thread language_fan
Fri, 02 Oct 2009 10:16:05 -0400, Jeremie Pelletier thusly wrote: I expect my $3k computer to not slow down to a crawl because its software is written in a safe way and I like people with older computers to still be able to run my programs without waiting 5 minutes between any two mouse

Re: null references redux + Looney Tunes

2009-10-02 Thread language_fan
Fri, 02 Oct 2009 10:30:24 -0400, Jarrett Billingsley thusly wrote: I always think it's funny when people are like so, I had this idea, lemme throw this out there. I know it sounds weird, but just bear with me - what if there were _no null_? Did I just _blow your mind?_ And the perspective

Re: null references redux + Looney Tunes

2009-10-02 Thread Andrei Alexandrescu
language_fan wrote: Fri, 02 Oct 2009 10:30:24 -0400, Jarrett Billingsley thusly wrote: I always think it's funny when people are like so, I had this idea, lemme throw this out there. I know it sounds weird, but just bear with me - what if there were _no null_? Did I just _blow your mind?_ And

Re: null references redux + Looney Tunes

2009-10-02 Thread language_fan
Fri, 02 Oct 2009 12:38:33 -0500, Andrei Alexandrescu thusly wrote: I'll note two things. For one, Walter is a heck more progressive than his pedigree might lead one to think. He has taken quite some risks with a number of features that made definite steps outside the mainstream, and I feel he