On 21/11/2011 20:06, Jesse Phillips wrote:
What you are describing is Head Const, and is not available.
http://www.d-programming-language.org/const-faq.html#head-const
It will not be added as it doesn't provide any guarantees about the code that
is useful
to the compiler. It can't be added to
On 12/01/2011 12:08 AM, Stewart Gordon wrote:
On 21/11/2011 20:06, Jesse Phillips wrote:
What you are describing is Head Const, and is not available.
http://www.d-programming-language.org/const-faq.html#head-const
It will not be added as it doesn't provide any guarantees about the
code that
/21/11 11:04 AM, Alex Rønne Petersen wrote:
Hi,
Is there any way to make a variable single-assignment, regardless of its
type? I.e.:
void foo()
{
some magical keyword? int i = 0;
i = 2; // Error: i cannot be reassigned
}
I realize const and immutable will do this, but they are transitive
Hi,
Is there any way to make a variable single-assignment, regardless of its
type? I.e.:
void foo()
{
some magical keyword? int i = 0;
i = 2; // Error: i cannot be reassigned
}
I realize const and immutable will do this, but they are transitive and
infect the type, which I do
Don't think so.
You could also wrap it in a struct with disabled opAssign, but this would
also change the type.
On 21-11-2011 15:48, Trass3r wrote:
Don't think so.
You could also wrap it in a struct with disabled opAssign, but this
would also change the type.
Perhaps allowing 'final' on fields and locals would be a nice way to
gain this effect...
- Alex
On 11/21/11 11:04 AM, Alex Rønne Petersen wrote:
Hi,
Is there any way to make a variable single-assignment, regardless of its
type? I.e.:
void foo()
{
some magical keyword? int i = 0;
i = 2; // Error: i cannot be reassigned
}
I realize const and immutable will do this, but they are transitive
Petersen wrote:
Hi,
Is there any way to make a variable single-assignment, regardless of its
type? I.e.:
void foo()
{
some magical keyword? int i = 0;
i = 2; // Error: i cannot be reassigned
}
I realize const and immutable will do this, but they are transitive and
infect the type, which I do *not* want
On 11/21/2011 03:04 PM, Alex Rønne Petersen wrote:
Hi,
Is there any way to make a variable single-assignment, regardless of its
type? I.e.:
void foo()
{
some magical keyword? int i = 0;
i = 2; // Error: i cannot be reassigned
}
I realize const and immutable will do
Le 21/11/2011 15:04, Alex Rønne Petersen a écrit :
Hi,
Is there any way to make a variable single-assignment, regardless of its
type? I.e.:
void foo()
{
some magical keyword? int i = 0;
i = 2; // Error: i cannot be reassigned
}
I realize const and immutable will do
/21/11 11:04 AM, Alex Rønne Petersen wrote:
Hi,
Is there any way to make a variable single-assignment, regardless of its
type? I.e.:
void foo()
{
some magical keyword? int i = 0;
i = 2; // Error: i cannot be reassigned
}
I realize const and immutable will do this, but they are transitive
On 21/11/2011 14:04, Alex Rønne Petersen wrote:
Hi,
Is there any way to make a variable single-assignment, regardless of its
type? I.e.:
void foo()
{
some magical keyword? int i = 0;
i = 2; // Error: i cannot be reassigned
}
I realize const and immutable will do this, but they are transitive
What you are describing is Head Const, and is not available.
http://www.d-programming-language.org/const-faq.html#head-const
It will not be added as it doesn't provide any guarantees about the code that
is useful to the compiler. It can't be added to the existing system without
complicating
The only thing I can think of:
struct Once(T)
{
this(T val)
{
i = val;
}
immutable T i;
alias i this;
}
void main()
{
Once!int i = 1; // ok
i = 4; // ng
}
However it seems I've found a little hole in the system:
void foo(ref int x)
{
x = 2;
}
void
14 matches
Mail list logo