Thread overview | ||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
January 31, 2004 How do you like result variable ? | ||||
---|---|---|---|---|
| ||||
Many functions are written as follows: int func(...) { int result; ... result = ... ... return result; } I feel it's needless bother. I prefer auto-declared "result" variable like Eiffel or Delphi. int func(...) { ... result = ... ... } It simplifies code. And return is one of jump statements. Although I don't dislike a jump statement, I don't want to use it where jump is unnecessary. Even if result introduced, the compatibility will be kept if return will set result before exit. Thanks. YT |
January 31, 2004 Re: How do you like result variable ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Y.Tomino | I agree. The shorter your functions, the more you suffer from this. Borland has done a number of things right, and this is one of them. In article <bvhb5v$2uc4$1@digitaldaemon.com>, Y.Tomino says... > >Many functions are written as follows: > >int func(...) >{ > int result; > ... > result = ... > ... > return result; >} > >I feel it's needless bother. >I prefer auto-declared "result" variable like Eiffel or Delphi. > >int func(...) >{ > ... > result = ... > ... >} > >It simplifies code. > >And return is one of jump statements. >Although I don't dislike a jump statement, I don't want to use it where jump >is unnecessary. >Even if result introduced, the compatibility will be kept if return will set >result before exit. > >Thanks. >YT > |
January 31, 2004 Re: How do you like result variable ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Y.Tomino | Pointless sugar. Sorry "Y.Tomino" <demoonlit@inter7.jp> wrote in message news:bvhb5v$2uc4$1@digitaldaemon.com... > Many functions are written as follows: > > int func(...) > { > int result; > ... > result = ... > ... > return result; > } > > I feel it's needless bother. > I prefer auto-declared "result" variable like Eiffel or Delphi. > > int func(...) > { > ... > result = ... > ... > } > > It simplifies code. > > And return is one of jump statements. > Although I don't dislike a jump statement, I don't want to use it where jump > is unnecessary. > Even if result introduced, the compatibility will be kept if return will set > result before exit. > > Thanks. > YT > |
February 01, 2004 Re: How do you like result variable ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Y.Tomino | >I prefer auto-declared "result" variable like Eiffel or Delphi.
<snobbery>
It seems to me that "scripting" languages do this, and "programming" languages
require declaration of variables. D is a programming language, and I am a
programmer, not a script writer.
Although some scripting languages are now quite powerful (Perl and Java), and perhaps some programming languages are less powerful (C# and VB), there is still a distinction and times when a scripting language just won't cut it. </snobbery>
|
February 01, 2004 Re: How do you like result variable ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Juan C | Juan C wrote:
>>I prefer auto-declared "result" variable like Eiffel or Delphi.
>
>
> <snobbery>
> It seems to me that "scripting" languages do this, and "programming" languages
> require declaration of variables. D is a programming language, and I am a
> programmer, not a script writer.
>
> Although some scripting languages are now quite powerful (Perl and Java), and
> perhaps some programming languages are less powerful (C# and VB), there is still
> a distinction and times when a scripting language just won't cut it.
> </snobbery>
>
>
Delphi is a compiled language and not a "scripting" language, don't know whether this is standard pascal though.
btw: its compile times are fast, really, really fast.
I don't like Java, but it's rarely spoken about as a scripting language. And if I'm not mistaken efforts are underway to generate a native binary from Java source code.
My scripting language of choice would be Python :-)
bye,
roel
|
February 01, 2004 Re: How do you like result variable ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Roel Mathys | Roel Mathys wrote:
>
> Delphi is a compiled language and not a "scripting" language, don't know whether this is standard pascal though.
> btw: its compile times are fast, really, really fast.
>
Delphi uses a language called Object Pascal.
It uses modules and some kind of precompilation.
Stephan
|
February 01, 2004 Re: How do you like result variable ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Stephan Wienczny | Stephan Wienczny wrote:
> Roel Mathys wrote:
>
>>
>> Delphi is a compiled language and not a "scripting" language, don't know whether this is standard pascal though.
>> btw: its compile times are fast, really, really fast.
>>
>
> Delphi uses a language called Object Pascal.
> It uses modules and some kind of precompilation.
>
> Stephan
>
you mean each unit is precompiled into an object file and only recompiled whenever the source in it has changed?
This speeds up the *generation* process, just like VC++ with precompiled headers and other languages that use some kind of modules :-)
This way compilation only happens for a few files, but linking still needs to be done.
or do you mean don't
"don"t know whether this is standard pascal though"
=> I knew delphi = pascal with (borland property) object extension
In the meantime I looked it up in one of my old (and I mean old) Pascal manual, and the "result" shortcut was certainly in it.
bye,
roel
|
February 01, 2004 Re: How do you like result variable ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Roel Mathys | In article <bvingb$27ve$1@digitaldaemon.com>, Roel Mathys says... > >Stephan Wienczny wrote: > >> Roel Mathys wrote: >> >>> >>> Delphi is a compiled language and not a "scripting" language, don't >>> know whether this is standard pascal though. >>> btw: its compile times are fast, really, really fast. Ever since Turbo Pascal 1.0 (23 years ago) they've been very proud of having the fastest Pascal compilers, and because of the language itself, also faster than any C compiler. Object Pascal, as they call the language, is the de facto standard today. (Even if Richard Stallman &co try to belittle this factoid.) >> Delphi uses a language called Object Pascal. >> It uses modules and some kind of precompilation. The Delphi compiler is split in two stages, a "front" and a "back". The "back" is the same for Delphi and Borland C++. (I guess Walter does the same with D and his C++ ??) >In the meantime I looked it up in one of my old (and I mean old) Pascal manual, and the "result" shortcut was certainly in it. I've always been under the impression that this was one of the original thoughts when N. Wirth published the language. One of the main ideas was to cut through unnecessary writing, where possible. The language was to be smooth, consistent, easy to learn, yet powerful enough for serious programming. Pascal is actually older than C. It was developed during the late 1960's. In my bookshelf I found "The Pascal Language" published by Helsinki University of Technology - Laboratory of Information Processing Science, 1980. The "result shortcut" is presented as an integral part of Pascal. At the end is an appendix about differences between some implementations of the day, and the result shortcut is not among them. |
February 01, 2004 Re: How do you like result variable ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Matthew | "return" has two functions(return value and exit), I think it's unnatural syntax sugar that makes redundant code. However, as you wrote, in the language which already has return, it's unavoidable that another method seems to pointless. Thank you. YT |
February 01, 2004 Re: How do you like result variable ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Matthew | In article <bvhdr9$19n$1@digitaldaemon.com>, Matthew says... > >Pointless sugar. > >Sorry agreed - because D is meant to attract C, C++, Java programmers that are use to a certain idiom, at this point I would find reading "result" code to be confusing after so many years of "return" I think Walter made this pretty clear when he laid out his design goals for D. > >"Y.Tomino" <demoonlit@inter7.jp> wrote in message news:bvhb5v$2uc4$1@digitaldaemon.com... >> Many functions are written as follows: >> >> int func(...) >> { >> int result; >> ... >> result = ... >> ... >> return result; >> } >> >> I feel it's needless bother. >> I prefer auto-declared "result" variable like Eiffel or Delphi. >> >> int func(...) >> { >> ... >> result = ... >> ... >> } >> >> It simplifies code. >> >> And return is one of jump statements. >> Although I don't dislike a jump statement, I don't want to use it where >jump >> is unnecessary. >> Even if result introduced, the compatibility will be kept if return will >set >> result before exit. >> >> Thanks. >> YT >> > > |
Copyright © 1999-2021 by the D Language Foundation