No registered users in community xowiki
in last 10 minutes
in last 10 minutes
[Xotcl] RE: [Xotcl] Probable bug: no method calls with "next" & init
From: Kristoffer Lawson <setok_at_fishpool.com>
Date: Mon, 5 Feb 2001 23:28:30 +0200 (EET)
On Mon, 5 Feb 2001, Rick Hedin wrote:
> Hi Kristoffer.
>
> This behavior seems correct. You are trying to pass three arguments:
>
> 1. myArg 2. -whatever 3. niceSystem
>
> to one formal parameter:
>
> arg
>
> We could send one argument:
>
> next {myArg -whatever niceSystem}
>
> or use the special properties of the args keyword:
>
> Foo instproc init {args} { . . .
>
> Am I looking at this right?
No, that wasn't the point. When normally creating an object you
can call other methods along with the initialisation procedure
(this is mentioned in the section of the tutorial about parameters,
IIRC). So the following works:
Class Foo
Foo instproc init {arg} {
puts "arg: $arg"
}
Foo instproc anotherMethod {param} {
puts "param: $param"
}
set foo [Foo new initArg -anotherMethod methodParam]
Output:
param: methodParam
arg: initArg
This can often be extremely handy (and a nice feature of XOTcl). But
apparently this does not work with [next] and init. It's not exactly
documented that it doesn't work, but it would feel natural to assume that.
- ---------- = = ---------//--+
| / Kristoffer Lawson | www.fishpool.fi|.com
+-> | setok_at_fishpool.com | - - --+------
|-- Fishpool Creations Ltd - / |
+-------- = - - - = --------- /~setok/
Date: Mon, 5 Feb 2001 23:28:30 +0200 (EET)
On Mon, 5 Feb 2001, Rick Hedin wrote:
> Hi Kristoffer.
>
> This behavior seems correct. You are trying to pass three arguments:
>
> 1. myArg 2. -whatever 3. niceSystem
>
> to one formal parameter:
>
> arg
>
> We could send one argument:
>
> next {myArg -whatever niceSystem}
>
> or use the special properties of the args keyword:
>
> Foo instproc init {args} { . . .
>
> Am I looking at this right?
No, that wasn't the point. When normally creating an object you
can call other methods along with the initialisation procedure
(this is mentioned in the section of the tutorial about parameters,
IIRC). So the following works:
Class Foo
Foo instproc init {arg} {
puts "arg: $arg"
}
Foo instproc anotherMethod {param} {
puts "param: $param"
}
set foo [Foo new initArg -anotherMethod methodParam]
Output:
param: methodParam
arg: initArg
This can often be extremely handy (and a nice feature of XOTcl). But
apparently this does not work with [next] and init. It's not exactly
documented that it doesn't work, but it would feel natural to assume that.
- ---------- = = ---------//--+
| / Kristoffer Lawson | www.fishpool.fi|.com
+-> | setok_at_fishpool.com | - - --+------
|-- Fishpool Creations Ltd - / |
+-------- = - - - = --------- /~setok/