View · Search · Index
No registered users in community xowiki
in last 10 minutes

RE: [Xotcl] Is this a bug?

From: Murr, Florian <florian.murr_at_siemens.com>
Date: Thu, 8 Dec 2005 15:39:27 +0100

When I run the script, I get:

::x y 'y0'
::x y 'y1'
::x init ''
::x y ''
expected 'y1', but got: ''

Yes, you are right, I overload the setter/getter method and expected
naively that it just prints the puts-statement and works otherwise
unchanged. [Should have read the manual more properly, I guess :-)]
I can achieve my desired result too, by doing something like:

X instproc y {args} {
    puts "[self] y '$args'"
    my instvar y
    if {[llength $args]} { set y [lindex $args 0] }
    next
}

But I wanted to have an 'official' answer to this behaviour.

Regards,
- Florian


-----Original Message-----
From: Gustaf Neumann [mailto:neumann_at_wu-wien.ac.at]
Sent: Thursday, December 08, 2005 12:43 PM
To: Murr, Florian
Cc: xotcl_at_alice.wu-wien.ac.at
Subject: Re: [Xotcl] Is this a bug?

Hmm, are you sure? the script you have sent does not produce the message
you are indicating....

~/scripts> set ::xotcl::version
1.3
~/scripts> set ::xotcl::patchlevel
.8
~/scripts> Class X -parameter {
> {y y0}
>}
::X
~/scripts> X instproc init {args} { puts "[self] init '$args'"; next }
~/scripts> X instproc y {args} {
> set x [next]
> puts "[self] y '$args'"
> set x
>}
~/scripts> X create x -y y1
::x y 'y0'
::x y 'y1'
::x init ''
::x
=============================
however, most probably it is not doing what you might be expecting.
your method y overwrites the setter method of parameter y, therefore in
this example, not much happens in the next of method y.

maybe you had in mind to overload the setter/getter method, which you
can do e.g. with a mixin (see below)

Class X -parameter {
    {y y0}
} -instmixin [Class new -instproc y args {
  puts "[self] [self proc] $args"
  set x [next]
  puts "[self] [self proc] $args setter returns <$x>"
  return $x
}]

X create x -y y1
puts x.y=[x set y]