|
From: | Tobia Conforto |
Subject: | Re: [Chicken-users] handle "unbound variable" exception for undefined procedures? |
Date: | Wed, 24 Dec 2008 11:53:15 +0100 |
Shawn Ruledge wrote:
It would be cool if the proxy method implementations could be defined on an as-needed basis.
IMHO a different object system would be better suited to this "lazy method definition".
I'm thinking of a message-passing model (think of Smalltalk or Objective-C) where each object is a lambda. Here is the trivial example:
#;1> (define (make-point x y) ---> (match-lambda* ---> (('x) x) ---> (('y) y) ---> (('x new) (set! x new)) ---> (('y new) (set! y new)))) #;2> (define p1 (make-point 2 3)) #;3> (p1 'x) 2 #;4> (p1 'y 4) #;5> (p1 'y) 4 #;6>Mind you, this is the simplest implementation possible, without inheritance, polymorphism or anything useful. But if you find (or write) a full-fledged object system that works like this (probably based on table lookup instead of static pattern matching) then you will have no trouble adding a handler for unknown methods that fetches the definitions on the fly.
-Tobia
[Prev in Thread] | Current Thread | [Next in Thread] |