Jump to page: 1 2 3
Thread overview
How do you like result variable ?
Jan 31, 2004
Y.Tomino
Jan 31, 2004
Georg Wrede
Jan 31, 2004
Matthew
Feb 01, 2004
Y.Tomino
Feb 05, 2004
Ilya Minkov
Feb 06, 2004
Y.Tomino
Feb 06, 2004
Ilya Minkov
Feb 01, 2004
Mark T
Feb 01, 2004
Roel Mathys
Feb 01, 2004
The one Haranguer
Feb 01, 2004
Sean L. Palmer
Feb 01, 2004
Matthew
Feb 01, 2004
Roel Mathys
Feb 01, 2004
Sean L. Palmer
Feb 01, 2004
Matthew
Feb 02, 2004
The Lone Haranguer
Feb 03, 2004
Serge K
Feb 03, 2004
Serge K
Feb 01, 2004
Juan C
Feb 01, 2004
Roel Mathys
Feb 01, 2004
Stephan Wienczny
Feb 01, 2004
Roel Mathys
Feb 01, 2004
Georg Wrede
Feb 01, 2004
Andy Friesen
Feb 01, 2004
Y.Tomino
Feb 02, 2004
Andy Friesen
Feb 02, 2004
Juan C
Feb 05, 2004
matthias becker
Feb 05, 2004
J C Calvarese
Feb 02, 2004
C
January 31, 2004
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
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
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
>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
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
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
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
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
"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
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
>>
>
>


« First   ‹ Prev
1 2 3