Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

Never be led astray onto the path of virtue.


comp / comp.lang.tcl / Re: An XOTcl question

SubjectAuthor
* An XOTcl questionHelmut Giese
`* Re: An XOTcl questionStefan Sobernig
 `- Re: An XOTcl questionHelmut Giese

1
Subject: An XOTcl question
From: Helmut Giese
Newsgroups: comp.lang.tcl
Organization: ratiosoft
Date: Wed, 26 Jun 2024 22:17 UTC
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: hgiese@ratiosoft.com (Helmut Giese)
Newsgroups: comp.lang.tcl
Subject: An XOTcl question
Date: Thu, 27 Jun 2024 00:17:41 +0200
Organization: ratiosoft
Lines: 86
Message-ID: <493p7j5mt662no7u9pe6f8e4729jrr7a5n@4ax.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 27 Jun 2024 00:17:38 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="e4d665719b66f5d46919cf4fdb181fe0";
logging-data="2483230"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19Pjvoz/R3KntGx/+xKkYnm"
Cancel-Lock: sha1:dGp/N0YL7rHWQSjrQPcT50UobWY=
X-Newsreader: Forte Free Agent 1.93/32.576 English (American)
View all headers

Hello out there,
I am reviving an old project of mine from around 2008 / 2010 because
I thought I could use some of its parts. The XOTcl version used then
was 1.4 IIRC. The current version is 2.3 which I think is fairly
recent.
My grief is the error message produced when something goes wrong
constructing a new object: The exact reason is - so it seems - never
told - let alone the offending location. This makes it extremely
tedious to advance.
Look at the following example. Context: Having set a particular 'mode'
I click at some place where I want a new line to start. The code:
---
# ctor - coords are <x, y, starting widget>
Line instproc init {canvas coordLst {cName ""}} {
my instvar c cfg coords id

# call base class ctor
lassign $coordLst x y widgets
next $canvas [list $x $y] ;#$cfg ;#$options

set coords {} ; set widgets {}
puts lb
# create first point
my newLinePoint $x $y
puts lc
bindC $c $id <Enter> {s::mkLargePointCurs $c}
}

# Create a new point
Line instproc newLinePoint {x y} {
my instvar c children coords
set x [$c canvasx $x] ; set y [$c canvasy $y]
lappend children [LinePoint [LinePoint autoname Point%d] $c [list
$x $y] \
-parent [self]]
lappend coords $x $y
} ----
I want to create a line starting with a 1st point.
This is the result:
---
Microsoft Windows [Version 10.0.19045.4529]
(c) Microsoft Corporation. Alle Rechte vorbehalten.

d:\x\Test>tclsh main.tcl
lb

and an error window.
---
My conclusions:
- I see 'lb' but not 'lc' - my conclusion is: The error must be in
'newLinePoint'.
- But this is the error message:
--
wrong # args: should be "next canvas coordinates ?mainDict?"
wrong # args: should be "next canvas coordinates ?mainDict?"
::Line ::xotcl::Class->create
invoked from within
"::Line create Line1 .mainFr.c {72 66 ::LEDBtn1} -parent ::C"
("uplevel" body line 1)
invoked from within
"::uplevel $lvl [list [self] create {*}$args]"
(procedure "unknown" line 7)
::Line ::xotcl::Class->unknown
invoked from within
"Line Line$lineNo $c [list $x $y $state] -parent [self]"
(procedure "startCreateLine" line 10)
::C ::Canvas->startCreateLine
invoked from within
"my startCreateLine $state $x $y $line"
...
---
What is this? The call to 'next' has well been passed when it puts out
the 'lb', and in 'newLinePoint' I don't call 'next'.

Questions:
- Has anybody a strategy to cope with this behaviour?
- Or is there a newer version which produces usable error messages?
- I have read that there is a successor to XOTcl.
-- Does it have this same deficiency?
-- If not: Is it somehow upwards compatible with XOTcl?

Oh, this is on Windows 10, 64 bit under tcl 8.6.10.
Any help or idea will be greatly appreciated.
Helmut
PS: Sorry for the long rant.

Subject: Re: An XOTcl question
From: Stefan Sobernig
Newsgroups: comp.lang.tcl
Organization: A noiseless patient Spider
Date: Wed, 10 Jul 2024 22:36 UTC
References: 1
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: stefan.sobernig@wu.ac.at (Stefan Sobernig)
Newsgroups: comp.lang.tcl
Subject: Re: An XOTcl question
Date: Thu, 11 Jul 2024 00:36:28 +0200
Organization: A noiseless patient Spider
Lines: 86
Message-ID: <94712dd1-0594-4ca4-9830-5af3a3cdb12a@wu.ac.at>
References: <493p7j5mt662no7u9pe6f8e4729jrr7a5n@4ax.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 11 Jul 2024 00:36:56 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="b9370f1ba7fa448227078d48f9c5002f";
logging-data="2216418"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+vVQv6PKcgoNyxAVWzXl8/4+kRiLwQFVw="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:gYy7/RVtQzA5ZiUvmUQJFWU3mUk=
In-Reply-To: <493p7j5mt662no7u9pe6f8e4729jrr7a5n@4ax.com>
Content-Language: en-GB
View all headers

