Why does Dynamic Typing really matter?!?

Jason Smith chastel_pelerin at hotmail.com
Fri Feb 7 04:39:33 CET 2003


Hi Laura

Thanks for ur reply....sorry for the incomplete msg, sent it a bit
prematurely!

The book sounds very informative, will def pick up a copy, to bad our
local uni library is behind the times....

This sort of information is exactly what I'm after, I need to justify
a thesis question, that being adding extra, be it instructions, etc..
to the CLR to optimise the compilation of languages that are
dynamically typed...I'm looking at Soft typing as a method to increase
the range of programs I can type statically and for those that I can't
allow the CLR to perform dynamic type checks...

I'm not that familiar with python syntax, actually not familiar at
all, I'm mostly a Haskell hacker...

Thanks again
J.


> Get a copy of _Design Patterns_ and then a copy of _Design Patterns
> Smalltalk Companion_.  Walk through the patterns one by one.  Many
> (I think more than half)  of the Smalltalk ones discuss why theirs
> is simpler than the C++ one due to the fact that Smalltalk is dynamially
> typed.  For a final cut, get Pattern Hatching, where you can watch
> John Vlissides finally decide that something was 'not a pattern' because
> it was too easy to do in Smalltalk :-)




> But if it is Python code you wanted ...
> 
> I wrote this a while ago (hmm, quite a while since I needed to
> import nested_scopes) when somebody wanted to see the Decorator
> Pattern.  Boy is it simple in Python ....
> 
> from __future__ import nested_scopes
> import Tkinter
> 
> class WrappedWidget:
>     def __init__(self, frame, widgetType=Tkinter.Label, **kw):
>         self._widget=widgetType(frame, **kw)
>         self.bind("<ButtonPress-1>", self.gotPressed)
>         
>     def __getattr__(self, name):
>         if name.startswith("__") and name.endswith("__"):
>             raise AttributeError, name
>         else:
>             return getattr(self._widget, name)
> 
>     def gotPressed(self, event):
>         print 'I got Pressed!'
>         self.configure(bg='red')
> 
> ###########################  
> if __name__ == '__main__':
> 
>     root = Tkinter.Tk()
>     quit = Tkinter.Button(root, text="QUIT", fg="red", command=root.quit)
>     quit.pack(side='left')
> 
>     Lab=WrappedWidget(root, fg='green', text='Label (default)')
>     Lab.pack(side='left', fill='both', expand = 1)
> 
>     mydict={'fg':'yellow', 'text':'Button'}
>     But=WrappedWidget(root, Tkinter.Button, **mydict)
>     But.pack(side='left', fill='both', expand = 1)
>     root.mainloop()
> --------------------------------------------




More information about the Python-list mailing list