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

Weblog Page

Showing 1471 - 1480 of 1561 Postings (summary)

Re: [Xotcl] XOTcl and Thread

Created by hypermail2xowiki importer, last modified by Stefan Sobernig 02 Jan 2017, at 11:15 PM

From: Krzysztof Frukacz <frukacz.krzysztof_at_gmail.com>
Date: Fri, 11 Feb 2011 15:09:39 +0100

Hello everyone,

On 02/11/2011 08:37 AM, mail_at_xdobry.de wrote:
> I have run also into this problem (trap).
> Threads in Tcl are different than in Java or C#.
> The tcl threads are more like new independent processes (at Tcl level).
>

I have noticed that and I must say I really miss that Java/C type
threads. I will now describe my problem more generally, maybe somebody
will give me a hint on a good solution.

I have a class called Modem. It handles communication with a modem over
serial port using AT commands. This class contains for example method
sendSMS, that of course sends an SMS message :)
I also have other objects that gather data from different sources and
they should report it over SMS. I would like to run those in separate
threads.

In C/C++/Java I would do that:
1. create Modem object
2. start several threads for data processing objects
3. each data processing object will call [modem sendSMS +49123456789
$reportText ]
For C++/Java every thread would get access to single object that handles
communication (serial interface cannot be used by two objects at the
same time). Of course Modem would implement some synchronization
mechanisms like mutex (I find Java's ReentrantLock extremely useful).

I'll be grateful for your suggestions how to do it in XOTcl.

-- 
Krzysiek

[Xotcl] Segfault after undefining "new" proc in a class namespace

Created by hypermail2xowiki importer, last modified by Stefan Sobernig 02 Jan 2017, at 11:15 PM

From: Arthur Schreiber <schreiber.arthur_at_googlemail.com>
Date: Fri, 25 May 2012 11:07:53 +0200

Hey Gustaf,

The following is propably a very uncommon use case, but it causes a
segfault, so I think it's rather serious:

% package require nx
% nx::Class create A {}
% proc ::A::new {} { return "something" }
% A new
something
% rename ::A::new ""
% A new
[1] 2515 segmentation fault (core dumped) tclsh

Kind regards,
Arthur

Re: [Xotcl] filters and next

Created by hypermail2xowiki importer, last modified by Stefan Sobernig 02 Jan 2017, at 11:15 PM

From: Andriy Tkachuk <ant_at_imt.com.ua>
Date: Mon, 22 Apr 2002 17:15:44 +0300 (EEST)

hello!

it seems yet another bug with this theme:
if there are several filters:

Class A
A instproc msg args {
        puts [concat A: $args]
        next
}

Class B -superclass A
B instproc msg args {
        my instvar a b
        puts [concat B: $args]
        next
}

B instproc my_filter args {
        set ff [my info filter]
        puts "filter: calledproc: [self calledproc]; args: $args"
        my msg "in filter before next; calledproc: [self calledproc]"
        set res [next]
        #my msg "in filter after next; calledproc: [self calledproc]"
        return $res
}

B instproc my_filter2 args {
        return [next]
}

B b

b filter {my_filter my_filter2}

xotclsh [/usr~]b msg bb
filter: calledproc: msg; args: bb
B: {in filter before next; calledproc: msg}
B: {in filter before next; calledproc: msg}
A: {in filter before next; calledproc: msg}
xotclsh [/usr~]

if uncomment in my_filter msg in post-next part, then:
"too many nested calls to Tcl_EvalObj"

thanks,
  Andriy.

On Fri, 19 Apr 2002, Uwe Zdun wrote:

> Hi Andriy,
>
> this was a little bug. We have closed down the filter chain upon the "msg"
> method but the filter was not done with its own next. I'll attach an xotcl.c
> file that should fix the problem (the fix will also be in the next xotcl
> release ... but as this is a quite unusual case we don't produce a full patch
> release for this fix). Simply replace the xotcl.c file in the distribution
> and re-compile ...
>
> --uwe
>
>
> On Wednesday 17 April 2002 05:46 pm, Andriy Tkachuk wrote:
> > Hello! :)
> >
> > How it must works, when in pre/post part of filter
> > object calls his procs that calls next?
> > Situation like here:
> >
> > Class A
> > A instproc msg msg {
> > puts "puts: $msg"
> > }
> >
> > Class B -superclass A
> > B instproc msg msg {
> > next
> > }
> >
> > B instproc my_filter args {
> > my msg "before next in filter"
> > next
> > }
> >
> > B b
> >
> > b filter my_filter
> > b msg bb
> > puts: before next in filter
> >
> > that's all!: there is no "puts: bb".
> >
> > if filter like this:
> >
> > B instproc my_filter args {
> > my msg "before next in filter"
> > next
> > my msg "after next in filter"
> > }
> >
> > then:
> > "too many nested calls to Tcl_EvalObj"
> >
> > Thank you.
> >
> > _______________________________________________
> > Xotcl mailing list - Xotcl_at_alice.wu-wien.ac.at
> > http://alice.wu-wien.ac.at/mailman/listinfo/xotcl
>

