private methods ? override ?
[1/4] from: arngar:gmai:l at: 6-Jun-2007 19:24
Hi all, As you see I post many questions these days, I want to understand what I can and cannot do with rebol ... 1/ In rebol you can make object, but as I read it is not possible to create private function ? 2/ Is it possible to call the parent function, then override it, patient make object! [ do-something func  [ print "something" ] ] super-patient make patient [ do-something func  [ super <------------------ I would like to call the parent function print "something else" <----------------- Add this code after calling the parent's function ] ] thanks for help arnaud
[2/4] from: moliad::gmail::com at: 6-Jun-2007 14:09
this is only possible with class type object models. REBOL has a prototype object model, and static binding. what happens is that each object is its own class really, so there is no concept of parent or super class. you can rig up a derive function I guess which actually includes the original code within the derived functions, when they have the 'SUPER word... not for novices though... I don't have time for it right now, but You've just triggered a small fun project in my tests folder, and will come back with a working code sample in a few hours. -MAx On 6/6/07, Arnaud Garcia <arngar-gmail.com> wrote:
[3/4] from: gregg:pointillistic at: 6-Jun-2007 14:41
Hi Arnaud, AG> As you see I post many questions these days, I want to understand AG> what I can and cannot do with rebol ... That's great. Asking questions helps everybody. AG> 1/ In rebol you can make object, but as I read it is not possible to AG> create private function ? It can be done, but it's more work that REBOLers normally want to use. :-) o: make object! [ a: 0 b: 1 fn-1: fn-2: none use [c d] [ c: "xyz" fn-1: does [print c] fn-2: does [a: 2 d: 4] ] ] o: make object! [ get-a: set-a: get-b: set-b: none use [_a _b] [ _a: _b: none get-a: does [_a] set-a: func [value] [_a: value] get-b: does [_b] set-b: func [value] [_b: value] ] ] Marc Meurrens did some extra research in this area as well. I'm not sure if he's still on the ML, after all the changes it's gone through, but maybe he'll chime in. -- Gregg
[4/4] from: santilli::gabriele::gmail::com at: 6-Jun-2007 23:16
2007/6/6, Arnaud Garcia <arngar-gmail.com>:
> 2/ Is it possible to call the parent function, then override it,
A simple way to ovverride a function is (does not need to be inside an object): do-something: does [print "something"] use [super] [ super: :do-something do-something: does [ super print "something else" ] ] You can easily create an OVERRIDE function that does that, or you can create your own object constructor that overrides the functions that way istead of replacing them. HTH, Gabriele.