[nem-bug] [Nemerle 0000627]: Increment in aggument
feedback at nemerle.org
feedback at nemerle.org
Sun Feb 26 14:46:55 CET 2006
A NOTE has been added to this issue.
======================================================================
<http://nemerle.org/bugs/view.php?id=627>
======================================================================
Reported By: VladD2
Assigned To:
======================================================================
Project: Nemerle
Issue ID: 627
Category: Compiler
Reproducibility: always
Severity: minor
Priority: normal
Status: new
======================================================================
Date Submitted: 02-26-2006 04:33 CET
Last Modified: 02-26-2006 14:46 CET
======================================================================
Summary: Increment in aggument
Description:
This example:
[code]
using System.Console;
mutable x = 0;
WriteLine("-- {0} --", x++);
WriteLine("-- {0} --", ++x);
[/code]
print:
-- --
-- --
But must print:
-- 0 --
-- 2 --
======================================================================
----------------------------------------------------------------------
steffen - 02-26-06 11:08
----------------------------------------------------------------------
The increment and decrement operators return a void in nemerle.
You however can use something like:
WriteLine("-- {0} --", {x++; x});
----------------------------------------------------------------------
VladD2 - 02-26-06 14:31
----------------------------------------------------------------------
> The increment and decrement operators return a void in nemerle.
1. This is not logical.
2. The compiler should report error message since void-value was put into
parameter of a method.
----------------------------------------------------------------------
nazgul - 02-26-06 14:46
----------------------------------------------------------------------
1. This is logical with regards to assignment operator, which is returning
void. This way i++ is simply a shortcut for 'i=i+1', which returns void
2. We allow using void as proper type of value. It is similar to union
types in functional languages. This way you can use functions returning
void as arguments where generic functions 'a->'b are expected. Also you
can for example define Hashtable[int,void], and use hash.Add (1,()) - it
behaves like set this way.
Issue History
Date Modified Username Field Change
======================================================================
02-26-06 04:33 VladD2 New Issue
02-26-06 11:08 steffen Note Added: 0001109
02-26-06 14:31 VladD2 Note Added: 0001110
02-26-06 14:46 nazgul Note Added: 0001111
======================================================================
More information about the bugs
mailing list