--
  Because strait is the gate, and narrow is the way, which leadeth unto
   <b>life</b>, and few there be that find it. (MAT 7:7)
 <b>Ask</b>, and it shall be given you; <b>seek</b>, and ye shall find;
   <b>knock</b>, and it shall be opened unto you... (MAT 7:14)

Re: [Xotcl] "Simple Delegation" revisited (long post)

Created by hypermail2xowiki importer, last modified by Stefan Sobernig 02 Jan 2017, at 11:15 PM

From: Uwe Zdun <uwe.zdun_at_uni-essen.de>
Date: Fri, 13 Jul 2001 14:00:33 +0200

Hi Sheik,

sorry for the late response. I attach a sligtly different variant of your
filter program that should run. Look for "XXX" comments to see what I had to
change.

Cheers,

Uwe


#################################################################


#create SimpleDelegation as a meta-class

Class SimpleDelegation -superclass Class
SimpleDelegation instproc sdFilter args {
  set method [self calledproc]
  if {[[self] exists delegate]} {
    set del [[self] set delegate]
    puts "Filter $del $method"

    #if delegate has method then dispatch it.
    if {[$del procsearch $method] != ""} {
      #
      # XXX:
      #
      # eval [eval [$del $method $args]] does not work
      #
      return [eval $del $method $args]
    }
    return [next];
  }

  #
  # XXX:
  # you have forgotten this "next". Remember the filter is
  # called on every call. Also on "[self] set delegate $d" in init.
  # if you do not pass such calls through, the delegate must
  # be set before the filter is appended.
  #
  next
}

SimpleDelegation instproc init args {
  [self] filterappend [self class]::sdFilter
  next
  [self] instproc setDelegate {d} {
    [self] set delegate $d
  }
}

SimpleDelegation A -parameter delegate
SimpleDelegation B -parameter delegate

A instproc m {x} {
  puts "[self] [self class] [self proc] $x"
  return [next]
}

B instproc m {x} {
  puts "[self] [self class] [self proc] $x"
  next
  return [expr {$x*2 + [[self] set v]}]
}

Class C

#method "m" renamed to "m2" here.
C instproc m2 {x} {
  puts "[self] [self class] [self proc] $x"
  next
  return [expr {$x*3 + [[self] set v]}]
}
A a
B b

a setDelegate b
b set v 100
C c
b setDelegate c
c set v 100

#
# XXX:
# here, it said "a m 123", but you require some indiretion so that
# the filter knows that it should call m2 instead of m
#
# to make the example run, i just call m2 directly ...
#
puts "result = [a m2 123]"

#################################################################


















On Sunday 08 July 2001 19:10, Sheik Yussuff wrote:

