archives

function overriding workaround in dynamically typed languages

hi,
i had a chance to make my hand dirty with ruby. IMHO untypedness of these dynamically typed language is more a nuisance than as a help. define a class, and if you want your behaviour different depending upon the type of object, only option left is check if it is one of the kind of object you are interested and then work accordingly..

def fun(inobj)
if inobj.kind_of?(obj1)
do something..
elsif inobj.kindof?(obj2)
do something.
endif

except these switch cases, is there any better way of handling the situation, where overridden function would have been helpful (in pure OO sense)

regards
chinmay

Real-World Haskell, the book

Don Stewart, John Goerzen and I are excited to announce that we're working on a book for O'Reilly, the title of which is "Real-World Haskell". We hope that the book will be useful for getting people quickly bootstrapped into applying Haskell to real problems, and shedding the language's undeserved "academic only" aura. We're delighted that O'Reilly has agreed to publish the book under a Creative Commons license, so we'll be able to make it available to as many people as possible.

For more information, see our web site.

Picky libraries, picky languages?

STL has some complexity requirements specified. (Dunno how much people really meet them, or what the constant factors are, of course.) I often find myself scratching my head trying to figure out what, if any, specification the Java standard libraries are following in terms of e.g. performance and behavioural contracts.

To what degree do people value the idea of providing a standard library for a language that is super well specified w.r.t. things like time and space complexity, suitability for concurrency, behavioural patterns, use of nulls, etc.? (Personally, as a library consumer, I think that would all be the bee's knees.) It sure seems like a rarity.

Further, to what degree should such things be available as core concepts in a language? Are various complexity metrics describable in any design-by-contract systems? It would possibly be neat to declare that a method has a certain running time complexity, and then have the compiler and tools chain that information together throughout the call tree (I'm not expecting them to prove the declared complexities). And ways to put assertions or requirements in bounding those values.

I've poked around but haven't turned up any great refs, thanks for any info/pointers.

I guess to some degree I see this all being aimed at correctness by construction vs. relying too much on post-hoc testing.

DbC + OPascal == Chrome

(Hadn't seen this before, didn't find it mentioned on LtU via the search.)

One of the most exciting features Chrome brings to .NET are Class Contracts, a concept comparable to "Design by Contract" introduced by Eiffel. Chrome is the first attempt to bring DBC-like concepts into a main-stream language.

I'm not sure I'd call a new version of Object Pascal coming from a single vendor "a main-stream language" but Chrome still sounds interesting.

Error messages

This looks interesting -- has anyone had a closer look?

SEMINAL: Searching for Error Messages IN Advanced Languages

Benjamin Lerner, Dan Grossman, and Craig Chambers

Seminal is a new approach to providing useful type-error messages during compilation, while simultaneously making compilers simpler, more reliable, and faster. The key idea is to use a simple and robust type-checker as an oracle for an error-message finder that uses search to find a good error message in the form of a "similar" code skeleton that would type-check.

Their system is for OCaml, btw. Personally I find the standard OCaml messages reasonably useful... but I have no idea how much hair is behind them in the compiler.

Josh