« Return to Thread: Syntax for generic parameter declaration

Re: Syntax for generic parameter declaration

by Wraith-2 :: Rate this Message:

Reply to Author | View in Thread


Heres a rather lengthy example i pulled out of a c# project, to show
what the syntax will look like when it gets unwieldy rather than the
nice neat examples we've got here at the moment.

Trailing:

public static def CreateTransitions[of TState,TValue](
    stateMap as IDictionary[of ISet[of TState],TState],
    states as IDictionary[of ISet[of TState],IDictionary[of
Predicate[of TValue],ISet[of TState]]],
    stateComparer as IEqualityComparer[of TState]
    ) as IDictionary[of TState,IList[of ITransition[of
TState,TValue]]]
    given TSTate isa IEquatable[of TState]
    given TValue isa IComparable[of TValue]:
    dict = TransitionDictionary[of TState,IList[of Transition[of
TState,TValue]]](stateComparer)


Inline:

public static def CreateTransitions[of TState(IEquatable[of
TState]),TValue(IComparable[of TValue])](
    stateMap as IDictionary[of ISet[of TState],TState],
    states as IDictionary[of ISet[of TState],IDictionary[of
Predicate[of TValue],ISet[of TState]]],
    stateComparer as IEqualityComparer[of TState]
    ) as IDictionary[of TState,IList[of ITransition[of
TState,TValue]]]:
    dict = TransitionDictionary[of TState,IList[of Transition[of
TState,TValue]]](stateComparer)


Why the 'of'? is there some place where indexing, slicing or some
other use or [] is available in type definitions? it's be cleaner
without the keyword and [] is already containing the list.

I still feel that the inline syntax is clearer, shorter too in the way
i've laid it out but that is entirely personal preference. Is there a
particular reason so many people seem to favour the trailing form?
What is the rationale for it? to me it makes the division between
definition and body less clear than it already is in the example, it
takes more effort than it needs to for you to mentally parse the
definition and find the point where the code you want to work with is.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Boo Programming Language" group.
To post to this group, send email to boolang@...
To unsubscribe from this group, send email to boolang-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/boolang
-~----------~----~----~----~------~----~------~--~---

 « Return to Thread: Syntax for generic parameter declaration