> > Just over 6 months ago,Catherine Letondal raised
>
> the issue of implementing "simple delegation".
>
> Professor G. Neumann replied with some code showing
>
> how it can be done as well as suggesting that one may
>
> use a filter to filter all methods or an instmixin
>
> to target specific methods for delegation.
>
> I am now learning Tcl and XOTcl (a week or so now)at the
>
> same time and have decided to try the filter approach.
>
> The Experiment:
>
> 1. Create a meta-class SimpleDelegation
>
> 2. add a filter sdFilter to this meta-class
>
> 3. add an instproc setDelegate
>
> 4. Create classes A and B using SimpleDelegate
>
> 5. Create class C using Class
>
> 6. A has as delegate(instvar) an object of class B;
>
> B has as delegate an object of class C
>
> 7. A,B and C has a method "m" defined
>
> The Problem: (Using Windows binary ver 0.85)
>
> I extended Prof. Neumann's code to handle above
>
> and it works.(see Code1 below)
>
> My experiment(Code 2) works only for the following
>
> cases(that I tested):
>
> 1. A,B and C has a method "m".
>
> 2. The instvar delegate removed from B
>
> It does not work when I rename the method
>
> "m" in class C to "m2".
>
> In this case I expect an object of class B to
>
> execute "m" but instead I get an object of class
>
> A executing "m" instead.
>
> I would be grateful for any pointers to resolve
>
> this problem.
>
> Also I want to try to implement delegation as
>
> described by Prof. Lieberman(OOPSLA 1986 paper).
>
> Will be grateful for any pointers on this also.
>
> ................
>
> Code1: Prof Neumann's code inelegantly extended
>
> Class A -parameter delegate
>
> A instproc handleDelegation {result} {
>
> if {[[self] exists delegate]} {
>
> set context [::info level -1]
>
> #look for method in delegated object
>
> if {[[[self] set delegate] procsearch [lindex $context 0]] != "" } {
>
> ::upvar $result y
>
> set y [eval [[self] set delegate] $context]
>
> return 1
>
> }
>
> }
>
> return 0
>
> }
>
> A instproc m {x} {
>
> if {[[self] handleDelegation r]} {
>
> return $r
>
> } else {
>
> puts "[self] [self class] [self proc] $x";
>
> return [next]
>
> }
>
> }
>
> Class B -parameter delegate
>
> B instproc handleDelegation {result} {
>
> if {[[self] exists delegate]} {
>
> set context [::info level -1]
>
> #look for method in delegated object
>
> if {[[[self] set delegate] procsearch [lindex $context 0]] != "" } {
>
> ::upvar $result y
>
> set y [eval [[self] set delegate] $context]
>
> return 1
>
> }
>
> }
>
> return 0
>
> }
>
> B instproc m {x} {
>
> if {[[self] handleDelegation r]} {
>
> return $r
>
> } else {
>
> puts "[self] [self class] [self proc] $x";
>
> return [next]
>
> }
>
> }
>
> Class D
>
> D instproc m2 {x} {
>
> puts "[self] [self class] [self proc] $x"
>
> next
>
> return [expr {$x*2 + [[self] set v]}]
>
> }
>
> D d1
>
> d1 set v 100
>
> B b1 -delegate d1
>
> A a1 -delegate b1
>
> puts "result = [a1 m 123]"
>
> ................................................
>
> Code2: My Try using filters
>
> #create SimpleDelegation as a meta-class
>
> Class SimpleDelegation -superclass Class
>
> SimpleDelegation instproc sdFilter args {
>
> set method [self calledproc]
>
> if {[[self] exists delegate]} {
>
> set del [[self] set delegate]
>
> #if delegate has method then dispatch it.
>
> if {[$del procsearch $method] != ""} {
>
> return [eval [$del $method $args]]
>
> }
>
> return [next];
>
> }
>
> }
>
> SimpleDelegation instproc init args {
>
> [self] filterappend [self class]::sdFilter
>
> next
>
> [self] instproc setDelegate {d} {
>
> [self] set delegate $d
>
> }
>
> }
>
> SimpleDelegation A -parameter delegate
>
> SimpleDelegation B -parameter delegate
>
>
>
> A instproc m {x} {
>
> puts "[self] [self class] [self proc] $x"
>
> return [next]
>
> }
>
> B instproc m {x} {
>
> puts "[self] [self class] [self proc] $x"
>
> next
>
> return [expr {$x*2 + [[self] set v]}]
>
> }
>
> Class C
>
> #method "m" renamed to "m2" here.
>
> C instproc m2 {x} {
>
> puts "[self] [self class] [self proc] $x"
>
> next
>
> return [expr {$x*3 + [[self] set v]}]
>
> }
>
> A a
>
> B b
>
> a setDelegate b
>
> b set v 100
>
> C c
>
> b setDelegate c
>
> c set v 100
>
> puts "result = [a m 123]"
>
> ...................................................
>
> Regards,
>
> Sheik Yussuff
>
> email: sheik_at_carib-link.net

