History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: BOO-223
Type: Improvement Improvement
Status: Open Open
Priority: Minor Minor
Assignee: Rodrigo B. de Oliveira
Reporter: Scott Fleckenstein
Votes: 3
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Boo

Improve Operator Override (and General Comparison)

Created: 14/Dec/04 12:58 AM   Updated: 22/Mar/06 06:34 PM
Component/s: Compiler
Affects Version/s: None
Fix Version/s: None

Time Tracking:
Not Specified

File Attachments: 1. File operators.diff (297 kb)
2. Zip Archive operators.zip (63 kb)

Issue Links:
dependent


 Description  « Hide
improve the syntax for overriding, such that you can define:

def +:
pass

for both binary and unary operations, and also allow the definition of a general comparison function such that:

def <=>:
rvalue.Value <=> lvalue.Value

will allow any of the comparison operations to be performed.



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Scott Fleckenstein - 14/Dec/04 01:00 AM
operators.zip is a patch (and added files) to enable the above behavior. It seems to work pretty well, but whether it is ready for prime time is the community's decision.

Scott Fleckenstein - 14/Dec/04 12:35 PM
Apparrently I am an idiot, since the one time i didn't check the patch it broke. Something happened with the #regions in some of the files. This patch should successfully apply.

Sorry everyone


Arron Washington - 14/Dec/04 05:39 PM
I'm down with that - its a cleaner, easier to read syntax than having op_... everywhere, that's for sure.


Doug H - 21/Mar/06 07:04 PM
Approved syntax for operator overloading described at: http://groups.google.com/group/boolang/msg/6a00315e5939e28a?hl=en&

Arron Washington - 21/Mar/06 07:22 PM
Does that mean we get the spaceship operator, too?

Doug H - 22/Mar/06 06:34 PM
I don't see why not. It's a nice shortcut for "==", "!=", "<", ">", "<=", ">="
Even a lot of C# people want it:
http://blogs.msdn.com/abhinaba/archive/2005/10/11/479537.aspx
http://www.dotnetjunkies.com/WebLog/anoras/archive/2005/10/11/133164.aspx