digitalmars.D.learn - Is there a reason for default-int?
- Simen kjaeraas (7/7) Dec 28 2009 Apart from C legacy, is there a reason to assume anything we don't know ...
- Phil Deets (7/12) Dec 28 2009 w =
- Don (3/14) Dec 28 2009 D never had default int. When there's an error, the compiler just has to...
- Ary Borenszweig (4/19) Dec 29 2009 It could be an Error type (that's not an alias for int type) that don't
- BCS (11/33) Dec 29 2009 that poses an interesting question: what "type" does this this give?
- Don (2/43) Dec 29 2009 Error.
- Ary Borenszweig (8/51) Dec 30 2009 Exactly! You would get an error saying "i ~ s" cannot happen, then it
- BCS (8/63) Dec 31 2009 IIRC, all of the above is planned and in the works.
- Don (3/9) Dec 28 2009 There's now an Error type in the compiler. It's gradually filtering its
- Simen kjaeraas (4/13) Dec 29 2009 Great!
- BCS (2/13) Dec 29 2009 ok. Can we s/gradually/rapidly/ ?
- =?ISO-8859-1?Q?Tomek_Sowi=f1ski?= (2/4) Jan 02 2010 The one from object.di or the compiler makes up its own dummy type to sa...
- Don (4/9) Jan 03 2010 It's just an internal compiler thing, which does nothing except reduce
Apart from C legacy, is there a reason to assume anything we don't know what is, is an int? Shouldn't the compiler instead say 'unknown type' or something else that makes sense? -- Simen
Dec 28 2009
On Mon, 28 Dec 2009 16:18:46 -0500, Simen kjaeraas = <simen.kjaras gmail.com> wrote:Apart from C legacy, is there a reason to assume anything we don't kno=w =what is, is an int? Shouldn't the compiler instead say 'unknown type' or =something else that makes sense?C++ abandoned default int. I think it would be best for D to do the same= . Just my 2=A2, Phil Deets
Dec 28 2009
Phil Deets wrote:On Mon, 28 Dec 2009 16:18:46 -0500, Simen kjaeraas <simen.kjaras gmail.com> wrote:D never had default int. When there's an error, the compiler just has to choose *some* type, so that it doesn't crash <g>.Apart from C legacy, is there a reason to assume anything we don't know what is, is an int? Shouldn't the compiler instead say 'unknown type' or something else that makes sense?C++ abandoned default int. I think it would be best for D to do the same.
Dec 28 2009
Don wrote:Phil Deets wrote:It could be an Error type (that's not an alias for int type) that don't start to spit errors everywhere and instead just blocks all further errors on that type.On Mon, 28 Dec 2009 16:18:46 -0500, Simen kjaeraas <simen.kjaras gmail.com> wrote:D never had default int. When there's an error, the compiler just has to choose *some* type, so that it doesn't crash <g>.Apart from C legacy, is there a reason to assume anything we don't know what is, is an int? Shouldn't the compiler instead say 'unknown type' or something else that makes sense?C++ abandoned default int. I think it would be best for D to do the same.
Dec 29 2009
Hello Ary,Don wrote:that poses an interesting question: what "type" does this this give? int i; char[] s; int foo(int); char[] foo(int,char[]); int[] foo(char[],int); auto whatType = foo(i ~ s, s); i~s gives the error type but DMD could tell that as long as the other args are correct, the only foo that works returns a char[] so does the variable get the error type or char[]?Phil Deets wrote:It could be an Error type (that's not an alias for int type) that don't start to spit errors everywhere and instead just blocks all further errors on that type.On Mon, 28 Dec 2009 16:18:46 -0500, Simen kjaeraas <simen.kjaras gmail.com> wrote:D never had default int. When there's an error, the compiler just has to choose *some* type, so that it doesn't crash <g>.Apart from C legacy, is there a reason to assume anything we don't know what is, is an int? Shouldn't the compiler instead say 'unknown type' or something else that makes sense?C++ abandoned default int. I think it would be best for D to do the same.
Dec 29 2009
BCS wrote:Hello Ary,Error.Don wrote:that poses an interesting question: what "type" does this this give? int i; char[] s; int foo(int); char[] foo(int,char[]); int[] foo(char[],int); auto whatType = foo(i ~ s, s); i~s gives the error type but DMD could tell that as long as the other args are correct, the only foo that works returns a char[] so does the variable get the error type or char[]?Phil Deets wrote:It could be an Error type (that's not an alias for int type) that don't start to spit errors everywhere and instead just blocks all further errors on that type.On Mon, 28 Dec 2009 16:18:46 -0500, Simen kjaeraas <simen.kjaras gmail.com> wrote:D never had default int. When there's an error, the compiler just has to choose *some* type, so that it doesn't crash <g>.Apart from C legacy, is there a reason to assume anything we don't know what is, is an int? Shouldn't the compiler instead say 'unknown type' or something else that makes sense?C++ abandoned default int. I think it would be best for D to do the same.
Dec 29 2009
Don wrote:BCS wrote:Exactly! You would get an error saying "i ~ s" cannot happen, then it resolves to the Error type. Now resolution of "foo" is not done (or yes: it defaults to Error) because it has an argument of type Error (one less error in the console is shown). Since foo is error, whatType is Error. Then if whatType is used it won't trigger errors. Etc. You would get a single error in the precise position you need to correct it, instead of one error hidden with other many unrelated errors.Hello Ary,Error.Don wrote:that poses an interesting question: what "type" does this this give? int i; char[] s; int foo(int); char[] foo(int,char[]); int[] foo(char[],int); auto whatType = foo(i ~ s, s); i~s gives the error type but DMD could tell that as long as the other args are correct, the only foo that works returns a char[] so does the variable get the error type or char[]?Phil Deets wrote:It could be an Error type (that's not an alias for int type) that don't start to spit errors everywhere and instead just blocks all further errors on that type.On Mon, 28 Dec 2009 16:18:46 -0500, Simen kjaeraas <simen.kjaras gmail.com> wrote:D never had default int. When there's an error, the compiler just has to choose *some* type, so that it doesn't crash <g>.Apart from C legacy, is there a reason to assume anything we don't know what is, is an int? Shouldn't the compiler instead say 'unknown type' or something else that makes sense?C++ abandoned default int. I think it would be best for D to do the same.
Dec 30 2009
Hello Ary,Don wrote:IIRC, all of the above is planned and in the works. The only point I was wondering about is should DMD attempt to resolve functions where args are of error types? My thought is that in some cases it could resolve it and detect real errors down the line. OTOH, the argument for this (that blind propagation of Error can disable type checking on large swaths of code, even across functions via template code and auto return) is also an argument for why it could be a disaster if it makes the wrong guess.BCS wrote:Exactly! You would get an error saying "i ~ s" cannot happen, then it resolves to the Error type. Now resolution of "foo" is not done (or yes: it defaults to Error) because it has an argument of type Error (one less error in the console is shown). Since foo is error, whatType is Error. Then if whatType is used it won't trigger errors. Etc. You would get a single error in the precise position you need to correct it, instead of one error hidden with other many unrelated errors.Hello Ary,Error.Don wrote:that poses an interesting question: what "type" does this this give? int i; char[] s; int foo(int); char[] foo(int,char[]); int[] foo(char[],int); auto whatType = foo(i ~ s, s); i~s gives the error type but DMD could tell that as long as the other args are correct, the only foo that works returns a char[] so does the variable get the error type or char[]?Phil Deets wrote:It could be an Error type (that's not an alias for int type) that don't start to spit errors everywhere and instead just blocks all further errors on that type.On Mon, 28 Dec 2009 16:18:46 -0500, Simen kjaeraas <simen.kjaras gmail.com> wrote:D never had default int. When there's an error, the compiler just has to choose *some* type, so that it doesn't crash <g>.Apart from C legacy, is there a reason to assume anything we don't know what is, is an int? Shouldn't the compiler instead say 'unknown type' or something else that makes sense?C++ abandoned default int. I think it would be best for D to do the same.
Dec 31 2009
Simen kjaeraas wrote:Apart from C legacy, is there a reason to assume anything we don't know what is, is an int? Shouldn't the compiler instead say 'unknown type' or something else that makes sense?There's now an Error type in the compiler. It's gradually filtering its way through the compiler.
Dec 28 2009
On Tue, 29 Dec 2009 07:37:42 +0100, Don <nospam nospam.com> wrote:Simen kjaeraas wrote:Great! -- SimenApart from C legacy, is there a reason to assume anything we don't know what is, is an int? Shouldn't the compiler instead say 'unknown type' or something else that makes sense?There's now an Error type in the compiler. It's gradually filtering its way through the compiler.
Dec 29 2009
Hello Don,Simen kjaeraas wrote:ok. Can we s/gradually/rapidly/ ?Apart from C legacy, is there a reason to assume anything we don't know what is, is an int? Shouldn't the compiler instead say 'unknown type' or something else that makes sense?There's now an Error type in the compiler. It's gradually filtering its way through the compiler.
Dec 29 2009
Don Wrote:There's now an Error type in the compiler. It's gradually filtering its way through the compiler.The one from object.di or the compiler makes up its own dummy type to say "something wrong"?
Jan 02 2010
Tomek Sowiński wrote:Don Wrote:It's just an internal compiler thing, which does nothing except reduce the number of parasitic error messages spewed out by the compiler. You should never notice that it's there.There's now an Error type in the compiler. It's gradually filtering its way through the compiler.The one from object.di or the compiler makes up its own dummy type to say "something wrong"?
Jan 03 2010