|
From: Clemens H. <c.h...@gm...> - 2000-12-31 01:55:15
|
Hi Manuel,
after some thinking and playing with Brain, I have got some new
ideas:
o Introduce <base>r<digits> style for denoting numbers. That was
coming from Smalltalk, I believe. I like this more than the leading
zero means octal, 0x means hex and so on. It would be more
consistent and could work with *every* number base:
2r01001101 #! Binary number
8r1234567 #! Octal number
16rABC001C #! Hex number
o Introduce a method that enables me to determine if some object is a
native one or not. That one should be easy: Every object derived
from Object or one of its child should return 'false' on
e.g. is-native? Others would returning 'true'.
o Bound methods
This thought I got while thinking about realisation of callbacks. My
thoughts: It should be possible to get implementation of a certain
method. But as we have to differ native methods from Brain methods I
would propose following.
- Introduction of a new object Method or Message
- I can get a bound Method object via e.g.
method = anyobject method: :foo.
- A bound Method object is associated with the object it was taken
from. I can simply call it via :() that would invoke the method as
it would be sended to the object. Like this:
m = 1 method: :+.
m(2). #! equivalent to 1 + 2 => 3
m(3). #! equivalent to 1 + 3 => 4
- From a non-native method, I could extract/get the block that
implements this method:
blk = (anObj method: :anMethod) block
for native methods this should return 'nil'.
- I can rebind bound Method objects to another receiver of same
type:
m = 1 method: :+.
m(3). #! equivalent to 1 + 3 => 4
m rebind-to: 2.
m(3). #! rebound so equiv to 2 + 3 => 5
This could be used for fine callback tricks ...
I think this would be nice, as we could assign some bound Method
objects as e.g. callbacks. We would not have to assign object *and*
method name then. In an example of signal-slot in one of my last
mails I have proposed:
obj1 connect: :foo with: obj2 slot: :slot-foo.
Due to my proposal, this could be changed then to:
obj1 connect: :foo with: (obj2 method: :slot-foo).
What do you think about this all?
Ciao,
Clemens.
PS: A happy new year to you, your family and all friends-of-Brain.
--
Clemens Hintze mailto: c.h...@gm...
|