[nem-bug] [Nemerle 0000572]: I cannot understand conversion between
int and char
feedback at nemerle.org
feedback at nemerle.org
Wed Nov 16 19:19:45 CET 2005
The following issue has been CLOSED
======================================================================
<http://nemerle.org/bugs/view.php?id=572>
======================================================================
Reported By: ymatsu
Assigned To:
======================================================================
Project: Nemerle
Issue ID: 572
Category: Compiler (type engine)
Reproducibility: always
Severity: minor
Priority: normal
Status: closed
Resolution: not an issue
Fixed in Version:
======================================================================
Date Submitted: 11-15-2005 19:12 CET
Last Modified: 11-16-2005 19:19 CET
======================================================================
Summary: I cannot understand conversion between int and char
Description:
def x:int = 'a';
doesn't work.
Compiler message is
parser.n:5:9:5:12: error: expected int, got char in type-enforced
expression: System.Char is not a subtype of System.Int32 [simple require]
How can I convert int from char, char from int?
======================================================================
----------------------------------------------------------------------
nazgul - 11-15-05 19:20
----------------------------------------------------------------------
You must use explicit cast to convert from char to int:
def x = 'a' :> int;
We do not allow chars to be automatically converted to ints, because
treating chars as ints is usually a mistake and the mapping is not clear
(i.e. for unicode characters). Using :> (runtime cast) instead of :
(staitc, compile-time type check) forces conversion.
----------------------------------------------------------------------
ymatsu - 11-16-05 10:32
----------------------------------------------------------------------
Thank you. I understand.
Issue History
Date Modified Username Field Change
======================================================================
11-15-05 19:12 ymatsu New Issue
11-15-05 19:20 nazgul Note Added: 0001028
11-16-05 10:32 ymatsu Note Added: 0001029
11-16-05 19:19 nazgul Status new => closed
11-16-05 19:19 nazgul Resolution open => not an issue
11-16-05 19:19 nazgul Description Updated
======================================================================
More information about the bugs
mailing list