[nem-bug] [Nemerle 0000633]: You cannot overload += or other
operators that are defined as macros in macros/operators.n
feedback at nemerle.org
feedback at nemerle.org
Tue Mar 7 19:32:10 CET 2006
A NOTE has been added to this issue.
======================================================================
<http://nemerle.org/bugs/view.php?id=633>
======================================================================
Reported By: amp
Assigned To:
======================================================================
Project: Nemerle
Issue ID: 633
Category: The Language
Reproducibility: always
Severity: minor
Priority: normal
Status: new
======================================================================
Date Submitted: 03-06-2006 01:13 CET
Last Modified: 03-07-2006 19:32 CET
======================================================================
Summary: You cannot overload += or other operators that are
defined as macros in macros/operators.n
Description:
Because the macro is applied before the user defined operators are applied,
the overload is silently ignored.
++ and -- are overloadable, but cannot be applied to immutable variables
because the macro performs an assignment.
I think it is important to allow an arbitrary function to be called by any
operator, because it allows programs to define mini-languages that operate
among a group of classes.
That being said, this issue should at least be documented.
The operators effected are:
&&, ||, %||, %&&, %^^, ++, --, +=, -=, *=, /=, <<=, >>=, %=, |=, &=, ^=,
<->, ::=
======================================================================
----------------------------------------------------------------------
nazgul - 03-07-06 19:32
----------------------------------------------------------------------
AFAIR this is just like in C# and it is quite good design - all those
operators are (and should remain) shortcuts for a longer, more verbose
assignment expressions. So you can overload + operator and compiler will
automatically make ++ +=, etc. operators work as expected with this.
Of course, this is a restriction, but sometimes compiler should force
consistent and sane design on developer :)
Issue History
Date Modified Username Field Change
======================================================================
03-06-06 01:13 amp New Issue
03-06-06 03:17 amp Issue Monitored: amp
03-07-06 19:32 nazgul Note Added: 0001115
======================================================================
More information about the bugs
mailing list