« 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


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

 « Return to Thread: Syntax for generic parameter declaration