Hi Helmut!

> Any help or idea will be greatly appreciated.

I tried to reproduce the erroneous behaviour using XOTcl 2.3 and Tcl
8.6.13 on macOS, but I failed, I am afraid.

Could you create a minimal, reproducible script?

What I tried:

---------------%<---------------
puts [package req Tcl]
puts [package req XOTcl]

## setup

xotcl::Class Base -parameter {parent} \
-instproc init {canvas coordinates {mainDict ""}} {;}

xotcl::Class Line -parameter {{id 321}} -superclass Base

xotcl::Class Point -superclass Base -instproc init {args} {
puts $args
} xotcl::Class LinePoint -superclass Point
proc ::bindC {args} {;}

## distilled

LinePoint instproc init {canvas {coords ""}} { next }

# ctor - coords are <x, y, starting widget>
Line instproc init {canvas coordLst {cName ""}} {
my instvar c cfg coords id
set c .cc
# call base class ctor
lassign $coordLst x y widgets
set tgt [self next]; puts "$tgt === [[lindex $tgt 0] info instargs
[lindex $tgt 2]]"
next $canvas [list $x $y] ;#$cfg ;#$options

set coords {} ; set widgets {}
puts lb
# create first point
my newLinePoint $x $y
puts lc
bindC $c $id <Enter> {s::mkLargePointCurs $c}
}

# Create a new point
Line instproc newLinePoint {x y} {
my instvar c children coords
# set x [$c canvasx $x] ; set y [$c canvasy $y]
lappend children [LinePoint [LinePoint autoname Point%d] $c [list
$x $y] -parent [self]]
lappend coords $x $y
}

## main.tcl ?
::Line Line1 .mainFr.c {72 66 ::LEDBtn1} -parent ::C
---------------%<---------------

This produces:

---------------%<---------------
8.6.13
2.3
::Base instproc init === canvas coordinates mainDict
lb
..cc {72 66}
lc
---------------%<---------------

Could you add the following introspection line just before [next] is
called in your actual script?

---------------%<---------------
set tgt [self next]; puts "$tgt === [[lindex $tgt 0] info instargs
[lindex $tgt 2]]"
---------------%<---------------

Best, Stefan

Subject: Re: An XOTcl question
From: Helmut Giese
Newsgroups: comp.lang.tcl
Organization: ratiosoft
Date: Thu, 11 Jul 2024 21:04 UTC
References: 1 2
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: hgiese@ratiosoft.com (Helmut Giese)
Newsgroups: comp.lang.tcl
Subject: Re: An XOTcl question
Date: Thu, 11 Jul 2024 23:04:44 +0200
Organization: ratiosoft
Lines: 30
Message-ID: <q5h09j11e5ves3rgii6gdq859tifkdulol@4ax.com>
References: <493p7j5mt662no7u9pe6f8e4729jrr7a5n@4ax.com> <94712dd1-0594-4ca4-9830-5af3a3cdb12a@wu.ac.at>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 11 Jul 2024 23:04:42 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="c89967a0abe921ba4046d4949d1d88f8";
logging-data="2775277"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18wMHI57XB+4fDi80wGfkAd"
Cancel-Lock: sha1:u9rBoOGq8obAaKUpMe6iqHNFWi0=
X-Newsreader: Forte Free Agent 1.93/32.576 English (American)
View all headers

Hi Stefan,
thanks for caring, but I'm afraid I cannot reproduce it any more - the
project has progressed. It turned out that the error message was in
fact correct (it was a call to 'next') but this call wasn't in
'newLinePoint' but in 'LinePoint'.
That's in fact my only grief wth XOTcl: The error message produced
when something goes wrong in a constructor. In other situations the
error message pin points the exact location. I just made a quick test
by 'provoquing' an error. The result was as expected:

Provoqued error
while executing
"error "Provoqued error""
(procedure "checkRelPos" line 3)
::s::Line1 ::s::Line->checkRelPos
invoked from within
"my checkRelPos "
(procedure "straightSegment" line 129)
::s::Line1 ::s::Line->straightSegment
... and so on until
"::s::State2 moveStateHL 435 110 1"
(command bound to event)

Only in a constructor this mechanism apparently doesn't work. Well, I
trust that there is a technical reason for this behaviour and it
cannot be helped.

Apart from that XOTcl is a fantastic tool.
Thanks again, Stefan, and best regards
Helmut

1

rocksolid light 0.9.8
clearnet tor