----------------------------------------
Content-Type: text/html; charset="iso-8859-1"; name="Attachment: 1"
Content-Transfer-Encoding: quoted-printable
Content-Description:
----------------------------------------

-- 
Uwe Zdun
Institute for Computer Science, University of Essen
Phone: +49 201 81 00 332, Fax: +49 201 81 00 398
zdun_at_{xotcl,computer,acm}.org, uwe.zdun_at_uni-essen.de

Re: [Xotcl] XOTcl packages

Created by hypermail2xowiki importer, last modified by Stefan Sobernig 02 Jan 2017, at 11:15 PM

From: Jeff Hobbs <jeffh_at_activestate.com>
Date: Sat, 4 Apr 2009 06:48:01 -0700

On 4-Apr-09, at 5:50 AM, Stefan Sobernig wrote:
>> On 03/04/2009 11:24 AM, Victor Mayevski wrote:
>>> I really like that XOTcl is being included with ActiveState
>>> distribution, and even updates via teacup are working. But there is
>>> one issue - why is it that the rest of XOTcl packages (comm,
>>> serializer etc) are not being included?
>> The teapot is designed for individual packages (though they can
>> have dependencies). In building, it goes through the usual
>> configure / make / install steps. XOTcl only packages up the core
>> library when it does that. The other packages would be best
>> handled separately somehow.
>
> Couldn't teacup provide the "--with-all=yes" configure flag so that
> the
> accompanying infrastructure is included?

It's actually at the build level. You would need an equivalent make
all and install all, but it would need to identify the packages
separately for packaging as well. Ideally these would be retrievable
separately in RCS and combined into the meta package via RCS tricks
(possible with almost all RCS systems) or make dist. That way teacup
and other package-oriented providers could work at the package level,
which XOTcl could still have the traditional megapackage for those who
use it.

Jeff

[Xotcl] Training in Xotcl

Created by hypermail2xowiki importer, last modified by Stefan Sobernig 02 Jan 2017, at 11:15 PM

From: Aslam Mohammed \(masam\) <"Aslam>
Date: Tue, 29 Aug 2006 15:47:41 -0400

Friends,
 
We are looking for some expert in XOTCL to come and train, does your org
does training if yes can u pls do contact
_at_ 919-392-8267
 
Tx
Aslam

Re: [Xotcl] experience installing xotcl on MacOsX ?

Created by hypermail2xowiki importer, last modified by Stefan Sobernig 02 Jan 2017, at 11:15 PM

From: Gustaf Neumann <neumann_at_wu-wien.ac.at>
Date: Tue, 21 Sep 2004 11:40:06 +0200

On Friday 17 September 2004 19:19, Catherine Letondal wrote:
> Dear members of xotcl the list,
>
> Has someone any experience in installing XOtcl on MacOsX ?
> I have found a "Portfile" but I don't know what to do with it?

Catherine,

isn't the Mac OS X Tcl/Tk Aqua 8.4.7 Release something for
you to use, it contains XOTcl binaries.....

http://groups.google.at/groups?q=xotcl&hl=de&lr=&ie=UTF-8&scoring=d&selm=pgpmoose.200408041618.26617%40despot.non.net&rnum=8

-gustaf
>
> Thanks in advance !

-- 
Univ.Prof. Dr.Gustaf Neumann
Abteilung für Wirtschaftsinformatik und Neue Medien
Wirtschaftsuniversität Wien, Augasse 2-6, 1090 Wien

[Xotcl] xotcl namespace auto-import

Created by hypermail2xowiki importer, last modified by Stefan Sobernig 02 Jan 2017, at 11:15 PM

From: Neil Madden <nem_at_cs.nott.ac.uk>
Date: Mon, 24 May 2004 21:57:09 +0100

Hello all,

Small feature request: could XOTcl be made to automatically [namespace
import] the ::xotcl::* commands into every object it creates? I'm
trying to write a package using XOTcl, and so don't want to import
XOTcl into the global namespace. As Tcl's command resolution rules are
current namespace then global namespace only, I can't just import it
into my package namespace, as all objects (which are sub-namespaces,
AIUI) would skip the containing namespace when resolving. So, I have
two options:

1) Fully qualify everything - lots of xotcl::my, xotcl::self etc
everywhere
2) Import xotcl namespace manually into each object namespace.

