

Any Python users willing to some feedback on some language ideas I had? Thanks - pwmanagerdied
http://gist.github.com/216041#files

======
makecheck
I'm not sure the block syntax buys as much as you'd want it to. Maybe a more
complex example would help?

For instance, you can create similar syntax with a class definition. I've
tossed together something quick below to emulate your UI library (not really
something I've tried in practice, but the idea is there):

    
    
        class ExampleLabel:
            caption = "This is an example"
            position = (50, 50)
    
        class ClickMeButton:
            caption = "Click me! Click me!"
            on_click = lambda: sys.stdout.write("The button was clicked.\n")
    
        class HelloWorldWindow:
            caption = "Hello World"
            dimensions = (400, 300)
            contains = (ExampleLabel, ClickMeButton)
    

If you then had classes or functions with __kwargs arguments, that recognized
key names such as "caption", "on_click", etc., then the above classes could be
used in this way to instantiate things (either alone, or within something like
a Window):

    
    
        b = Button(**ClickMeButton.__dict__)
        l = Label(**ExampleLabel.__dict__)
    

...or equivalently, on the fly:

    
    
        l = Label(caption="Other label", position=(10, 20))
    

Notice that since everything is defined as a class, instantiating duplicates
is actually taken care of. For example:

    
    
        w1 = Window(**HelloWorldWindow.__dict__)
        w2 = Window(**HelloWorldWindow.__dict__)
    

Since I haven't "inlined" anything in a block assignment, the definition can
be used repeatedly (when put in a class).

~~~
pwmanagerdied
Thank you very much for the feedback.

I tried to keep the examples simple so that the functionality was clear, I'll
try to come up with a more concrete example to demonstrate it's utility.

I'm aware that you can achieve a a lot of already using classes (and
metaclasses), but I thought a clearer syntax would be helpful. I don't seeing
my code cluttered with "class" when that's not what's actually happening, but
of course that could be exactly what was happening in my example.

One thing I originally had in my example (though I decided it wasn't a good
idea so I removed it) was

    
    
        ui.on_event "click", "altclick":
            print("I've been clicked!")
    

where on_event macro takes the paren-less tuple of event names and returns
another macro which takes the block, then does the correct assignment.

I realize this also isn't a strong example, but it's a little bit more than I
have in the post.

