Thread overview | |||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
February 06, 2004 [Language design] Notational error | ||||
---|---|---|---|---|
| ||||
In D it is allowed to call a function like this: | fori(0, 0) and like this | fori(0.0) provided, that `f' is overloaded for example like this: | void fori(real v){someglobalrealvariable=v;...} | void fori(int start, int end){for(i=start;i<=end;i++){...}} However, if the programmer wants to type `f(0.0)' but instead types `f(0,0)' the catastrophe might be unavoidable: | Here is a very real example of catastrophic system failure due to a | simple syntactical problem in a programming language: | | The USSR Mars probe, released from the Earth's atmosphere on November | 27,1971, crash landed on the surface of Mars because its booster rockets | failed. The failure was due to a single character mistake in the landing | algorithm, which was written in Fortran. There was a breaking routine | with a waiting loop of the style "FOR I=1,1000", which didn't perform | properly, because the comma was replaced with a period, which was | compiled as "FORI=1.1", variable "FORI" was assigned the value "1.1". http://www.amadeus-3.com/main_files/oberon2vsCPP.php, [cited 06.02.04] How does this agree with D's design goal: | for practical programmers who need to get the job done quickly, reliably So long. |
February 06, 2004 Re: [Language design] Notational error | ||||
---|---|---|---|---|
| ||||
Posted in reply to Manfred Nowak | C learned from the problems of Fortrash. But I suppose that this kind of problem can crop up in D if the recent suggestion of auto-declared variables (or whatever the term was) is allowed. These examples are the reason why modern (as opposed to 50s-era) languages require double entry bookkeeping. |
February 06, 2004 Re: [Language design] Notational error | ||||
---|---|---|---|---|
| ||||
Posted in reply to The Lone Haranguer | The Lone Haranguer wrote: > But I suppose that this kind of problem can crop up in D if the recent suggestion of auto-declared variables (or whatever the term was) is allowed. I am with you. > These examples are the reason why modern (as opposed to 50s-era) languages require double entry bookkeeping. Double entry bookkeeping? In the example replace the two int's with two real's, then there is no double bookkeeping for a call with two int's, but dmd still does not evoke an error because of the automatic type casting. Moreover, as D is supposed to be used in programming teams, the two functions might be public and included in a module used by another team member. Have you ever read through a whole interface description? I usually stopped, when I found the function I need. So I would not be even aware of the fact, that the needed function might be overloaded. If double bookkeeping would be followed to the end, then it would mean for a distributed development team, that every used function from a "foreign" module has to be introduced explicitely into the current scope and that no tool is allowed to help with this introducing. As you surely know this is not the case with D. However, to avoid the accidentically call of an overloaded function containing one number, respectively two numbers in comparable position, D should - turn off automatic type casting, or if this is not enough - require double bookkeeping in the importing module. I.e. in the example when the overload `fori(int, int)' is declared the call `fori(0,0)' should generate something like: | ... : ambiguous overloads for 'fori', introduce overload into scope when the overload `fori(real, real)' is declared the call `fori(0,0)' should generate something like: | ... : ambiguous overloads for 'fori', no implicit type cast in either case the call `fori(0.0)' should generate something like: | ... : ambiguous overloads for 'fori', introduce overload into scope So long. |
February 06, 2004 Re: [Language design] Notational error | ||||
---|---|---|---|---|
| ||||
Posted in reply to Manfred Nowak | 1) no problems here in typing the wrong of two.. its a different place. 2) syntax highlighting the way i do it makes such situations VERY obvious. namely my numbers are always dark yellow (good to read on white, but not really pointing out of the screen) my keytokens ( ({,})+-*/%&| and all those), are all in red (very pointing out of the screen).. so fori(0,0) and fori(0.0) would look entierly different. and btw, you can do this in c++ as well (and java, i think, too). "Manfred Nowak" <svv1999@hotmail.com> schrieb im Newsbeitrag news:bvunid$1fqg$1@digitaldaemon.com... > In D it is allowed to call a function like this: > > | fori(0, 0) > > and like this > > | fori(0.0) > > provided, that `f' is overloaded for example like this: > > | void fori(real v){someglobalrealvariable=v;...} > | void fori(int start, int end){for(i=start;i<=end;i++){...}} > > > However, if the programmer wants to type `f(0.0)' but instead types > `f(0,0)' the catastrophe might be unavoidable: > > | Here is a very real example of catastrophic system failure due to a > | simple syntactical problem in a programming language: > | > | The USSR Mars probe, released from the Earth's atmosphere on November > | 27,1971, crash landed on the surface of Mars because its booster rockets > | failed. The failure was due to a single character mistake in the landing > | algorithm, which was written in Fortran. There was a breaking routine > | with a waiting loop of the style "FOR I=1,1000", which didn't perform > | properly, because the comma was replaced with a period, which was > | compiled as "FORI=1.1", variable "FORI" was assigned the value "1.1". > http://www.amadeus-3.com/main_files/oberon2vsCPP.php, [cited 06.02.04] > > How does this agree with D's design goal: > | for practical programmers who need to get the job done quickly, reliably > > So long. > > > > |
February 06, 2004 Re: [Language design] Notational error | ||||
---|---|---|---|---|
| ||||
Posted in reply to davepermen | davepermen wrote: > 1) no problems here in typing the wrong of two.. its a different place. I do not grep what you mean. > 2) syntax highlighting the way i do it makes such situations VERY obvious. [...] That is nice. But syntax highlighting is not part of the language. However, that drives me to the question, whether white space should be made part of the language by introducing a `, ' token as separator for argument lists. Then at least two characters must be wrongly typed. > and btw, you can do this in c++ as well (and java, i think, too). That is at least true for c++. But why follow old errors? So long. |
February 06, 2004 Re: [Language design] Notational error | ||||
---|---|---|---|---|
| ||||
Posted in reply to Manfred Nowak | i don't accidentally type the wrong one as the keys are placed in a way to get accessed very differently by my hands. thats what i ment with 1) 2) i know, it's not a language feature. but there is NO reason today to not do your work on a pc, and then send it to the device. and if you work on a pc, you can have at least TextPad to syntax highlight. hey, we're in 2004. :D btw, i DO understand the problem. i just don't think it is a real problem in real development environments and situations of today anymore. "Manfred Nowak" <svv1999@hotmail.com> schrieb im Newsbeitrag news:bvvpgb$563$1@digitaldaemon.com... > davepermen wrote: > > > 1) no problems here in typing the wrong of two.. its a different place. > > I do not grep what you mean. > > > 2) syntax highlighting the way i do it makes such situations VERY obvious. > [...] > > That is nice. But syntax highlighting is not part of the language. However, that drives me to the question, whether white space should be made part of the language by introducing a `, ' token as separator for argument lists. Then at least two characters must be wrongly typed. > > > and btw, you can do this in c++ as well (and java, i think, too). > > That is at least true for c++. But why follow old errors? > > So long. |
February 06, 2004 Re: [Language design] Notational error | ||||
---|---|---|---|---|
| ||||
Posted in reply to davepermen | On Fri, 06 Feb 2004 11:18:54 +0100, davepermen wrote: [...] > the keys are placed in a way to get accessed very differently by my hands. [...] Upps! Which country do you live in? > there is NO reason today to not do your work on a pc [...] Are you sure? When have you last time convinced the boss of your 300 computer scientists development team to introduce for the whole team an IDE, text program or syntax highlighting extension of your choice? I am really not used to work in military, medical, juridical or environments for the caring professions. You might be more experienced in this areas to state such an opinion. So long. |
February 06, 2004 Re: [Language design] Notational error | ||||
---|---|---|---|---|
| ||||
Posted in reply to Manfred Nowak | > Upps! Which country do you live in? Switzerland. The keys are near, but accessed by different fingers (damn, is that the right english word? :D). default qwertz layout. > Are you sure? yes. anyone ever NOT used a pc to code in the last years? even for integrated controllers, and all. they upload it trough some COM port to the actual system. everyone uses at least DOS with 'edit', to write the code. and today, about every workstation for programmers needs (as every workstation at all:D) some sort of outlook for mailing (hehe), and some sort of internet access (oooonly for searching for infos about current problems, of course..). i know of no programmer who preferes non-syntax-highighted text over syntax-highlighted one. D gives enough possible IDE's and coloured text-editors to chose from. > When have you last time convinced the boss of your 300 computer scientists development team to introduce for the whole team an IDE, text program or syntax highlighting extension of your choice? dunno, normally that goes under the hood, without ever noting from the boss.. hey, it's just the boss:D > I am really not used to work in military, medical, juridical or environments for the caring professions. You might be more experienced in this areas to state such an opinion. uhm.. uhm?! i'm not at all in such an environment. i just know if there is a more comfortable tool to use, people addopt rapitly. and if it's free, even the boss can't complain. and we're talking about D here. how much people are yet in D that don't want to change to an IDE because thei're so used to notepad or 'edit' in dos? i know none. and if we're talking about c++.. vc6 is standard in most places.. never ones / other ones exist, too, of course. but i know of no ide that is in use that doesn't have syntax highlighting. again, we're in 2004. i have 16million colours to spend on 1310720 pixels. i won't write at any time in black and write. except for this newsgroup mails.. > So long. that long |
February 06, 2004 Re: [Language design] Notational error | ||||
---|---|---|---|---|
| ||||
Posted in reply to Manfred Nowak | >However, if the programmer wants to type `f(0.0)' but instead types
>`f(0,0)' the catastrophe might be unavoidable:
>
>| Here is a very real example of catastrophic system failure due to a
>| simple syntactical problem in a programming language:
>|
>| The USSR Mars probe, released from the Earth's atmosphere on November
>| 27,1971, crash landed on the surface of Mars because its booster rockets
>| failed. The failure was due to a single character mistake in the landing
>| algorithm, which was written in Fortran. There was a breaking routine
>| with a waiting loop of the style "FOR I=1,1000", which didn't perform
>| properly, because the comma was replaced with a period, which was
>| compiled as "FORI=1.1", variable "FORI" was assigned the value "1.1".
1) that's what code reviews are for, if the app is safety or "mission" critical then it should be thoroughly review.
2) Unit testing would probably have found it also
even a very strict language like Ada will not prevent all "human" mistakes
|
February 07, 2004 Re: [Language design] Notational error | ||||
---|---|---|---|---|
| ||||
Posted in reply to davepermen | On Fri, 6 Feb 2004 18:35:52 +0100, davepermen <davepermen@hotmail.com> wrote:
> i know of no programmer who preferes non-syntax-highighted text over syntax-highlighted one.
You do now. :-)
I find it distracting and ugly, especially when bright colors are used. I do use fonts (and sizes thereof) in which commas and periods are easily distinguishable, though.
-Scott
|
Copyright © 1999-2021 by the D Language Foundation