| Thread overview | |||||||
|---|---|---|---|---|---|---|---|
|
July 28, 2008 What is the difference? (D2) | ||||
|---|---|---|---|---|
| ||||
Using them as parameter modifiers in functions, what is the difference between "in", "const" and "final"?
e.g.
void func(final int i)
{...}
vs
void func(in int i)
{...}
vs
void func(const int i)
{...}
Thanks
| ||||
July 28, 2008 Re: What is the difference? (D2) | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Dave B. | Dave B. wrote:
> Using them as parameter modifiers in functions, what is the difference between "in", "const" and "final"?
>
> e.g.
>
> void func(final int i)
> {...}
>
> vs
>
> void func(in int i)
> {...}
>
> vs
>
> void func(const int i)
> {...}
>
> Thanks
Currently, I think that 'const' and 'in' are the same. While 'final' is not implemented, and I can't recall what it was supposed to do.
| |||
July 29, 2008 Re: What is the difference? (D2) | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Dave B. | On Mon, 28 Jul 2008 13:24:12 +0400, Dave B. <nospam@thankyou.com> wrote: > Using them as parameter modifiers in functions, what is the difference between "in", "const" and "final"? > > e.g. > > void func(final int i) > {...} > > vs > > void func(in int i) > {...} > > vs > > void func(const int i) > {...} > > Thanks in, out and inout are explained here very well: http://www.digitalmars.com/pnews/read.php?server=news.digitalmars.com&group=digitalmars.D.learn&artnum=6440 in - is a do-nothing modifier, since it is a default behaviour. const - variable is a constant value in the function scope. D2 only final - not supported. use const instead | |||
July 29, 2008 Re: What is the difference? (D2) | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Koroskin Denis | Koroskin Denis wrote:
> On Mon, 28 Jul 2008 13:24:12 +0400, Dave B. <nospam@thankyou.com> wrote:
>
>> Using them as parameter modifiers in functions, what is the difference between "in", "const" and "final"?
>>
>> e.g.
>>
>> void func(final int i)
>> {...}
>>
>> vs
>>
>> void func(in int i)
>> {...}
>>
>> vs
>>
>> void func(const int i)
>> {...}
>>
>> Thanks
>
> in, out and inout are explained here very well:
> http://www.digitalmars.com/pnews/read.php?server=news.digitalmars.com&group=digitalmars.D.learn&artnum=6440
>
>
> in - is a do-nothing modifier, since it is a default behaviour.
> const - variable is a constant value in the function scope. D2 only
> final - not supported. use const instead
That's about D1 though. At least at one point, Walter said that 'in' would mean 'final const' in D2. I don't know if it's panned out that way or not.
--bb
| |||
July 29, 2008 Re: What is the difference? (D2) | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Bill Baxter | On Tue, 29 Jul 2008 09:45:51 +0900, Bill Baxter wrote: > Koroskin Denis wrote: >> On Mon, 28 Jul 2008 13:24:12 +0400, Dave B. <nospam@thankyou.com> wrote: >> >>> Using them as parameter modifiers in functions, what is the difference between "in", "const" and "final"? >>> >>> e.g. >>> >>> void func(final int i) >>> {...} >>> >>> vs >>> >>> void func(in int i) >>> {...} >>> >>> vs >>> >>> void func(const int i) >>> {...} >>> >>> Thanks >> >> in, out and inout are explained here very well: http://www.digitalmars.com/pnews/read.php? server=news.digitalmars.com&group=digitalmars.D.learn&artnum=6440 >> >> >> in - is a do-nothing modifier, since it is a default behaviour. const - variable is a constant value in the function scope. D2 only final - not supported. use const instead > > That's about D1 though. At least at one point, Walter said that 'in' would mean 'final const' in D2. I don't know if it's panned out that way or not. > > --bb I thought with all the changes that happened final was thrown out. | |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply