D - ideas and questions
- Matthias Becker (53/53) Nov 17 2003 Here are some ideas, I'm not realy sure about:
- Walter (28/78) Nov 18 2003 types
- Helmut Leitner (5/8) Nov 18 2003 Shared.
- Hauke Duden (3/7) Nov 19 2003 Is it just me, or are the discussions in this newsgroup going downhill
- Charles Sanders (4/11) Nov 19 2003 A couple of strippers is just what this newsgroup needs ;).
Here are some ideas, I'm not realy sure about: Everybody starts the name of a type with an uppercase letter. Only D's types start with a lowercase letter. Perhaps they should start with an upper case letter as well: Int, UInt, Char, ... . ------------------------------------------------------------------ An modifier no_side_effect micht be helpfull for optimisations. Eg, if you write the following: result = (x + y) * (x + y); where everything is a suerdefined type, the operator + has to be executed twice, as it could have side effects. With this modifier, the compiler knows that the function (in this case the operator +) has no side effect and can use the result of the operation twice. This is only true if the function is deterministic (it has the same reult if the arguments are the same). So you would eigther need another attribut "deterministic" or "no_side_effect" would guarantie that the function is deterministc as well. If you have the code, the Compiler might know on it's own, whether a function has side effects or not, but if it's already compiled code, e.g. part of an external library, the compiler has no chance to find it out. And it might be (too?) hard to find out whether a function has side effects for the compiler. ------------------------------------------------------------------ An then I want to ask a question to Walter: Youintroduced a new Cast to D that is realy cool, but you only use C-style casts on your own. (I look in the fildes that came with the D-compiler). Why? And I have another question: As I mentioned I looked at some code of the standard-modules. In conv.d I fould the following (from toInt): { if (cast(uint)v > 0x80000000) goto Loverflow; v = -v; } There are many constructs like this. if the condition is true you jump to Loverflow (cool name :) ). There conv_overflow() is called. And if you look at this function you see the only thing it does is throwing an exception. I don't get it. Instead of this strange goto you could directly call the function or even throw directly. It seems not to have any sense. { if (cast(uint)v > 0x80000000) conv_overflow(s); v = -v; } This code would be as informative and wouldn't use an additional goto. goto should only be used if there is a real reason for it not just for fun. But perhaps I missed something. It's the same with goto Lerr. There only conv_error() is called which directly throws. I would replace goto Loverflow; with throw new ConvOverflowError(s); or if it's too long in your opinion with conv_overflow(s);
Nov 17 2003
"Matthias Becker" <Matthias_member pathlink.com> wrote in message news:bpb0i3$24nn$1 digitaldaemon.com...Everybody starts the name of a type with an uppercase letter. Only D'stypesstart with a lowercase letter. Perhaps they should start with an uppercaseletter as well: Int, UInt, Char, ... .D follows the C/C++ tradition of all keywords being lower case.An modifier no_side_effect micht be helpfull for optimisations. Eg, if youwritethe following: result = (x + y) * (x + y); where everything is a suerdefined type, the operator + has to be executedtwice,as it could have side effects. With this modifier, the compiler knows thatthefunction (in this case the operator +) has no side effect and can use theresultof the operation twice. This is only true if the function is deterministic(ithas the same reult if the arguments are the same). So you would eigtherneedanother attribut "deterministic" or "no_side_effect" would guarantie thatthefunction is deterministc as well. If you have the code, the Compiler might know on it's own, whether afunctionhas side effects or not, but if it's already compiled code, e.g. part ofanexternal library, the compiler has no chance to find it out. And it mightbe(too?) hard to find out whether a function has side effects for thecompiler. A D compiler usually has far more information about functions in different files than C/C++ compilers do. However, you are right, and some way to say that a function has no side effects is a useful property for optimization.An then I want to ask a question to Walter: Youintroduced a new Cast to Dthatis realy cool, but you only use C-style casts on your own. (I look in thefildesthat came with the D-compiler). Why?Sloth. <g>And I have another question: As I mentioned I looked at some code of the standard-modules. In conv.d Ifouldthe following (from toInt): { if (cast(uint)v > 0x80000000) goto Loverflow; v = -v; } There are many constructs like this. if the condition is true you jump to Loverflow (cool name :) ). There conv_overflow() is called. And if you look at this function you see theonlything it does is throwing an exception. I don't get it. Instead of this strange goto you could directly call the function or even throw directly. It seems not to have any sense. { if (cast(uint)v > 0x80000000) conv_overflow(s); v = -v; } This code would be as informative and wouldn't use an additional goto.gotoshould only be used if there is a real reason for it not just for fun. But perhaps I missed something. It's the same with goto Lerr. There only conv_error() is called whichdirectlythrows. I would replace goto Loverflow; with throw new ConvOverflowError(s); or if it's too long in your opinion with conv_overflow(s);It's a habit of mine to collect all the errors into one spot using a goto. It's not right or wrong, just a personal style.
Nov 18 2003
Walter wrote:It's a habit of mine to collect all the errors into one spot using a goto. It's not right or wrong, just a personal style.Shared. -- Helmut Leitner leitner hls.via.at Graz, Austria www.hls-software.com
Nov 18 2003
I would replace goto Loverflow;I agree with you - a stripper is the way to go.Is it just me, or are the discussions in this newsgroup going downhill somewhat? ;) Hauke
Nov 19 2003
A couple of strippers is just what this newsgroup needs ;). C "Hauke Duden" <H.NS.Duden gmx.net> wrote in message news:bpfdbf$2ihe$1 digitaldaemon.com...> I agree with you - a stripper is the way to go. Is it just me, or are the discussions in this newsgroup going downhill somewhat? ;) HaukeI would replace goto Loverflow;
Nov 19 2003