Trait-typing of traits: Function, Method, Callable

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Trait-typing of traits: Function, Method, Callable

Des.P
I really like how parameterized data-structure types are handled by traits:

        c = List(Tuple(Int, String),  Instance(A))

Why isn't this approach also used to trait-type Functions (and Methods, Callables, ...) by their argument and return types?

class A:
        i = Int
        s = String
        f = Function(args=(Int, String, List(Int)), return=List(String))

Thanks!

_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: Trait-typing of traits: Function, Method, Callable

Robert Kern
On Fri, Nov 30, 2012 at 4:35 PM, Des.P <[hidden email]> wrote:

> I really like how parameterized data-structure types are handled by traits:
>
>         c = List(Tuple(Int, String),  Instance(A))
>
> Why isn't this approach also used to trait-type Functions (and Methods, Callables, ...) by their argument and return types?
>
> class A:
>         i = Int
>         s = String
>         f = Function(args=(Int, String, List(Int)), return=List(String))

Do you mean decorating methods to type-check their arguments and
returns? We used to have a decorator that does this. We never found it
to be useful, so it has not been maintained. It may still work, but I
don't recommend using it.

--
Robert Kern
Enthought
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev