[Python-ideas] ML Style Pattern Matching for Python
spir
denis.spir at gmail.com
Sat Dec 18 12:45:49 CET 2010
On Sat, 18 Dec 2010 12:23:45 +0100
Eike Welk <eike.welk at gmx.net> wrote:
> Class Creation
> --------------
>
> Foo = class {| a, b |}
>
> This should be equivalent to:
>
> class Foo(object):
> def __init__(self, a, b):
> self.a = a
> self.b = b
>
> Inheritance is not so important in the context of classes that have no
> methods. It could be expressed with a new method ("inherits") of the
> metaclass. Like this:
>
> Foo = class {| a, b |}.inherits(Bar, Baz)
>
> How one would create methods, and if it should be possible to create method at
> all, needs to be discussed.
What advantage?
> Instance Creation
> -----------------
>
> foo = {| a=1, b=2 |}:Foo
>
> This should be equivalent to:
>
> foo = Foo(a=1, b=2)
>
> In the usual case, it should not be necessary to specify the class name:
>
> foo = {| a=1, b=2 |}
I want composite object literal notation as well. But certainly not {| a=1, b=2 |}. Rather (a=1, b=2) or (a:1, b:2).
Untyped case would created an instance of Object (but since as of now they can't have attrs, there should be another modif), or of a new FreeObject subtype of Object.
> The run-time should search for a class with a matching "__init__" method.
? conflicts?
Denis
-- -- -- -- -- -- --
vit esse estrany ☣
spir.wikidot.com
More information about the Python-ideas
mailing list