Syntax for generic parameter declaration

View: New views
10 Messages — Rating Filter:   Alert me  
< Prev | 1 - 2 | Next >

Re: Syntax for generic parameter declaration

by Wraith-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


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
-~----------~----~----~----~------~----~------~--~---


Re: Syntax for generic parameter declaration

by George-94 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


>Why the 'of'?
'of' for better readership, nothing else, I think.
>Is there a
particular reason so many people seem to favour the trailing form?
C# programmers lobby :-)

On 1 июн, 06:03, 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.
>
> 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
-~----------~----~----~----~------~----~------~--~---


Re: Syntax for generic parameter declaration

by Doug H :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message




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
                   ) as IDictionary[of TState, IList of ITransition[of
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.


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---


Re: Syntax for generic parameter declaration

by Arron Washington-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

??

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 there's already a non-ugly syntax.

On 6/1/07, Doug H <doug00@...> 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
                   ) as IDictionary[of TState, IList of ITransition[of
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.




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
-~----------~----~----~----~------~----~------~--~---


Re: Syntax for generic parameter declaration

by Avishay Lavie :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


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
> 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
> >                    ) as IDictionary[of TState, IList of ITransition[of
> > 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


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---


Re: Syntax for generic parameter declaration

by Arron Washington-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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

> 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
> >                    ) as IDictionary[of TState, IList of ITransition[of

> > 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
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---


Re: Syntax for generic parameter declaration

by Arron Washington-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.
To clear things up I'm not trying to be non-conformist just to be non-conformist; I just think that if there's a cleaner way to do it, we should do it -- generics isn't a topic that you're just going to intuitively learn how to use without having to examine the syntax for it, first.

On 6/1/07, Arron Washington <l33ts0n@...> wrote:
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

> 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
> >                    ) as IDictionary[of TState, IList of ITransition[of

> > 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
-~----------~----~----~----~------~----~------~--~---


Re: Syntax for generic parameter declaration

by Wraith-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


> C# programmers lobby :-)

I'm mainly a c# programmer so i'm quite used to it's way of doing
things. It's not really a compelling argument for designing one
langauge that you should do as all the others did. If we followed that
reasoning they'd all be lisp or c which isn't desirable. Python
doesn't really have this sort of construct because we're talking
typing but that doesn't mean the c# way is the best way to proceed.

It irritates me slightly with C# that when i declare a generic
parameter that i have to remember the paramters as i'm typing and once
i get finished writing the argument list i have to reintroduce the
generic parameter names and apply constraints to them, it's sort of a
syntactic "see later" and it doesn't need to happen. When you declare
types you intriduce the name and specify it's bases immediately so i'd
find it neater to do the same with generics. It also happens to map
quite closely to the IL layout.

> properties use [] in the type definition
Ah, hadn't thought of that one. Thanks. More a symptom of a lack of
available pairs and too much overloadng on [] than anything else.

> 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

Now this could work, with a few small changes :)
How about:

public static def foobar(par1 as T, par2 as Z, par3 as Y) as What
   generic T(IFoo,contravariant)
   generic Z(constructor)
   generic Y(covariant):
   print "types: {0}",typeof(T).Name,typeof(Z).Name,typeof(Y).Name


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---


Re: Syntax for generic parameter declaration

by Avishay Lavie :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


You have some pretty good points there. Your last example, however, is
against your original point since it does a kind of "see later" that
is worse than the previous suggestion: first you USE the parameters,
then you declare them. That's really pretty confusing.

I'm half taken by your argument, and I find the inline syntax that
echoes the inheritance syntax the best suggestion in that category.

On Jun 2, 4:00 pm, Wraith <wrai...@...> wrote:

> > C# programmers lobby :-)
>
> I'm mainly a c# programmer so i'm quite used to it's way of doing
> things. It's not really a compelling argument for designing one
> langauge that you should do as all the others did. If we followed that
> reasoning they'd all be lisp or c which isn't desirable. Python
> doesn't really have this sort of construct because we're talking
> typing but that doesn't mean the c# way is the best way to proceed.
>
> It irritates me slightly with C# that when i declare a generic
> parameter that i have to remember the paramters as i'm typing and once
> i get finished writing the argument list i have to reintroduce the
> generic parameter names and apply constraints to them, it's sort of a
> syntactic "see later" and it doesn't need to happen. When you declare
> types you intriduce the name and specify it's bases immediately so i'd
> find it neater to do the same with generics. It also happens to map
> quite closely to the IL layout.
>
> > properties use [] in the type definition
>
> Ah, hadn't thought of that one. Thanks. More a symptom of a lack of
> available pairs and too much overloadng on [] than anything else.
>
> > 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
>
> Now this could work, with a few small changes :)
> How about:
>
> public static def foobar(par1 as T, par2 as Z, par3 as Y) as What
>    generic T(IFoo,contravariant)
>    generic Z(constructor)
>    generic Y(covariant):
>    print "types: {0}",typeof(T).Name,typeof(Z).Name,typeof(Y).Name


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---


Re: Syntax for generic parameter declaration

by Wraith-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


> You have some pretty good points there. Your last example, however, is
> against your original point since it does a kind of "see later" that
> is worse than the previous suggestion: first you USE the parameters,
> then you declare them. That's really pretty confusing.

Yes, because a lot of people seem to prefer the terminal syntax. I'm
trying to find something acceptible that isn't just me demanding what
i want. I still think inline is better but i can't just keep shouting
about that can i? :)

I also realised that there isn't any requirement for the generic
parameters to be delcared between the name definition and the
parameter-list. They could very well be somewhere else. From a parsing
point of view (computer and human) it's probably easier to work with
them as in c# but it's worth looking at.

> I'm half taken by your argument, and I find the inline syntax that
> echoes the inheritance syntax the best suggestion in that category.

> > public static def foobar(par1 as T, par2 as Z, par3 as Y) as What
> >    generic T(IFoo,contravariant)
> >    generic Z(constructor)
> >    generic Y(covariant):
> >    print "types: {0}",typeof(T).Name,typeof(Z).Name,typeof(Y).Name

public static def foobar[of
T(IFoo,contravariant),Z(constructor),Y(covariant)](par1 as T, par2 as
Z, par3 as Y) as What:
    print "types: {0}",typeof(T).Name,typeof(Z).Name,typeof(Y).Name

works for me, not a big fan of the "[of " but that seems to necasary
so i'll live with it.


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

< Prev | 1 - 2 | Next >