Re: I think C# is forcing us to write more (redundant) code
- From: "Willy Denoyette [MVP]" <willy.denoyette@xxxxxxxxxx>
- Date: Mon, 29 Aug 2005 23:11:09 +0200
"Jon Skeet [C# MVP]" <skeet@xxxxxxxxx> wrote in message
news:MPG.1d7d80f5d8ccc8ad98c626@xxxxxxxxxxxxxxxxxxxxxxx
> Willy Denoyette [MVP] <willy.denoyette@xxxxxxxxxx> wrote:
>> > No, that's not true for local variables. Local variables aren't
>> > assigned to anything by default, and can't be read until they've been
>> > definitely assigned.
>>
>> Actualy they are, the IL directive .locals init, emitted by C# , VB.NET
>> and
>> ME C++, is a hint for the JIT to initialize the locals (stack as well as
>> register allocated) to 0 (zero).
>
> That may be true of the implementation, but not of the specification. I
> should have made that clearer - it's actually important when it comes
> to calling methods with "out" parameters written in other languages,
> but within C# the value is effectively unspecified. This is perhaps
> unfortunate...
>
> --
> Jon Skeet - <skeet@xxxxxxxxx>
> http://www.pobox.com/~skeet
> If replying to the group, please do not mail me too
Mind to tell us what specification are you talking about?
To me it's clear that C#, J#, C++ and VB.NET compilers emits a '.locals
init' directive and as a result the locals are initialized to zero. Sure,
the locals are not explicitely initialized (as per specification?), but all
(MS) compilers do emit the .local init directive in the method header,
question is based on what specification.
Not sure what 'out' parameters have to do with this, though, the callee
does/should not consider an out argument being 'initialized' by the caller,
the value it as doesn't matter anyway.
Willy.
.
- Follow-Ups:
- Re: I think C# is forcing us to write more (redundant) code
- From: Jon Skeet [C# MVP]
- Re: I think C# is forcing us to write more (redundant) code
- From: Willy Denoyette [MVP]
- Re: I think C# is forcing us to write more (redundant) code
- References:
- I think C# is forcing us to write more (redundant) code
- From: Neo The One
- Re: I think C# is forcing us to write more (redundant) code
- From: Lasse Vågsæther Karlsen
- Re: I think C# is forcing us to write more (redundant) code
- From: Neo The One
- Re: I think C# is forcing us to write more (redundant) code
- From: Bob Powell [MVP]
- Re: I think C# is forcing us to write more (redundant) code
- From: Jon Skeet [C# MVP]
- Re: I think C# is forcing us to write more (redundant) code
- From: Willy Denoyette [MVP]
- Re: I think C# is forcing us to write more (redundant) code
- From: Jon Skeet [C# MVP]
- I think C# is forcing us to write more (redundant) code
- Prev by Date: Re: Hungarian Notation
- Next by Date: Re: NewBie Simple question
- Previous by thread: Re: I think C# is forcing us to write more (redundant) code
- Next by thread: Re: I think C# is forcing us to write more (redundant) code
- Index(es):
Relevant Pages
|