May 11, 2006

Boo AST Attribute Ideas

Here are some ideas I had for handy Boo AST (abstract syntax tree) attributes:
[HandleExceptionWithMessageBox]
def Foo():
CallSomething()
DoStuff()
MaybeCrash()
expands to
def Foo():
try:
CallSomething()
DoStuff()
MaybeCrash()
except ex:
MessageBox.Show(ex.Message)

Very handy for UI code that calls into business objects that may throw up exceptions. Not having to explicitly write the try…except block is a timesaver!

Also,

class MyForm:
btn = Button()

[HandleEvent(btn.Click)]
def ButtonClicked():
print "button clicked"
expands to
class MyForm:
btn = Button()

def constructor():
btn.Click += ButtonClicked

def ButtonClicked():
print "button clicked"
This allows the event hookup to appear on the handling method, rather than miles away in the constructor. This is great for UI code since it means u can delete a method and know there is not still a line of code else trying to point to it. (So basically is works like the VB.NET "handles" keyword.)

- No comments Not publicly viewable


Add a comment

You are not allowed to comment on this entry as it has restricted commenting permissions.

Google Ads

Search this blog

Most recent comments

  • I scratched my eye while i was holding some kind of plastic packaging.. Anyways the corner of the pl… by Ercan on this entry
  • About a year ago my contacts that i was wearing, i guess were fautly, because shortly after they wer… by Jon on this entry
  • I got shower gel in my eye 4 and a half days ago, and becasue i rubbed my eyes a lot, i have scratch… by Chris on this entry
  • This website may help http://www.webmd.com/eye–health/tc/Eye–Injuries–Home–Treatment by S on this entry
  • I somehow got dirt, or debris in my eye. The terrible pain sent me in a tailspin. I was afraid of sa… by Bobbi on this entry

Tags

May 2006

Mo Tu We Th Fr Sa Su
Apr |  Today  | Jun
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31            

Galleries

Blog archive

Loading…
Not signed in
Sign in

Powered by BlogBuilder
© MMXX