2 is better than 1, but is still a bit of a pain to remember to do, and
I seem to remember trying it and it not always working (I could be
wrong about that).

So, my feature request would be that all Objects [namespace import] the
xotcl namespace automatically.[1]

Cheers,

Neil.

[1] [namespace import] is actually quite expensive as it creates
commands in each namespace which forward on to the originals. Possibly
if XOTcl is already hooked in to Tcl's resolver APIs for method
dispatch/inheritance, then the xotcl namespace could just be added as a
final search path (after xotcl::Object).

Re: [Xotcl] Workaround for "value of parameter could be non-positional argument"

Created by hypermail2xowiki importer, last modified by Stefan Sobernig 02 Jan 2017, at 11:15 PM

From: Gustaf Neumann <neumann_at_wu.ac.at>
Date: Thu, 21 Jun 2012 16:01:14 +0200

Some background: if one has a code like

    set value -v
    Test new -value $value

even the tcl extension developer has no means to distinguish between a
variable containing a value and constant like:

    Test new -value -v

in practice, statements like the one above are c common source of
problem, so nsf spits out in the case of a fully unknown argument the
warning you mentioned. So, getting the warning is a feature, not a bug :)

The simplest way to get rid of the message is to turn of debug. by
default, the debug level of nsf is 1, setting it to 0 will remove these
messages

    nsf::configure debug 0
    Test new -value -v

This will of course get rid of all warnings (we had no warnings in XOTcl
1.*).

An alternative option is to provide a value type for the property, such
as e.g. integer, object, ... which are for your example most probable
not suitable types. However, nsf contains predefined support for all
value types definable by "string is ...", or one can use application
specific value checkers; so we can get rid of the message by saying that
the permissible values must be e.g. printable. Setting a different value
type helps because the default value-checker (for unspecified values)
spits out the warning.

    # turn debug on again
    nsf::configure debug 1

    # define the property to accept printable values
    nx::Class create Test {
        :property value:required,print
    }

    Test new -value -v

Hope this helps and explains things...

-gustaf neumann

Am 21.06.12 10:22, schrieb Arthur Schreiber:
> Hello Gustaf,
>
> what is the recommended way to work around the warning that is put out by
> code like this:
>
> nx::Class create Test {
> :property value:required
> }
>
> set value "-h"
> Test new -value $value
> # => Warning: value '-h' of parameter '-expected' could be a non-positional
> argument during:
> # ::nsf::__#0l configure -expected -h
>
>
> Kind regards,
> Arthur
>

-- 
Univ.Prof. Dr. Gustaf Neumann
Institute of Information Systems and New Media
WU Vienna
Augasse 2-6, A-1090 Vienna, AUSTRIA

Re: [Xotcl] Help with singleton design pattern

Created by hypermail2xowiki importer, last modified by Stefan Sobernig 02 Jan 2017, at 11:15 PM

From: Gustaf Neumann <neumann_at_wu-wien.ac.at>
Date: Tue, 22 Apr 2003 12:03:56 +0200

On Saturday 19 April 2003 07:40, Michael A. Cleverly wrote:
> As I'm starting to learn XOTcl, I decided to try and implement a singleton
> design pattern as an educational exercise.

 Dear Michael,

 Uwe has already answered the filter-part. To solve the singleton
 problem, there is much less code necessary. The following example
 uses a metaclass that provides an instproc "new":

==========================================
Class Singleton -superclass Class
Singleton instproc new args {
  expr {[my exists instance] ?
        [my set instance] : [my set instance [next]]}
}
==========================================

 A new singleton can be created in a declarative way, and
 all calls to "new" will return the same instance (you can
 also raise errors, if you prefer)

==========================================
Singleton MyClass
puts "1. [MyClass new]"
puts "2. [MyClass new]"
==========================================

 Certainly the same maechanism can be applied on "create" as well.
 In the current XOTcl version, you have to duplicate the instproc
 for "create", in the forthcoming xotcl version registering a single
 instproc on create will be sufficient (in 1.0.2, the method new
 calls directly the implementation of create, the next version
 will go through the dispatcher).

 best regards
-gn

-- 
Univ.Prof. Dr.Gustaf Neumann
Abteilung für Wirtschaftsinformatik
WU-Wien, Augasse 2-6, 1090 Wien

Next Page