« Return to Thread: Syntax for generic parameter declaration
I differ on the opinion of conformity; in this case I think conformity means we're going to have to scrap with some very poor (aesthetically and otherwise) stuff.
As for the colon, well, put it where-ever the hell you want it -- personally I would put it after the parameter declaration () since it looks nicer.On 6/1/07, Avish <some.avish@...> wrote:
I don't see where the I'm-starting-the-body-now-kthx colon goes in
your example.
Also, I think it's better if the syntax for generic {type | method}
definitions echoes the syntax for their constructed counterparts, that
is, using "of" after the entity's name. It's more intuitive that way.
On Jun 1, 10:33 pm, "Arron Washington" <l33t...@...> wrote:
> ??
>
> public static def foobar(par1 as T, par2 as Z, par3 as Y)
> generic T : of, where constraint (optional)
> generic Z : of, where constraint (optional)
> generic Y
>
> Cheat -- think outside the box and _cheat_. Stealing is preferrable if> > ) as IDictionary[of TState, IList of ITransition[of
> there's already a non-ugly syntax.
>
> On 6/1/07, Doug H <dou...@...> wrote:
>
>
>
>
>
> > On May 31, 8:03 pm, Wraith <wrai...@...> wrote:
> > > 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.
>
> > > 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)
>
> > Here it is with vb-like inline syntax like daniel mentioned, plus in
> > python style (no static, public when unnecessary):
>
> > def CreateTransitions[of TState as IEquatable[of TState], TValue as
> > 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)
>
> > My earlier proposal was to put generic parameters at the beginning of
> > the normal parameters list so
> > people don't forget the parentheses. This version requires less
> > parentheses and brackets. You can
> > tell which parameters are generic by the "of" at the beginning:
>
> > def CreateTransitions(of TState as IEquatable of TState, of TValue as
> > 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> --
> > TState,TValue]]:
> > dict = TransitionDictionary(of TState, of IList of Transition[of
> > TState, TValue], stateComparer)
>
> > Here is a no-bracket version, cleaner on the eyes and more explicit
> > about which parameters are generic
> > (the brackets in all the other versions don't require "of" for generic
> > parameters after the first one in a list):
>
> > def CreateTransitions(of TState as IEquatable of TState,
> > of TValue as IComparable of TValue,
> > stateMap as IDictionary(of ISet of TState, of
> > TState),
> > states as IDictionary(of ISet of TState, of
> > IDictionary(of Predicate of TValue, of ISet of TState)),
> > stateComparer as IEqualityComparer of TState
> > ) as IDictionary(of TState, of IList of
> > ITransition(of TState, of TValue)):
> > dict = TransitionDictionary(of TState, of IList of Transition(of
> > TState, of 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.
>
> > properties use [] in the type definition
>
> > Either way, "X[of Y]" or "X(of Y)" should be substitutable with "X of
> > Y" I believe.
>
> College student by day, code mercenary by night, I am the Geek Ninja!
>
> http://geekninja.blogspot.com
http://geekninja.blogspot.com
--
College student by day, code mercenary by night, I am the Geek Ninja!
http://geekninja.blogspot.com
--~--~---------~--~----~------------~-------~--~----~
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
| Free embeddable forum powered by Nabble | Forum Help |