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

Key: BOO-500
Type: New Feature New Feature
Status: Resolved Resolved
Resolution: Fixed
Priority: Minor Minor
Assignee: Doug H
Reporter: Cameron Kenneth Knight
Votes: 0
Watchers: 0
Operations

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

self[index] instead of [DefaultMember(Item)] Item(index)

Created: 28/Sep/05 10:41 PM   Updated: 04/Mar/06 08:18 AM
Component/s: Compiler
Affects Version/s: None
Fix Version/s: 0.7.6

Time Tracking:
Not Specified

Environment: All
Issue Links:
Related
 


 Description  « Hide
currently to access an object like an array, you have to do this:

[DefaultMember("Item")]
class Alpha:
Item(index):
return DoSomething(index)

Alpha()['bravo']
It would make a lot more sense to do

class Alpha:
self[index]:
return DoSomething(index)

Alpha()['bravo']



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Rodrigo B. de Oliveira - 29/Sep/05 08:40 AM
How about an attribute that does the System.Reflection.DefaultMember thing for you?

class Alpha:
[default] Item(index):
get:
return DoSometing(index)

No special syntax and semantics needed.


Cameron Kenneth Knight - 05/Oct/05 11:45 AM
I don't think the [default] attribute is what is needed.

C#'s way of doing this(index) is a very nice syntax.

It's clear and to the point and you'll know what to expect even before you know what an indexer does.


Doug H - 16/Nov/05 04:00 PM
Just noting. Syntax for default indexers will use "self" with square brackets instead of parentheses:

class Alpha:
self[index]:
return DoSomething(index)

And non-default indexed properties will switch over to square brackets instead of parentheses too:

class Person:
Child[index] as Person:
return cast(Person, _children[index])

And manual use of [DefaultMember] attribute will be deprecated.


Doug H - 04/Mar/06 08:18 AM
Editing to show approved syntax since this is the only documentation we have