Design Patterns in Dynamically-Typed Languages

Michel Fortin michel.fortin at michelf.com
Wed Apr 22 04:23:31 PDT 2009


On 2009-04-21 13:14:07 -0400, Andrei Alexandrescu 
<SeeWebsiteForEmail at erdani.org> said:

> There's been quite some discussion lately about dynamically-typed 
> languages et al. Here's a pretty good and easy-to-follow presentation 
> by Peter Norvig (AI guru among other gurusdoms he owns) on how 
> dynamically-typed languages make implementation of various design 
> patterns considerably easier:
> 
> http://norvig.com/design-patterns/

I love that sentence: "Long ago, a subroutine call was just a pattern" 
followed by some assembler code equivalent to a function call.

Somewhere in there it says that in a dynamic language types and classes 
are objects available at runtime, which means you can put types into 
variables. That's very true in Objective-C (where classes are 
themselves objects).

We're almost there in D: ClassInfo represents a class, TypeInfo a type, 
but what we can do with them currently is of limited utility. They're 
also distinct entities from the compile-time type concept. Allowing 
automatic unboxing of compile-time types to TypeInfo/ClassInfo, and 
adding runtime-reflection equivalent to what is available through 
compile-time reflection) would help drastically at using D as a dynamic 
language.


-- 
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/




More information about the Digitalmars-d mailing list