[nem-bug] [Nemerle 0000627]: Increment in aggument

feedback at nemerle.org feedback at nemerle.org
Wed May 3 18:37:28 CEST 2006


The following issue has been RESOLVED.
======================================================================
<http://nemerle.org/bugs/view.php?id=627> 
======================================================================
Reported By:                VladD2
Assigned To:                nazgul
======================================================================
Project:                    Nemerle
Issue ID:                   627
Category:                   Compiler
Reproducibility:            always
Severity:                   minor
Priority:                   normal
Status:                     resolved
Resolution:                 fixed
Fixed in Version:           
======================================================================
Date Submitted:             02-26-2006 04:33 CET
Last Modified:              05-03-2006 18:37 CEST
======================================================================
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.

----------------------------------------------------------------------
 VladD2 - 02-26-06 16:11 
----------------------------------------------------------------------
The result of such a behavior is that the resulting code does not match the
intention, and no messages are generated at that! No tricks with
hash-tables can justify such problems. The beginners would leave off the
language, if they do not understand what’s going on.

----------------------------------------------------------------------
 nazgul - 05-03-06 18:37 
----------------------------------------------------------------------
The code is now rejected by compiler. No void to object auto-casts are
allowed.
As for design of ++ and -- operators I guess we will stick for with
current design. Maybe we should add +++ and --- operators, which returns
value though...

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                          
02-26-06 16:11 VladD2         Note Added: 0001112                          
05-03-06 18:37 nazgul         Status                   new => resolved     
05-03-06 18:37 nazgul         Resolution               open => fixed       
05-03-06 18:37 nazgul         Assigned To               => nazgul          
05-03-06 18:37 nazgul         Note Added: 0001225                          
======================================================================




More information about the bugs mailing list