in last 10 minutes
Re: [Xotcl] proper way to access xotcl classes
- This message: [ Message body ] [ More options (top, bottom) ]
- Related messages: [ Next message ] [ Previous message ] [ In reply to ] [ Next in thread ] [ Replies ]
- Contemporary messages sorted: [ by date ] [ by thread ] [ by subject ] [ by author ] [ by messages with attachments ]
Date: Thu, 8 May 2008 11:02:48 -0500
I copy and pasted what you posted, and still get the error:
invalid command name "s1"
On Thu, May 8, 2008 at 10:59 AM, Gustaf Neumann <neumann_at_wu-wien.ac.at>
wrote:
> Matthew Smith schrieb:
>
>>
>>
>> Putting in:
>> s1 push a
>> results in an error, however I can do:
>>
>> what is the error? this indicates that you have not defined the method
>> push correctly
>>
>> I get:
>> invalid command name "s1"
>>
> this indicates, that you have not created an object s1. Your program
> should look like the following.....
>
> hope this helps
> -gustaf neumann
>
> ===========================================
> package require XOTcl; namespace import ::xotcl::*
>
> Class Stack
> Stack instproc init {} {
> my instvar things
> set things ""
> }
> Stack instproc push {thing} {
> my instvar things
> set things [concat [list $thing] $things]
> return $thing
> }
> Stack instproc pop {} {
> my instvar things
> set top [lindex $things 0]
> set things [lrange $things 1 end]
> return $top
> }
>
> set s1 [Stack new]
>
> s1 push a
> s1 push b
>
> set x [s1 pop]
> puts "The popped value is $x"
> ===========================================
>
>
Received on Thu May 08 2008 - 18:02:34 CEST
This archive was generated by hypermail 2.2.0 : Thu Nov 06 2008 - 11:10:48 CET